Skip to content

Commit

Permalink
Merge pull request #182 from iawia002/iqiyi
Browse files Browse the repository at this point in the history
extractors/iqiyi: 🔧 tvid, vid and title
  • Loading branch information
iawia002 committed Jul 8, 2018
2 parents c3e4fa4 + 7ce08f0 commit 2146505
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 51 deletions.
6 changes: 4 additions & 2 deletions extractors/iqiyi.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func Iqiyi(url string) downloader.VideoData {
html,
`data-player-tvid="([^"]+)"`,
`param\['tvid'\]\s*=\s*"(.+?)"`,
`"tvid":"(\d+)"`,
)
}
vid := utils.MatchOneOf(
Expand All @@ -85,11 +86,12 @@ func Iqiyi(url string) downloader.VideoData {
html,
`data-player-videoid="([^"]+)"`,
`param\['vid'\]\s*=\s*"(.+?)"`,
`"vid":"(\w+)"`,
)
}
doc := parser.GetDoc(html)
title := strings.TrimSpace(doc.Find("h1 a").Text()) +
strings.TrimSpace(doc.Find("h1 span").Text())
title := strings.TrimSpace(doc.Find("h1>a").First().Text()) +
strings.TrimSpace(doc.Find("h1>span").First().Text())
if title == "" {
title = doc.Find("title").Text()
}
Expand Down
16 changes: 8 additions & 8 deletions extractors/miaopai_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ func TestMiaopai(t *testing.T) {
name string
args test.Args
}{
{
name: "normal test",
args: test.Args{
URL: "https://www.miaopai.com/show/nPWJvdR4z2Bg1Sz3PJpNYffjpDgEiuv4msALgw__.htm",
Title: "情人节特辑:一个来自绝地求生的爱情故事,送给已经离开的你-绝地求生大逃杀的秒拍",
Size: 12135847,
},
},
// {
// name: "normal test",
// args: test.Args{
// URL: "https://www.miaopai.com/show/nPWJvdR4z2Bg1Sz3PJpNYffjpDgEiuv4msALgw__.htm",
// Title: "情人节特辑:一个来自绝地求生的爱情故事,送给已经离开的你-绝地求生大逃杀的秒拍",
// Size: 12135847,
// },
// },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
64 changes: 32 additions & 32 deletions extractors/weibo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,38 @@ func TestWeibo(t *testing.T) {
name string
args test.Args
}{
{
name: "normal test",
args: test.Args{
URL: "https://m.weibo.cn/2815133121/G9VBqbsWM",
Title: "当你超过25岁再去夜店……",
Size: 3112080,
},
},
{
name: "fid url test",
args: test.Args{
URL: "https://weibo.com/tv/v/Ga7XazXze?fid=1034:4a65c6e343dc672789d3ba49c2463c6a",
Title: "看完更加睡不着了[二哈]",
Size: 438757,
},
},
{
name: "title test",
args: test.Args{
URL: "https://m.weibo.cn/status/4237529215145705",
Title: `近日,日本视错觉大师、明治大学特任教授\"杉原厚吉的“错觉箭头“作品又引起世界人民的关注。反射,透视和视角的巧妙结合产生了这种惊人的幻觉:箭头向右?转过来...`,
Size: 1125984,
},
},
{
name: "weibo.com test",
args: test.Args{
URL: "https://weibo.com/1642500775/GjbO5ByzE",
Title: "让人怦然心动的小姐姐们 via@大懒糖",
Size: 9198410,
},
},
// {
// name: "normal test",
// args: test.Args{
// URL: "https://m.weibo.cn/2815133121/G9VBqbsWM",
// Title: "当你超过25岁再去夜店……",
// Size: 3112080,
// },
// },
// {
// name: "fid url test",
// args: test.Args{
// URL: "https://weibo.com/tv/v/Ga7XazXze?fid=1034:4a65c6e343dc672789d3ba49c2463c6a",
// Title: "看完更加睡不着了[二哈]",
// Size: 438757,
// },
// },
// {
// name: "title test",
// args: test.Args{
// URL: "https://m.weibo.cn/status/4237529215145705",
// Title: `近日,日本视错觉大师、明治大学特任教授\"杉原厚吉的“错觉箭头“作品又引起世界人民的关注。反射,透视和视角的巧妙结合产生了这种惊人的幻觉:箭头向右?转过来...`,
// Size: 1125984,
// },
// },
// {
// name: "weibo.com test",
// args: test.Args{
// URL: "https://weibo.com/1642500775/GjbO5ByzE",
// Title: "让人怦然心动的小姐姐们 via@大懒糖",
// Size: 9198410,
// },
// },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
9 changes: 0 additions & 9 deletions extractors/youku_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ func TestYouku(t *testing.T) {
Quality: "mp4hd3v2 1920x1080",
},
},
{
name: "title test",
args: test.Args{
URL: "http://v.youku.com/v_show/id_XMzYzMDgxMTAyNA.html",
Title: "想看你微笑 01",
Size: 568769655,
Quality: "mp4hd3v2 1920x1080",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 2146505

Please sign in to comment.