[ie/youtube] Fix `uploader_id` extraction (#11818)
[yt-dlp.git] / yt_dlp / extractor / neteasemusic.py
blob900b8b2a30c8637cb1968c646afb0a06c091e19b
1 import hashlib
2 import itertools
3 import json
4 import random
5 import re
6 import time
8 from .common import InfoExtractor
9 from ..aes import aes_ecb_encrypt, pkcs7_padding
10 from ..utils import (
11 ExtractorError,
12 int_or_none,
13 join_nonempty,
14 str_or_none,
15 strftime_or_none,
16 traverse_obj,
17 unified_strdate,
18 url_or_none,
19 urljoin,
20 variadic,
24 class NetEaseMusicBaseIE(InfoExtractor):
25 # XXX: _extract_formats logic depends on the order of the levels in each tier
26 _LEVELS = (
27 'standard', # free tier; 标准; 128kbps mp3 or aac
28 'higher', # free tier; 192kbps mp3 or aac
29 'exhigh', # free tier; 极高 (HQ); 320kbps mp3 or aac
30 'lossless', # VIP tier; 无损 (SQ); 48kHz/16bit flac
31 'hires', # VIP tier; 高解析度无损 (Hi-Res); 192kHz/24bit flac
32 'jyeffect', # VIP tier; 高清臻音 (Spatial Audio); 96kHz/24bit flac
33 'jymaster', # SVIP tier; 超清母带 (Master); 192kHz/24bit flac
34 'sky', # SVIP tier; 沉浸环绕声 (Surround Audio); flac
36 _API_BASE = 'http://music.163.com/api/'
37 _GEO_BYPASS = False
39 def _create_eapi_cipher(self, api_path, query_body, cookies):
40 request_text = json.dumps({**query_body, 'header': cookies}, separators=(',', ':'))
42 message = f'nobody{api_path}use{request_text}md5forencrypt'.encode('latin1')
43 msg_digest = hashlib.md5(message).hexdigest()
45 data = pkcs7_padding(list(str.encode(
46 f'{api_path}-36cd479b6b5-{request_text}-36cd479b6b5-{msg_digest}')))
47 encrypted = bytes(aes_ecb_encrypt(data, list(b'e82ckenh8dichen8')))
48 return f'params={encrypted.hex().upper()}'.encode()
50 def _download_eapi_json(self, path, video_id, query_body, headers={}, **kwargs):
51 cookies = {
52 'osver': 'undefined',
53 'deviceId': 'undefined',
54 'appver': '8.0.0',
55 'versioncode': '140',
56 'mobilename': 'undefined',
57 'buildver': '1623435496',
58 'resolution': '1920x1080',
59 '__csrf': '',
60 'os': 'pc',
61 'channel': 'undefined',
62 'requestId': f'{int(time.time() * 1000)}_{random.randint(0, 1000):04}',
63 **traverse_obj(self._get_cookies(self._API_BASE), {
64 'MUSIC_U': ('MUSIC_U', {lambda i: i.value}),
65 }),
67 return self._download_json(
68 urljoin('https://interface3.music.163.com/', f'/eapi{path}'), video_id,
69 data=self._create_eapi_cipher(f'/api{path}', query_body, cookies), headers={
70 'Referer': 'https://music.163.com',
71 'Cookie': '; '.join([f'{k}={v}' for k, v in cookies.items()]),
72 **headers,
73 }, **kwargs)
75 def _call_player_api(self, song_id, level):
76 return self._download_eapi_json(
77 '/song/enhance/player/url/v1', song_id,
78 {'ids': f'[{song_id}]', 'level': level, 'encodeType': 'flac'},
79 note=f'Downloading song URL info: level {level}')
81 def _extract_formats(self, info):
82 formats = []
83 song_id = info['id']
84 for level in self._LEVELS:
85 song = traverse_obj(
86 self._call_player_api(song_id, level), ('data', lambda _, v: url_or_none(v['url']), any))
87 if not song:
88 break # Media is not available due to removal or geo-restriction
89 actual_level = song.get('level')
90 if actual_level and actual_level != level:
91 if level in ('lossless', 'jymaster'):
92 break # We've already extracted the highest level of the user's account tier
93 continue
94 formats.append({
95 'url': song['url'],
96 'format_id': level,
97 'vcodec': 'none',
98 **traverse_obj(song, {
99 'ext': ('type', {str}),
100 'abr': ('br', {int_or_none(scale=1000)}),
101 'filesize': ('size', {int_or_none}),
104 if not actual_level:
105 break # Only 1 level is available if API does not return a value (netease:program)
106 if not formats:
107 self.raise_geo_restricted(
108 'No media links found; possibly due to geo restriction', countries=['CN'])
109 return formats
111 def _query_api(self, endpoint, video_id, note):
112 result = self._download_json(
113 f'{self._API_BASE}{endpoint}', video_id, note, headers={'Referer': self._API_BASE})
114 code = traverse_obj(result, ('code', {int}))
115 message = traverse_obj(result, ('message', {str})) or ''
116 if code == -462:
117 self.raise_login_required(f'Login required to download: {message}')
118 elif code != 200:
119 raise ExtractorError(f'Failed to get meta info: {code} {message}')
120 return result
122 def _get_entries(self, songs_data, entry_keys=None, id_key='id', name_key='name'):
123 for song in traverse_obj(songs_data, (
124 *variadic(entry_keys, (str, bytes, dict, set)),
125 lambda _, v: int_or_none(v[id_key]) is not None)):
126 song_id = str(song[id_key])
127 yield self.url_result(
128 f'http://music.163.com/#/song?id={song_id}', NetEaseMusicIE,
129 song_id, traverse_obj(song, (name_key, {str})))
132 class NetEaseMusicIE(NetEaseMusicBaseIE):
133 IE_NAME = 'netease:song'
134 IE_DESC = '网易云音乐'
135 _VALID_URL = r'https?://(?:y\.)?music\.163\.com/(?:[#m]/)?song\?.*?\bid=(?P<id>[0-9]+)'
136 _TESTS = [{
137 'url': 'https://music.163.com/#/song?id=550136151',
138 'info_dict': {
139 'id': '550136151',
140 'ext': 'mp3',
141 'title': 'It\'s Ok (Live)',
142 'creators': 'count:10',
143 'timestamp': 1522944000,
144 'upload_date': '20180405',
145 'description': 'md5:9fd07059c2ccee3950dc8363429a3135',
146 'duration': 197,
147 'thumbnail': r're:^http.*\.jpg',
148 'album': '偶像练习生 表演曲目合集',
149 'average_rating': int,
150 'album_artists': ['偶像练习生'],
152 }, {
153 'url': 'http://music.163.com/song?id=17241424',
154 'info_dict': {
155 'id': '17241424',
156 'ext': 'mp3',
157 'title': 'Opus 28',
158 'upload_date': '20080211',
159 'timestamp': 1202745600,
160 'duration': 263,
161 'thumbnail': r're:^http.*\.jpg',
162 'album': 'Piano Solos Vol. 2',
163 'album_artist': 'Dustin O\'Halloran',
164 'average_rating': int,
165 'description': '[00:05.00]纯音乐,请欣赏\n',
166 'album_artists': ['Dustin O\'Halloran'],
167 'creators': ['Dustin O\'Halloran'],
168 'subtitles': {'lyrics': [{'ext': 'lrc'}]},
170 }, {
171 'url': 'https://y.music.163.com/m/song?app_version=8.8.45&id=95670&uct2=sKnvS4+0YStsWkqsPhFijw%3D%3D&dlt=0846',
172 'md5': 'b896be78d8d34bd7bb665b26710913ff',
173 'info_dict': {
174 'id': '95670',
175 'ext': 'mp3',
176 'title': '国际歌',
177 'upload_date': '19911130',
178 'timestamp': 691516800,
179 'description': 'md5:1ba2f911a2b0aa398479f595224f2141',
180 'subtitles': {'lyrics': [{'ext': 'lrc'}]},
181 'duration': 268,
182 'alt_title': '伴唱:现代人乐队 合唱:总政歌舞团',
183 'thumbnail': r're:^http.*\.jpg',
184 'average_rating': int,
185 'album': '红色摇滚',
186 'album_artist': '侯牧人',
187 'creators': ['马备'],
188 'album_artists': ['侯牧人'],
190 }, {
191 'url': 'http://music.163.com/#/song?id=32102397',
192 'md5': '3e909614ce09b1ccef4a3eb205441190',
193 'info_dict': {
194 'id': '32102397',
195 'ext': 'mp3',
196 'title': 'Bad Blood',
197 'creators': ['Taylor Swift', 'Kendrick Lamar'],
198 'upload_date': '20150516',
199 'timestamp': 1431792000,
200 'description': 'md5:21535156efb73d6d1c355f95616e285a',
201 'subtitles': {'lyrics': [{'ext': 'lrc'}]},
202 'duration': 199,
203 'thumbnail': r're:^http.*\.jpg',
204 'album': 'Bad Blood',
205 'average_rating': int,
206 'album_artist': 'Taylor Swift',
208 'skip': 'Blocked outside Mainland China',
209 }, {
210 'note': 'Has translated name.',
211 'url': 'http://music.163.com/#/song?id=22735043',
212 'info_dict': {
213 'id': '22735043',
214 'ext': 'mp3',
215 'title': '소원을 말해봐 (Genie)',
216 'creators': ['少女时代'],
217 'upload_date': '20100127',
218 'timestamp': 1264608000,
219 'description': 'md5:03d1ffebec3139aa4bafe302369269c5',
220 'subtitles': {'lyrics': [{'ext': 'lrc'}]},
221 'duration': 229,
222 'alt_title': '说出愿望吧(Genie)',
223 'thumbnail': r're:^http.*\.jpg',
224 'average_rating': int,
225 'album': 'Oh!',
226 'album_artist': '少女时代',
228 'skip': 'Blocked outside Mainland China',
231 def _process_lyrics(self, lyrics_info):
232 original = traverse_obj(lyrics_info, ('lrc', 'lyric', {str}))
233 translated = traverse_obj(lyrics_info, ('tlyric', 'lyric', {str}))
235 if not original or original == '[99:00.00]纯音乐,请欣赏\n':
236 return None
238 if not translated:
239 return {
240 'lyrics': [{'data': original, 'ext': 'lrc'}],
243 lyrics_expr = r'(\[[0-9]{2}:[0-9]{2}\.[0-9]{2,}\])([^\n]+)'
244 original_ts_texts = re.findall(lyrics_expr, original)
245 translation_ts_dict = dict(re.findall(lyrics_expr, translated))
247 merged = '\n'.join(
248 join_nonempty(f'{timestamp}{text}', translation_ts_dict.get(timestamp, ''), delim=' / ')
249 for timestamp, text in original_ts_texts)
251 return {
252 'lyrics_merged': [{'data': merged, 'ext': 'lrc'}],
253 'lyrics': [{'data': original, 'ext': 'lrc'}],
254 'lyrics_translated': [{'data': translated, 'ext': 'lrc'}],
257 def _real_extract(self, url):
258 song_id = self._match_id(url)
260 info = self._query_api(
261 f'song/detail?id={song_id}&ids=%5B{song_id}%5D', song_id, 'Downloading song info')['songs'][0]
263 formats = self._extract_formats(info)
265 lyrics = self._process_lyrics(self._query_api(
266 f'song/lyric?id={song_id}&lv=-1&tv=-1', song_id, 'Downloading lyrics data'))
267 lyric_data = {
268 'description': traverse_obj(lyrics, (('lyrics_merged', 'lyrics'), 0, 'data'), get_all=False),
269 'subtitles': lyrics,
270 } if lyrics else {}
272 return {
273 'id': song_id,
274 'formats': formats,
275 'alt_title': '/'.join(traverse_obj(info, (('transNames', 'alias'), ...))) or None,
276 'creators': traverse_obj(info, ('artists', ..., 'name')) or None,
277 'album_artists': traverse_obj(info, ('album', 'artists', ..., 'name')) or None,
278 **lyric_data,
279 **traverse_obj(info, {
280 'title': ('name', {str}),
281 'timestamp': ('album', 'publishTime', {int_or_none(scale=1000)}),
282 'thumbnail': ('album', 'picUrl', {url_or_none}),
283 'duration': ('duration', {int_or_none(scale=1000)}),
284 'album': ('album', 'name', {str}),
285 'average_rating': ('score', {int_or_none}),
290 class NetEaseMusicAlbumIE(NetEaseMusicBaseIE):
291 IE_NAME = 'netease:album'
292 IE_DESC = '网易云音乐 - 专辑'
293 _VALID_URL = r'https?://music\.163\.com/(?:#/)?album\?id=(?P<id>[0-9]+)'
294 _TESTS = [{
295 'url': 'https://music.163.com/#/album?id=133153666',
296 'info_dict': {
297 'id': '133153666',
298 'title': '桃几的翻唱',
299 'upload_date': '20210913',
300 'description': '桃几2021年翻唱合集',
301 'thumbnail': r're:^http.*\.jpg',
303 'playlist_mincount': 12,
304 }, {
305 'url': 'http://music.163.com/#/album?id=220780',
306 'info_dict': {
307 'id': '220780',
308 'title': 'B\'Day',
309 'upload_date': '20060904',
310 'description': 'md5:71a74e1d8f392d88cf1bbe48879ad0b0',
311 'thumbnail': r're:^http.*\.jpg',
313 'playlist_count': 23,
316 def _real_extract(self, url):
317 album_id = self._match_id(url)
318 webpage = self._download_webpage(f'https://music.163.com/album?id={album_id}', album_id)
320 songs = self._search_json(
321 r'<textarea[^>]+\bid="song-list-pre-data"[^>]*>', webpage, 'metainfo', album_id,
322 end_pattern=r'</textarea>', contains_pattern=r'\[(?s:.+)\]')
323 metainfo = {
324 'title': self._og_search_property('title', webpage, 'title', fatal=False),
325 'description': self._html_search_regex(
326 (rf'<div[^>]+\bid="album-desc-{suffix}"[^>]*>(.*?)</div>' for suffix in ('more', 'dot')),
327 webpage, 'description', flags=re.S, fatal=False),
328 'thumbnail': self._og_search_property('image', webpage, 'thumbnail', fatal=False),
329 'upload_date': unified_strdate(self._html_search_meta('music:release_date', webpage, 'date', fatal=False)),
331 return self.playlist_result(self._get_entries(songs), album_id, **metainfo)
334 class NetEaseMusicSingerIE(NetEaseMusicBaseIE):
335 IE_NAME = 'netease:singer'
336 IE_DESC = '网易云音乐 - 歌手'
337 _VALID_URL = r'https?://music\.163\.com/(?:#/)?artist\?id=(?P<id>[0-9]+)'
338 _TESTS = [{
339 'note': 'Singer has aliases.',
340 'url': 'http://music.163.com/#/artist?id=10559',
341 'info_dict': {
342 'id': '10559',
343 'title': '张惠妹 - aMEI;阿妹;阿密特',
345 'playlist_count': 50,
346 }, {
347 'note': 'Singer has translated name.',
348 'url': 'http://music.163.com/#/artist?id=124098',
349 'info_dict': {
350 'id': '124098',
351 'title': '李昇基 - 이승기',
353 'playlist_count': 50,
354 }, {
355 'note': 'Singer with both translated and alias',
356 'url': 'https://music.163.com/#/artist?id=159692',
357 'info_dict': {
358 'id': '159692',
359 'title': '初音ミク - 初音未来;Hatsune Miku',
361 'playlist_count': 50,
364 def _real_extract(self, url):
365 singer_id = self._match_id(url)
367 info = self._query_api(
368 f'artist/{singer_id}?id={singer_id}', singer_id, note='Downloading singer data')
370 name = join_nonempty(
371 traverse_obj(info, ('artist', 'name', {str})),
372 join_nonempty(*traverse_obj(info, ('artist', ('trans', ('alias', ...)), {str})), delim=';'),
373 delim=' - ')
375 return self.playlist_result(self._get_entries(info, 'hotSongs'), singer_id, name)
378 class NetEaseMusicListIE(NetEaseMusicBaseIE):
379 IE_NAME = 'netease:playlist'
380 IE_DESC = '网易云音乐 - 歌单'
381 _VALID_URL = r'https?://music\.163\.com/(?:#/)?(?:playlist|discover/toplist)\?id=(?P<id>[0-9]+)'
382 _TESTS = [{
383 'url': 'http://music.163.com/#/playlist?id=79177352',
384 'info_dict': {
385 'id': '79177352',
386 'title': 'Billboard 2007 Top 100',
387 'description': 'md5:12fd0819cab2965b9583ace0f8b7b022',
388 'tags': ['欧美'],
389 'uploader': '浑然破灭',
390 'uploader_id': '67549805',
391 'timestamp': int,
392 'upload_date': r're:\d{8}',
394 'playlist_mincount': 95,
395 }, {
396 'note': 'Toplist/Charts sample',
397 'url': 'https://music.163.com/#/discover/toplist?id=60198',
398 'info_dict': {
399 'id': '60198',
400 'title': 're:美国Billboard榜 [0-9]{4}-[0-9]{2}-[0-9]{2}',
401 'description': '美国Billboard排行榜',
402 'tags': ['流行', '欧美', '榜单'],
403 'uploader': 'Billboard公告牌',
404 'uploader_id': '48171',
405 'timestamp': int,
406 'upload_date': r're:\d{8}',
408 'playlist_count': 100,
409 }, {
410 'note': 'Toplist/Charts sample',
411 'url': 'http://music.163.com/#/discover/toplist?id=3733003',
412 'info_dict': {
413 'id': '3733003',
414 'title': 're:韩国Melon排行榜周榜(?: [0-9]{4}-[0-9]{2}-[0-9]{2})?',
415 'description': 'md5:73ec782a612711cadc7872d9c1e134fc',
416 'upload_date': '20200109',
417 'uploader_id': '2937386',
418 'tags': ['韩语', '榜单'],
419 'uploader': 'Melon榜单',
420 'timestamp': 1578569373,
422 'playlist_count': 50,
425 def _real_extract(self, url):
426 list_id = self._match_id(url)
428 info = self._download_eapi_json(
429 '/v3/playlist/detail', list_id,
430 {'id': list_id, 't': '-1', 'n': '500', 's': '0'},
431 note='Downloading playlist info')
433 metainfo = traverse_obj(info, ('playlist', {
434 'title': ('name', {str}),
435 'description': ('description', {str}),
436 'tags': ('tags', ..., {str}),
437 'uploader': ('creator', 'nickname', {str}),
438 'uploader_id': ('creator', 'userId', {str_or_none}),
439 'timestamp': ('updateTime', {int_or_none(scale=1000)}),
441 if traverse_obj(info, ('playlist', 'specialType')) == 10:
442 metainfo['title'] = f'{metainfo.get("title")} {strftime_or_none(metainfo.get("timestamp"), "%Y-%m-%d")}'
444 return self.playlist_result(self._get_entries(info, ('playlist', 'tracks')), list_id, **metainfo)
447 class NetEaseMusicMvIE(NetEaseMusicBaseIE):
448 IE_NAME = 'netease:mv'
449 IE_DESC = '网易云音乐 - MV'
450 _VALID_URL = r'https?://music\.163\.com/(?:#/)?mv\?id=(?P<id>[0-9]+)'
451 _TESTS = [{
452 'url': 'https://music.163.com/#/mv?id=10958064',
453 'info_dict': {
454 'id': '10958064',
455 'ext': 'mp4',
456 'title': '交换余生',
457 'description': 'md5:e845872cff28820642a2b02eda428fea',
458 'creators': ['林俊杰'],
459 'upload_date': '20200916',
460 'thumbnail': r're:http.*\.jpg',
461 'duration': 364,
462 'view_count': int,
463 'like_count': int,
464 'comment_count': int,
466 }, {
467 'url': 'http://music.163.com/#/mv?id=415350',
468 'info_dict': {
469 'id': '415350',
470 'ext': 'mp4',
471 'title': '이럴거면 그러지말지',
472 'description': '白雅言自作曲唱甜蜜爱情',
473 'creators': ['白娥娟'],
474 'upload_date': '20150520',
475 'thumbnail': r're:http.*\.jpg',
476 'duration': 216,
477 'view_count': int,
478 'like_count': int,
479 'comment_count': int,
481 'skip': 'Blocked outside Mainland China',
482 }, {
483 'note': 'This MV has multiple creators.',
484 'url': 'https://music.163.com/#/mv?id=22593543',
485 'info_dict': {
486 'id': '22593543',
487 'ext': 'mp4',
488 'title': '老北京杀器',
489 'creators': ['秃子2z', '辉子', 'Saber梁维嘉'],
490 'duration': 206,
491 'upload_date': '20240618',
492 'like_count': int,
493 'comment_count': int,
494 'thumbnail': r're:http.*\.jpg',
495 'view_count': int,
499 def _real_extract(self, url):
500 mv_id = self._match_id(url)
502 info = self._query_api(
503 f'mv/detail?id={mv_id}&type=mp4', mv_id, 'Downloading mv info')['data']
505 formats = [
506 {'url': mv_url, 'ext': 'mp4', 'format_id': f'{brs}p', 'height': int_or_none(brs)}
507 for brs, mv_url in info['brs'].items()
510 return {
511 'id': mv_id,
512 'formats': formats,
513 'creators': traverse_obj(info, ('artists', ..., 'name')) or [info.get('artistName')],
514 **traverse_obj(info, {
515 'title': ('name', {str}),
516 'description': (('desc', 'briefDesc'), {str}, filter),
517 'upload_date': ('publishTime', {unified_strdate}),
518 'thumbnail': ('cover', {url_or_none}),
519 'duration': ('duration', {int_or_none(scale=1000)}),
520 'view_count': ('playCount', {int_or_none}),
521 'like_count': ('likeCount', {int_or_none}),
522 'comment_count': ('commentCount', {int_or_none}),
523 }, get_all=False),
527 class NetEaseMusicProgramIE(NetEaseMusicBaseIE):
528 IE_NAME = 'netease:program'
529 IE_DESC = '网易云音乐 - 电台节目'
530 _VALID_URL = r'https?://music\.163\.com/(?:#/)?program\?id=(?P<id>[0-9]+)'
531 _TESTS = [{
532 'url': 'http://music.163.com/#/program?id=10109055',
533 'info_dict': {
534 'id': '32593346',
535 'ext': 'mp3',
536 'title': '不丹足球背后的故事',
537 'description': '喜马拉雅人的足球梦 ...',
538 'creators': ['大话西藏'],
539 'timestamp': 1434179287,
540 'upload_date': '20150613',
541 'thumbnail': r're:http.*\.jpg',
542 'duration': 900,
544 }, {
545 'note': 'This program has accompanying songs.',
546 'url': 'http://music.163.com/#/program?id=10141022',
547 'info_dict': {
548 'id': '10141022',
549 'title': '滚滚电台的有声节目',
550 'description': 'md5:8d594db46cc3e6509107ede70a4aaa3b',
551 'creators': ['滚滚电台ORZ'],
552 'timestamp': 1434450733,
553 'upload_date': '20150616',
554 'thumbnail': r're:http.*\.jpg',
556 'playlist_count': 4,
557 }, {
558 'note': 'This program has accompanying songs.',
559 'url': 'http://music.163.com/#/program?id=10141022',
560 'info_dict': {
561 'id': '32647209',
562 'ext': 'mp3',
563 'title': '滚滚电台的有声节目',
564 'description': 'md5:8d594db46cc3e6509107ede70a4aaa3b',
565 'creators': ['滚滚电台ORZ'],
566 'timestamp': 1434450733,
567 'upload_date': '20150616',
568 'thumbnail': r're:http.*\.jpg',
569 'duration': 1104,
571 'params': {
572 'noplaylist': True,
576 def _real_extract(self, url):
577 program_id = self._match_id(url)
579 info = self._query_api(
580 f'dj/program/detail?id={program_id}', program_id, note='Downloading program info')['program']
582 metainfo = traverse_obj(info, {
583 'title': ('name', {str}),
584 'description': ('description', {str}),
585 'creator': ('dj', 'brand', {str}),
586 'thumbnail': ('coverUrl', {url_or_none}),
587 'timestamp': ('createTime', {int_or_none(scale=1000)}),
590 if not self._yes_playlist(
591 info['songs'] and program_id, info['mainSong']['id'], playlist_label='program', video_label='song'):
592 formats = self._extract_formats(info['mainSong'])
594 return {
595 'id': str(info['mainSong']['id']),
596 'formats': formats,
597 'duration': traverse_obj(info, ('mainSong', 'duration', {int_or_none(scale=1000)})),
598 **metainfo,
601 songs = traverse_obj(info, (('mainSong', ('songs', ...)),))
602 return self.playlist_result(self._get_entries(songs), program_id, **metainfo)
605 class NetEaseMusicDjRadioIE(NetEaseMusicBaseIE):
606 IE_NAME = 'netease:djradio'
607 IE_DESC = '网易云音乐 - 电台'
608 _VALID_URL = r'https?://music\.163\.com/(?:#/)?djradio\?id=(?P<id>[0-9]+)'
609 _TEST = {
610 'url': 'http://music.163.com/#/djradio?id=42',
611 'info_dict': {
612 'id': '42',
613 'title': '声音蔓延',
614 'description': 'md5:c7381ebd7989f9f367668a5aee7d5f08',
616 'playlist_mincount': 40,
618 _PAGE_SIZE = 1000
620 def _real_extract(self, url):
621 dj_id = self._match_id(url)
623 metainfo = {}
624 entries = []
625 for offset in itertools.count(start=0, step=self._PAGE_SIZE):
626 info = self._query_api(
627 f'dj/program/byradio?asc=false&limit={self._PAGE_SIZE}&radioId={dj_id}&offset={offset}',
628 dj_id, note=f'Downloading dj programs - {offset}')
630 entries.extend(self.url_result(
631 f'http://music.163.com/#/program?id={program["id"]}', NetEaseMusicProgramIE,
632 program['id'], program.get('name')) for program in info['programs'])
633 if not metainfo:
634 metainfo = traverse_obj(info, ('programs', 0, 'radio', {
635 'title': ('name', {str}),
636 'description': ('desc', {str}),
639 if not info['more']:
640 break
642 return self.playlist_result(entries, dj_id, **metainfo)