Skip to content

Commit

Permalink
extractors/weibo: 🔧 weibo.com url, fix #156 [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
iawia002 committed Jun 1, 2018
1 parent b4d4bb0 commit 201c5b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 6 additions & 2 deletions extractors/weibo.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ import (
// Weibo download function
func Weibo(url string) downloader.VideoData {
if !strings.Contains(url, "m.weibo.cn") {
statusID := utils.MatchOneOf(url, `weibo\.com/tv/v/([^\?/]+)`)[1]
url = "https://m.weibo.cn/status/" + statusID
statusID := utils.MatchOneOf(url, `weibo\.com/tv/v/([^\?/]+)`)
if statusID != nil {
url = "https://m.weibo.cn/status/" + statusID[1]
} else {
url = strings.Replace(url, "weibo.com", "m.weibo.cn", 1)
}
}
html := request.Get(url, url, nil)
title := utils.MatchOneOf(html, `"content2": "(.+?)",`)[1]
Expand Down
10 changes: 9 additions & 1 deletion extractors/weibo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,18 @@ func TestWeibo(t *testing.T) {
name: "title test",
args: test.Args{
URL: "https://m.weibo.cn/status/4237529215145705",
Title: `近日,日本视错觉大师、明治大学特任教授\"杉原厚吉的“错觉箭头“作品又引起世界人民的关注。反射,透视和视角的巧妙结合产生了这种惊人的幻觉:箭头向右?转过来还是向右?\n\n引用杉原教授的经典描述:“我们看外面的世界的方式——也就是我们的知觉——都是由大脑机制间接产生的,所以所有知觉在某`,
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

0 comments on commit 201c5b6

Please sign in to comment.