Skip to content

Commit

Permalink
更新QQ音乐API(部分付费歌曲无法下载)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xHJK committed Aug 24, 2019
1 parent aeca4ca commit 43d4fe5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
50 changes: 32 additions & 18 deletions music_dl/addons/qq.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,42 @@ def download_cover(self):
def download(self):
# 计算vkey
guid = str(random.randrange(1000000000, 10000000000))
params = {"guid": guid, "format": "json", "json": 3}

params = {"guid": guid,
"loginUin": "3051522991",
"format": "json",
"platform": "yqq",
"cid": "205361747",
"uin": "3051522991",
"songmid": self.mid,
"needNewCode": 0}
rate_list = [
("A000", "ape", 800),
("F000", "flac", 800),
("M800", "mp3", 320),
("C400", "m4a", 128),
("M500", "mp3", 128),
]
QQApi.session.headers.update({"referer": "http://y.qq.com"})
res_data = QQApi.request(
"http://base.music.qq.com/fcgi-bin/fcg_musicexpress.fcg",
method="GET",
data=params,
)
vkey = res_data.get("key", "")

for prefix in ["M800", "M500", "C400"]:
url = (
"http://dl.stream.qqmusic.qq.com/%s%s.mp3?vkey=%s&guid=%s&fromtag=1"
% (prefix, self.mid, vkey, guid)
for rate in rate_list:
params["filename"] = "%s%s.%s" % (rate[0], self.mid, rate[1])
res_data = QQApi.request(
"https://c.y.qq.com/base/fcgi-bin/fcg_music_express_mobile3.fcg",
method="GET",
data=params,
)
self.song_url = url
if self.available:
self.rate = 320 if prefix == "M800" else 128
break
vkey = res_data.get("data", {}).get("items", [])[0].get("vkey", "")
if vkey:
url = (
"http://dl.stream.qqmusic.qq.com/%s?vkey=%s&guid=%s&uin=3051522991&fromtag=64"
% (params["filename"], vkey, guid)
)
self.song_url = url
if self.available:
self.ext = rate[1]
self.rate = rate[2]
break
super(QQSong, self).download()


def qq_search(keyword) -> list:
""" 搜索音乐 """
number = config.get("number") or 5
Expand Down
2 changes: 1 addition & 1 deletion music_dl/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def search(self, keyword, sources_list) -> list:
# "kugou": "kugou",
# "netease": "netease",
# "163": "netease",
# "qq": "qq",
"qq": "qq",
# "xiami": "xiami",
}
thread_pool = []
Expand Down

0 comments on commit 43d4fe5

Please sign in to comment.