mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-15 07:42:42 +00:00
[QQMusic] Implement the guid algorithm
This commit is contained in:
parent
5d98908b26
commit
a2043572aa
1 changed files with 12 additions and 4 deletions
|
@ -1,13 +1,12 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import random
|
||||||
|
import time
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import strip_jsonp
|
from ..utils import strip_jsonp
|
||||||
|
|
||||||
# guid is a random number generated in javascript, but seems a fixed number
|
|
||||||
# also works
|
|
||||||
guid = '1'
|
|
||||||
|
|
||||||
|
|
||||||
class QQMusicIE(InfoExtractor):
|
class QQMusicIE(InfoExtractor):
|
||||||
_VALID_URL = r'http://y.qq.com/#type=song&mid=(?P<id>[0-9A-Za-z]+)'
|
_VALID_URL = r'http://y.qq.com/#type=song&mid=(?P<id>[0-9A-Za-z]+)'
|
||||||
|
@ -23,6 +22,13 @@ class QQMusicIE(InfoExtractor):
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
# Reference: m_r_GetRUin() in top_player.js
|
||||||
|
# http://imgcache.gtimg.cn/music/portal_v3/y/top_player.js
|
||||||
|
@staticmethod
|
||||||
|
def m_r_get_ruin():
|
||||||
|
curMs = int(time.time() * 1000) % 1000
|
||||||
|
return int(round(random.random() * 2147483647) * curMs % 1E10)
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mid = self._match_id(url)
|
mid = self._match_id(url)
|
||||||
|
|
||||||
|
@ -41,6 +47,8 @@ class QQMusicIE(InfoExtractor):
|
||||||
singer = self._html_search_regex(
|
singer = self._html_search_regex(
|
||||||
r"singer:\s*'([^']+)", detail_info_page, 'singer')
|
r"singer:\s*'([^']+)", detail_info_page, 'singer')
|
||||||
|
|
||||||
|
guid = self.m_r_get_ruin()
|
||||||
|
|
||||||
vkey = self._download_json(
|
vkey = self._download_json(
|
||||||
'http://base.music.qq.com/fcgi-bin/fcg_musicexpress.fcg?json=3&guid=%s' % guid,
|
'http://base.music.qq.com/fcgi-bin/fcg_musicexpress.fcg?json=3&guid=%s' % guid,
|
||||||
mid, note='Retrieve vkey', errnote='Unable to get vkey',
|
mid, note='Retrieve vkey', errnote='Unable to get vkey',
|
||||||
|
|
Loading…
Reference in a new issue