A feature-rich command-line audio/video downloader
[funk:channel] Improve extraction (closes #16285)
Sergey M․c84eae4f66be
diff --git a/youtube_dl/extractor/funk.py b/youtube_dl/extractor/funk.pyindex faea6576fe..0ff058619b 100644--- a/youtube_dl/extractor/funk.py+++ b/youtube_dl/extractor/funk.py@@ -5,7 +5,10 @@ import refrom .common import InfoExtractorfrom .nexx import NexxIE-from ..utils import int_or_none+from ..utils import (+ int_or_none,+ try_get,+)class FunkBaseIE(InfoExtractor):@@ -77,6 +80,20 @@ class FunkChannelIE(FunkBaseIE):'params': {'skip_download': True,},+ }, {+ # only available via byIdList API+ 'url': 'https://www.funk.net/channel/informr/martin-sonneborn-erklaert-die-eu',+ 'info_dict': {+ 'id': '205067',+ 'ext': 'mp4',+ 'title': 'Martin Sonneborn erklärt die EU',+ 'description': 'md5:050f74626e4ed87edf4626d2024210c0',+ 'timestamp': 1494424042,+ 'upload_date': '20170510',+ },+ 'params': {+ 'skip_download': True,+ },}, {'url': 'https://www.funk.net/channel/59d5149841dca100012511e3/mein-erster-job-lovemilla-folge-1/lovemilla/','only_matching': True,@@ -87,16 +104,28 @@ class FunkChannelIE(FunkBaseIE):channel_id = mobj.group('id')alias = mobj.group('alias')- results = self._download_json(- 'https://www.funk.net/api/v3.0/content/videos/filter', channel_id,- headers={- 'authorization': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnROYW1lIjoiY3VyYXRpb24tdG9vbCIsInNjb3BlIjoic3RhdGljLWNvbnRlbnQtYXBpLGN1cmF0aW9uLWFwaSxzZWFyY2gtYXBpIn0.q4Y2xZG8PFHai24-4Pjx2gym9RmJejtmK6lMXP5wAgc',- 'Referer': url,- }, query={- 'channelId': channel_id,- 'size': 100,- })['result']+ headers = {+ 'authorization': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnROYW1lIjoiY3VyYXRpb24tdG9vbCIsInNjb3BlIjoic3RhdGljLWNvbnRlbnQtYXBpLGN1cmF0aW9uLWFwaSxzZWFyY2gtYXBpIn0.q4Y2xZG8PFHai24-4Pjx2gym9RmJejtmK6lMXP5wAgc',+ 'Referer': url,+ }- video = next(r for r in results if r.get('alias') == alias)+ video = None++ by_id_list = self._download_json(+ 'https://www.funk.net/api/v3.0/content/videos/byIdList', channel_id,+ headers=headers, query={+ 'ids': alias,+ }, fatal=False)+ if by_id_list:+ video = try_get(by_id_list, lambda x: x['result'][0], dict)++ if not video:+ results = self._download_json(+ 'https://www.funk.net/api/v3.0/content/videos/filter', channel_id,+ headers=headers, query={+ 'channelId': channel_id,+ 'size': 100,+ })['result']+ video = next(r for r in results if r.get('alias') == alias)return self._make_url_result(video)