Skip to content

Commit

Permalink
Merge pull request #331 from iawia002/netease
Browse files Browse the repository at this point in the history
extractors/netease: update URL matching rules
  • Loading branch information
Xinzhao Xu authored Nov 24, 2018
2 parents 53a0217 + 05209c2 commit 0c4da00
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion extractors/netease/netease.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// Download main download function
func Download(url string) ([]downloader.Data, error) {
url = strings.Replace(url, "/#/", "/", 1)
vid := utils.MatchOneOf(url, `https?://music.163.com/mv\?id=(\d+)`)
vid := utils.MatchOneOf(url, `/(mv|video)\?id=(\w+)`)
if vid == nil {
return downloader.EmptyList, errors.New("invalid url for netease music")
}
Expand Down
18 changes: 17 additions & 1 deletion extractors/netease/netease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,29 @@ func TestDownload(t *testing.T) {
args test.Args
}{
{
name: "normal test",
name: "mv test 1",
args: test.Args{
URL: "https://music.163.com/#/mv?id=5547010",
Title: "There For You - Troye Sivan - 高清MV - 网易云音乐",
Size: 24249078,
},
},
{
name: "video test 1",
args: test.Args{
URL: "https://music.163.com/#/video?id=C8C9D11629798595BD28451DE3AC9FF4",
Title: "#金曜日の新垣结衣 总集編〈全9編〉 - 视频 - 网易云音乐",
Size: 37408123,
},
},
{
name: "video test 2",
args: test.Args{
URL: "https://music.163.com/m/video?id=6309CF62EF5D44FED5974536604944CF&userid=567080617",
Title: "当皮卡丘失去了小智就失去了全世界 - 视频 - 网易云音乐",
Size: 28547736,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 0c4da00

Please sign in to comment.