From 05209c296efbb22d985de868fb24c06c453ff8fe Mon Sep 17 00:00:00 2001 From: iawia002 Date: Sat, 24 Nov 2018 19:55:12 +0800 Subject: [PATCH] extractors/netease: update URL matching rules --- extractors/netease/netease.go | 2 +- extractors/netease/netease_test.go | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/extractors/netease/netease.go b/extractors/netease/netease.go index 08b8c9eed..5fc87491f 100644 --- a/extractors/netease/netease.go +++ b/extractors/netease/netease.go @@ -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") } diff --git a/extractors/netease/netease_test.go b/extractors/netease/netease_test.go index 503daaaa6..b398b2b4a 100644 --- a/extractors/netease/netease_test.go +++ b/extractors/netease/netease_test.go @@ -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) {