mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-29 19:47:54 +01:00
[qqmusic]support QQMusicSingerIE
This commit is contained in:
parent
5d1bd3b907
commit
5c037c0d1f
@ -156,16 +156,27 @@ class QQPlaylistBaseIE(InfoExtractor):
|
|||||||
def qq_static_url(category, mid):
|
def qq_static_url(category, mid):
|
||||||
return 'http://y.qq.com/y/static/%s/%s/%s/%s.html' % (category, mid[-2], mid[-1], mid)
|
return 'http://y.qq.com/y/static/%s/%s/%s/%s.html' % (category, mid[-2], mid[-1], mid)
|
||||||
|
|
||||||
@classmethod
|
def get_singer_all_songs(self, singmid, num):
|
||||||
def get_entries_from_page(cls, page):
|
return self._download_webpage(
|
||||||
|
r'https://c.y.qq.com/v8/fcg-bin/fcg_v8_singer_track_cp.fcg?format=json&inCharset=utf8&outCharset=utf-8&platform=yqq&needNewCode=0&singermid=%s&order=listen&begin=0&num=%s&songstatus=1' %
|
||||||
|
(singmid, num), singmid)
|
||||||
|
|
||||||
|
def get_entries_from_page(self, singmid):
|
||||||
entries = []
|
entries = []
|
||||||
|
|
||||||
for item in re.findall(r'class="data"[^<>]*>([^<>]+)</', page):
|
default_num = 1
|
||||||
song_mid = unescapeHTML(item).split('|')[-5]
|
json_text = self.get_singer_all_songs(singmid, default_num)
|
||||||
entries.append(cls.url_result(
|
json_obj = self._parse_json(json_text, singmid)
|
||||||
# https://y.qq.com/n/yqq/song/004Dbsoo1yCbNZ.html
|
|
||||||
'https://y.qq.com/n/yqq/song/' + song_mid + ".html", 'QQMusic',
|
if json_obj['code'] == 0:
|
||||||
song_mid))
|
total = json_obj['data']['total']
|
||||||
|
json_text = self.get_singer_all_songs(singmid, total)
|
||||||
|
json_obj = self._parse_json(json_text, singmid)
|
||||||
|
|
||||||
|
for item in json_obj['data']['list']:
|
||||||
|
if not (item['musicData'].get('songmid') is None):
|
||||||
|
songmid = item['musicData']['songmid']
|
||||||
|
entries.append(self.url_result(r'https://y.qq.com/n/yqq/song/%s.html' % songmid, 'QQMusic', songmid))
|
||||||
|
|
||||||
return entries
|
return entries
|
||||||
|
|
||||||
@ -187,26 +198,16 @@ class QQMusicSingerIE(QQPlaylistBaseIE):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mid = self._match_id(url)
|
mid = self._match_id(url)
|
||||||
|
|
||||||
singer_page = self._download_webpage(
|
entries = self.get_entries_from_page(mid)
|
||||||
self.qq_static_url('singer', mid), mid, 'Download singer page')
|
singer_page = self._download_webpage(url, mid, 'Download singer page')
|
||||||
|
singer_name = self._html_search_regex(r"singername : '(.*?)'", singer_page, 'singer name', default=None)
|
||||||
entries = self.get_entries_from_page(singer_page)
|
|
||||||
|
|
||||||
singer_name = self._html_search_regex(
|
|
||||||
r"singername\s*:\s*'([^']+)'", singer_page, 'singer name',
|
|
||||||
default=None)
|
|
||||||
|
|
||||||
singer_id = self._html_search_regex(
|
|
||||||
r"singerid\s*:\s*'([0-9]+)'", singer_page, 'singer id',
|
|
||||||
default=None)
|
|
||||||
|
|
||||||
singer_desc = None
|
singer_desc = None
|
||||||
|
|
||||||
if singer_id:
|
if mid:
|
||||||
req = sanitized_Request(
|
req = sanitized_Request(
|
||||||
'http://s.plcloud.music.qq.com/fcgi-bin/fcg_get_singer_desc.fcg?utf8=1&outCharset=utf-8&format=xml&singerid=%s' % singer_id)
|
'http://s.plcloud.music.qq.com/fcgi-bin/fcg_get_singer_desc.fcg?utf8=1&outCharset=utf-8&format=xml&singermid=%s' % mid)
|
||||||
req.add_header(
|
req.add_header(
|
||||||
'Referer', 'http://s.plcloud.music.qq.com/xhr_proxy_utf8.html')
|
'Referer', 'https://y.qq.com/n/yqq/singer/')
|
||||||
singer_desc_page = self._download_xml(
|
singer_desc_page = self._download_xml(
|
||||||
req, mid, 'Donwload singer description XML')
|
req, mid, 'Donwload singer description XML')
|
||||||
|
|
||||||
@ -304,7 +305,8 @@ class QQMusicToplistIE(QQPlaylistBaseIE):
|
|||||||
|
|
||||||
entries = [
|
entries = [
|
||||||
self.url_result(
|
self.url_result(
|
||||||
'https://y.qq.com/n/yqq/song/' + song['data']['songmid'] + ".html", 'QQMusic', song['data']['songmid']
|
'https://y.qq.com/n/yqq/song/' + song['data']['songmid'] + ".html", 'QQMusic',
|
||||||
|
song['data']['songmid']
|
||||||
) for song in toplist_json['songlist']
|
) for song in toplist_json['songlist']
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user