2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from .nexx import NexxIE
8 from ..compat import compat_str
15 class FunkBaseIE(InfoExtractor):
18 'Accept-Language': 'en-US,en;q=0.9,ru;q=0.8',
19 'authorization': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnROYW1lIjoid2ViYXBwLXYzMSIsInNjb3BlIjoic3RhdGljLWNvbnRlbnQtYXBpLGN1cmF0aW9uLWFwaSxuZXh4LWNvbnRlbnQtYXBpLXYzMSx3ZWJhcHAtYXBpIn0.mbuG9wS9Yf5q6PqgR4fiaRFIagiHk9JhwoKES7ksVX4',
21 _AUTH = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnROYW1lIjoid2ViYXBwLXYzMSIsInNjb3BlIjoic3RhdGljLWNvbnRlbnQtYXBpLGN1cmF0aW9uLWFwaSxuZXh4LWNvbnRlbnQtYXBpLXYzMSx3ZWJhcHAtYXBpIn0.mbuG9wS9Yf5q6PqgR4fiaRFIagiHk9JhwoKES7ksVX4'
24 def _make_headers(referer):
25 headers = FunkBaseIE._HEADERS.copy()
26 headers['Referer'] = referer
29 def _make_url_result(self, video):
31 '_type': 'url_transparent',
32 'url': 'nexx:741:%s' % video['sourceId'],
33 'ie_key': NexxIE.ie_key(),
34 'id': video['sourceId'],
35 'title': video.get('title'),
36 'description': video.get('description'),
37 'duration': int_or_none(video.get('duration')),
38 'season_number': int_or_none(video.get('seasonNr')),
39 'episode_number': int_or_none(video.get('episodeNr')),
43 class FunkMixIE(FunkBaseIE):
44 _VALID_URL = r'https?://(?:www\.)?funk\.net/mix/(?P<id>[^/]+)/(?P<alias>[^/?#&]+)'
46 'url': 'https://www.funk.net/mix/59d65d935f8b160001828b5b/die-realste-kifferdoku-aller-zeiten',
47 'md5': '8edf617c2f2b7c9847dfda313f199009',
51 'title': '"Die realste Kifferdoku aller Zeiten"',
52 'description': 'md5:c97160f5bafa8d47ec8e2e461012aa9d',
53 'timestamp': 1490274721,
54 'upload_date': '20170323',
58 def _real_extract(self, url):
59 mobj = re.match(self._VALID_URL, url)
60 mix_id = mobj.group('id')
61 alias = mobj.group('alias')
63 lists = self._download_json(
64 'https://www.funk.net/api/v3.1/curation/curatedLists/',
65 mix_id, headers=self._make_headers(url), query={
67 })['_embedded']['curatedListList']
71 if mix_id in (l.get('entityId'), l.get('alias')))['videoMetas']
73 meta['videoDataDelegate']
76 meta, lambda x: x['videoDataDelegate']['alias'],
79 return self._make_url_result(video)
82 class FunkChannelIE(FunkBaseIE):
83 _VALID_URL = r'https?://(?:www\.)?funk\.net/channel/(?P<id>[^/]+)/(?P<alias>[^/?#&]+)'
85 'url': 'https://www.funk.net/channel/ba/die-lustigsten-instrumente-aus-dem-internet-teil-2',
89 'title': 'Die LUSTIGSTEN INSTRUMENTE aus dem Internet - Teil 2',
90 'description': 'md5:a691d0413ef4835588c5b03ded670c1f',
91 'timestamp': 1514507395,
92 'upload_date': '20171229',
95 'skip_download': True,
98 # only available via byIdList API
99 'url': 'https://www.funk.net/channel/informr/martin-sonneborn-erklaert-die-eu',
103 'title': 'Martin Sonneborn erklärt die EU',
104 'description': 'md5:050f74626e4ed87edf4626d2024210c0',
105 'timestamp': 1494424042,
106 'upload_date': '20170510',
109 'skip_download': True,
112 'url': 'https://www.funk.net/channel/59d5149841dca100012511e3/mein-erster-job-lovemilla-folge-1/lovemilla/',
113 'only_matching': True,
116 def _real_extract(self, url):
117 mobj = re.match(self._VALID_URL, url)
118 channel_id = mobj.group('id')
119 alias = mobj.group('alias')
121 headers = self._make_headers(url)
125 # Id-based channels are currently broken on their side: webplayer
126 # tries to process them via byChannelAlias endpoint and fails
128 by_channel_alias = self._download_json(
129 'https://www.funk.net/api/v3.1/webapp/videos/byChannelAlias/%s'
131 'Downloading byChannelAlias JSON', headers=headers, query={
135 video_list = try_get(
136 by_channel_alias, lambda x: x['_embedded']['videoList'], list)
138 video = next(r for r in video_list if r.get('alias') == alias)
141 by_id_list = self._download_json(
142 'https://www.funk.net/api/v3.0/content/videos/byIdList',
143 channel_id, 'Downloading byIdList JSON', headers=headers,
148 video = try_get(by_id_list, lambda x: x['result'][0], dict)
151 results = self._download_json(
152 'https://www.funk.net/api/v3.0/content/videos/filter',
153 channel_id, 'Downloading filter JSON', headers=headers, query={
154 'channelId': channel_id,
157 video = next(r for r in results if r.get('alias') == alias)
159 return self._make_url_result(video)