twitch.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import itertools
  4. import re
  5. import random
  6. from .common import InfoExtractor
  7. from ..compat import (
  8. compat_HTTPError,
  9. compat_parse_qs,
  10. compat_str,
  11. compat_urllib_parse_urlencode,
  12. compat_urllib_parse_urlparse,
  13. compat_urlparse,
  14. )
  15. from ..utils import (
  16. clean_html,
  17. ExtractorError,
  18. int_or_none,
  19. js_to_json,
  20. orderedSet,
  21. parse_duration,
  22. parse_iso8601,
  23. update_url_query,
  24. urlencode_postdata,
  25. )
  26. class TwitchBaseIE(InfoExtractor):
  27. _VALID_URL_BASE = r'https?://(?:www\.)?twitch\.tv'
  28. _API_BASE = 'https://api.twitch.tv'
  29. _USHER_BASE = 'https://usher.ttvnw.net'
  30. _LOGIN_URL = 'http://www.twitch.tv/login'
  31. _CLIENT_ID = 'jzkbprff40iqj646a697cyrvl0zt2m6'
  32. _NETRC_MACHINE = 'twitch'
  33. def _handle_error(self, response):
  34. if not isinstance(response, dict):
  35. return
  36. error = response.get('error')
  37. if error:
  38. raise ExtractorError(
  39. '%s returned error: %s - %s' % (self.IE_NAME, error, response.get('message')),
  40. expected=True)
  41. def _call_api(self, path, item_id, note):
  42. response = self._download_json(
  43. '%s/%s' % (self._API_BASE, path), item_id, note,
  44. headers={'Client-ID': self._CLIENT_ID})
  45. self._handle_error(response)
  46. return response
  47. def _real_initialize(self):
  48. self._login()
  49. def _login(self):
  50. (username, password) = self._get_login_info()
  51. if username is None:
  52. return
  53. def fail(message):
  54. raise ExtractorError(
  55. 'Unable to login. Twitch said: %s' % message, expected=True)
  56. login_page, handle = self._download_webpage_handle(
  57. self._LOGIN_URL, None, 'Downloading login page')
  58. # Some TOR nodes and public proxies are blocked completely
  59. if 'blacklist_message' in login_page:
  60. fail(clean_html(login_page))
  61. login_form = self._hidden_inputs(login_page)
  62. login_form.update({
  63. 'username': username,
  64. 'password': password,
  65. })
  66. redirect_url = handle.geturl()
  67. post_url = self._search_regex(
  68. r'<form[^>]+action=(["\'])(?P<url>.+?)\1', login_page,
  69. 'post url', default=redirect_url, group='url')
  70. if not post_url.startswith('http'):
  71. post_url = compat_urlparse.urljoin(redirect_url, post_url)
  72. headers = {'Referer': redirect_url}
  73. try:
  74. response = self._download_json(
  75. post_url, None, 'Logging in as %s' % username,
  76. data=urlencode_postdata(login_form),
  77. headers=headers)
  78. except ExtractorError as e:
  79. if isinstance(e.cause, compat_HTTPError) and e.cause.code == 400:
  80. response = self._parse_json(
  81. e.cause.read().decode('utf-8'), None)
  82. fail(response['message'])
  83. raise
  84. if response.get('redirect'):
  85. self._download_webpage(
  86. response['redirect'], None, 'Downloading login redirect page',
  87. headers=headers)
  88. def _prefer_source(self, formats):
  89. try:
  90. source = next(f for f in formats if f['format_id'] == 'Source')
  91. source['preference'] = 10
  92. except StopIteration:
  93. pass # No Source stream present
  94. self._sort_formats(formats)
  95. class TwitchItemBaseIE(TwitchBaseIE):
  96. def _download_info(self, item, item_id):
  97. return self._extract_info(self._call_api(
  98. 'kraken/videos/%s%s' % (item, item_id), item_id,
  99. 'Downloading %s info JSON' % self._ITEM_TYPE))
  100. def _extract_media(self, item_id):
  101. info = self._download_info(self._ITEM_SHORTCUT, item_id)
  102. response = self._call_api(
  103. 'api/videos/%s%s' % (self._ITEM_SHORTCUT, item_id), item_id,
  104. 'Downloading %s playlist JSON' % self._ITEM_TYPE)
  105. entries = []
  106. chunks = response['chunks']
  107. qualities = list(chunks.keys())
  108. for num, fragment in enumerate(zip(*chunks.values()), start=1):
  109. formats = []
  110. for fmt_num, fragment_fmt in enumerate(fragment):
  111. format_id = qualities[fmt_num]
  112. fmt = {
  113. 'url': fragment_fmt['url'],
  114. 'format_id': format_id,
  115. 'quality': 1 if format_id == 'live' else 0,
  116. }
  117. m = re.search(r'^(?P<height>\d+)[Pp]', format_id)
  118. if m:
  119. fmt['height'] = int(m.group('height'))
  120. formats.append(fmt)
  121. self._sort_formats(formats)
  122. entry = dict(info)
  123. entry['id'] = '%s_%d' % (entry['id'], num)
  124. entry['title'] = '%s part %d' % (entry['title'], num)
  125. entry['formats'] = formats
  126. entries.append(entry)
  127. return self.playlist_result(entries, info['id'], info['title'])
  128. def _extract_info(self, info):
  129. return {
  130. 'id': info['_id'],
  131. 'title': info.get('title') or 'Untitled Broadcast',
  132. 'description': info.get('description'),
  133. 'duration': int_or_none(info.get('length')),
  134. 'thumbnail': info.get('preview'),
  135. 'uploader': info.get('channel', {}).get('display_name'),
  136. 'uploader_id': info.get('channel', {}).get('name'),
  137. 'timestamp': parse_iso8601(info.get('recorded_at')),
  138. 'view_count': int_or_none(info.get('views')),
  139. }
  140. def _real_extract(self, url):
  141. return self._extract_media(self._match_id(url))
  142. class TwitchVideoIE(TwitchItemBaseIE):
  143. IE_NAME = 'twitch:video'
  144. _VALID_URL = r'%s/[^/]+/b/(?P<id>\d+)' % TwitchBaseIE._VALID_URL_BASE
  145. _ITEM_TYPE = 'video'
  146. _ITEM_SHORTCUT = 'a'
  147. _TEST = {
  148. 'url': 'http://www.twitch.tv/riotgames/b/577357806',
  149. 'info_dict': {
  150. 'id': 'a577357806',
  151. 'title': 'Worlds Semifinals - Star Horn Royal Club vs. OMG',
  152. },
  153. 'playlist_mincount': 12,
  154. 'skip': 'HTTP Error 404: Not Found',
  155. }
  156. class TwitchChapterIE(TwitchItemBaseIE):
  157. IE_NAME = 'twitch:chapter'
  158. _VALID_URL = r'%s/[^/]+/c/(?P<id>\d+)' % TwitchBaseIE._VALID_URL_BASE
  159. _ITEM_TYPE = 'chapter'
  160. _ITEM_SHORTCUT = 'c'
  161. _TESTS = [{
  162. 'url': 'http://www.twitch.tv/acracingleague/c/5285812',
  163. 'info_dict': {
  164. 'id': 'c5285812',
  165. 'title': 'ACRL Off Season - Sports Cars @ Nordschleife',
  166. },
  167. 'playlist_mincount': 3,
  168. 'skip': 'HTTP Error 404: Not Found',
  169. }, {
  170. 'url': 'http://www.twitch.tv/tsm_theoddone/c/2349361',
  171. 'only_matching': True,
  172. }]
  173. class TwitchVodIE(TwitchItemBaseIE):
  174. IE_NAME = 'twitch:vod'
  175. _VALID_URL_BASE = r'https?://(?:www\.|player\.)?twitch\.tv'
  176. _VALID_URL = r'%s/(?:[^/]+/v/|\?video=v)(?P<id>\d+)' % _VALID_URL_BASE
  177. _ITEM_TYPE = 'vod'
  178. _ITEM_SHORTCUT = 'v'
  179. _TESTS = [{
  180. 'url': 'http://www.twitch.tv/riotgames/v/6528877?t=5m10s',
  181. 'info_dict': {
  182. 'id': 'v6528877',
  183. 'ext': 'mp4',
  184. 'title': 'LCK Summer Split - Week 6 Day 1',
  185. 'thumbnail': 're:^https?://.*\.jpg$',
  186. 'duration': 17208,
  187. 'timestamp': 1435131709,
  188. 'upload_date': '20150624',
  189. 'uploader': 'Riot Games',
  190. 'uploader_id': 'riotgames',
  191. 'view_count': int,
  192. 'start_time': 310,
  193. },
  194. 'params': {
  195. # m3u8 download
  196. 'skip_download': True,
  197. },
  198. }, {
  199. # player.twitch.tv URL
  200. 'url': 'http://player.twitch.tv/?video=v6528877&t=5m10s',
  201. 'info_dict': {
  202. 'id': 'v6528877',
  203. 'ext': 'mp4',
  204. 'title': 'LCK Summer Split - Week 6 Day 1',
  205. 'thumbnail': 're:^https?://.*\.jpg$',
  206. 'duration': 17208,
  207. 'timestamp': 1435131709,
  208. 'upload_date': '20150624',
  209. 'uploader': 'Riot Games',
  210. 'uploader_id': 'riotgames',
  211. 'view_count': int,
  212. 'start_time': 310,
  213. },
  214. 'params': {
  215. # m3u8 download
  216. 'skip_download': True,
  217. },
  218. }, {
  219. # Untitled broadcast (title is None)
  220. 'url': 'http://www.twitch.tv/belkao_o/v/11230755',
  221. 'info_dict': {
  222. 'id': 'v11230755',
  223. 'ext': 'mp4',
  224. 'title': 'Untitled Broadcast',
  225. 'thumbnail': 're:^https?://.*\.jpg$',
  226. 'duration': 1638,
  227. 'timestamp': 1439746708,
  228. 'upload_date': '20150816',
  229. 'uploader': 'BelkAO_o',
  230. 'uploader_id': 'belkao_o',
  231. 'view_count': int,
  232. },
  233. 'params': {
  234. # m3u8 download
  235. 'skip_download': True,
  236. },
  237. 'skip': 'HTTP Error 404: Not Found',
  238. }]
  239. def _real_extract(self, url):
  240. item_id = self._match_id(url)
  241. info = self._download_info(self._ITEM_SHORTCUT, item_id)
  242. access_token = self._call_api(
  243. 'api/vods/%s/access_token' % item_id, item_id,
  244. 'Downloading %s access token' % self._ITEM_TYPE)
  245. formats = self._extract_m3u8_formats(
  246. '%s/vod/%s?%s' % (
  247. self._USHER_BASE, item_id,
  248. compat_urllib_parse_urlencode({
  249. 'allow_source': 'true',
  250. 'allow_audio_only': 'true',
  251. 'allow_spectre': 'true',
  252. 'player': 'twitchweb',
  253. 'nauth': access_token['token'],
  254. 'nauthsig': access_token['sig'],
  255. })),
  256. item_id, 'mp4', entry_protocol='m3u8_native')
  257. self._prefer_source(formats)
  258. info['formats'] = formats
  259. parsed_url = compat_urllib_parse_urlparse(url)
  260. query = compat_parse_qs(parsed_url.query)
  261. if 't' in query:
  262. info['start_time'] = parse_duration(query['t'][0])
  263. if info.get('timestamp') is not None:
  264. info['subtitles'] = {
  265. 'rechat': [{
  266. 'url': update_url_query(
  267. 'https://rechat.twitch.tv/rechat-messages', {
  268. 'video_id': 'v%s' % item_id,
  269. 'start': info['timestamp'],
  270. }),
  271. 'ext': 'json',
  272. }],
  273. }
  274. return info
  275. class TwitchPlaylistBaseIE(TwitchBaseIE):
  276. _PLAYLIST_PATH = 'kraken/channels/%s/videos/?offset=%d&limit=%d'
  277. _PAGE_LIMIT = 100
  278. def _extract_playlist(self, channel_id):
  279. info = self._call_api(
  280. 'kraken/channels/%s' % channel_id,
  281. channel_id, 'Downloading channel info JSON')
  282. channel_name = info.get('display_name') or info.get('name')
  283. entries = []
  284. offset = 0
  285. limit = self._PAGE_LIMIT
  286. broken_paging_detected = False
  287. counter_override = None
  288. for counter in itertools.count(1):
  289. response = self._call_api(
  290. self._PLAYLIST_PATH % (channel_id, offset, limit),
  291. channel_id,
  292. 'Downloading %s JSON page %s'
  293. % (self._PLAYLIST_TYPE, counter_override or counter))
  294. page_entries = self._extract_playlist_page(response)
  295. if not page_entries:
  296. break
  297. total = int_or_none(response.get('_total'))
  298. # Since the beginning of March 2016 twitch's paging mechanism
  299. # is completely broken on the twitch side. It simply ignores
  300. # a limit and returns the whole offset number of videos.
  301. # Working around by just requesting all videos at once.
  302. # Upd: pagination bug was fixed by twitch on 15.03.2016.
  303. if not broken_paging_detected and total and len(page_entries) > limit:
  304. self.report_warning(
  305. 'Twitch pagination is broken on twitch side, requesting all videos at once',
  306. channel_id)
  307. broken_paging_detected = True
  308. offset = total
  309. counter_override = '(all at once)'
  310. continue
  311. entries.extend(page_entries)
  312. if broken_paging_detected or total and len(page_entries) >= total:
  313. break
  314. offset += limit
  315. return self.playlist_result(
  316. [self.url_result(entry) for entry in orderedSet(entries)],
  317. channel_id, channel_name)
  318. def _extract_playlist_page(self, response):
  319. videos = response.get('videos')
  320. return [video['url'] for video in videos] if videos else []
  321. def _real_extract(self, url):
  322. return self._extract_playlist(self._match_id(url))
  323. class TwitchProfileIE(TwitchPlaylistBaseIE):
  324. IE_NAME = 'twitch:profile'
  325. _VALID_URL = r'%s/(?P<id>[^/]+)/profile/?(?:\#.*)?$' % TwitchBaseIE._VALID_URL_BASE
  326. _PLAYLIST_TYPE = 'profile'
  327. _TEST = {
  328. 'url': 'http://www.twitch.tv/vanillatv/profile',
  329. 'info_dict': {
  330. 'id': 'vanillatv',
  331. 'title': 'VanillaTV',
  332. },
  333. 'playlist_mincount': 412,
  334. }
  335. class TwitchVideosBaseIE(TwitchPlaylistBaseIE):
  336. _VALID_URL_VIDEOS_BASE = r'%s/(?P<id>[^/]+)/videos' % TwitchBaseIE._VALID_URL_BASE
  337. _PLAYLIST_PATH = TwitchPlaylistBaseIE._PLAYLIST_PATH + '&broadcast_type='
  338. class TwitchAllVideosIE(TwitchVideosBaseIE):
  339. IE_NAME = 'twitch:videos:all'
  340. _VALID_URL = r'%s/all' % TwitchVideosBaseIE._VALID_URL_VIDEOS_BASE
  341. _PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'archive,upload,highlight'
  342. _PLAYLIST_TYPE = 'all videos'
  343. _TEST = {
  344. 'url': 'https://www.twitch.tv/spamfish/videos/all',
  345. 'info_dict': {
  346. 'id': 'spamfish',
  347. 'title': 'Spamfish',
  348. },
  349. 'playlist_mincount': 869,
  350. }
  351. class TwitchUploadsIE(TwitchVideosBaseIE):
  352. IE_NAME = 'twitch:videos:uploads'
  353. _VALID_URL = r'%s/uploads' % TwitchVideosBaseIE._VALID_URL_VIDEOS_BASE
  354. _PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'upload'
  355. _PLAYLIST_TYPE = 'uploads'
  356. _TEST = {
  357. 'url': 'https://www.twitch.tv/spamfish/videos/uploads',
  358. 'info_dict': {
  359. 'id': 'spamfish',
  360. 'title': 'Spamfish',
  361. },
  362. 'playlist_mincount': 0,
  363. }
  364. class TwitchPastBroadcastsIE(TwitchVideosBaseIE):
  365. IE_NAME = 'twitch:videos:past-broadcasts'
  366. _VALID_URL = r'%s/past-broadcasts' % TwitchVideosBaseIE._VALID_URL_VIDEOS_BASE
  367. _PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'archive'
  368. _PLAYLIST_TYPE = 'past broadcasts'
  369. _TEST = {
  370. 'url': 'https://www.twitch.tv/spamfish/videos/past-broadcasts',
  371. 'info_dict': {
  372. 'id': 'spamfish',
  373. 'title': 'Spamfish',
  374. },
  375. 'playlist_mincount': 0,
  376. }
  377. class TwitchHighlightsIE(TwitchVideosBaseIE):
  378. IE_NAME = 'twitch:videos:highlights'
  379. _VALID_URL = r'%s/highlights' % TwitchVideosBaseIE._VALID_URL_VIDEOS_BASE
  380. _PLAYLIST_PATH = TwitchVideosBaseIE._PLAYLIST_PATH + 'highlight'
  381. _PLAYLIST_TYPE = 'highlights'
  382. _TEST = {
  383. 'url': 'https://www.twitch.tv/spamfish/videos/highlights',
  384. 'info_dict': {
  385. 'id': 'spamfish',
  386. 'title': 'Spamfish',
  387. },
  388. 'playlist_mincount': 805,
  389. }
  390. class TwitchStreamIE(TwitchBaseIE):
  391. IE_NAME = 'twitch:stream'
  392. _VALID_URL = r'%s/(?P<id>[^/#?]+)/?(?:\#.*)?$' % TwitchBaseIE._VALID_URL_BASE
  393. _TESTS = [{
  394. 'url': 'http://www.twitch.tv/shroomztv',
  395. 'info_dict': {
  396. 'id': '12772022048',
  397. 'display_id': 'shroomztv',
  398. 'ext': 'mp4',
  399. 'title': 're:^ShroomzTV [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
  400. 'description': 'H1Z1 - lonewolfing with ShroomzTV | A3 Battle Royale later - @ShroomzTV',
  401. 'is_live': True,
  402. 'timestamp': 1421928037,
  403. 'upload_date': '20150122',
  404. 'uploader': 'ShroomzTV',
  405. 'uploader_id': 'shroomztv',
  406. 'view_count': int,
  407. },
  408. 'params': {
  409. # m3u8 download
  410. 'skip_download': True,
  411. },
  412. }, {
  413. 'url': 'http://www.twitch.tv/miracle_doto#profile-0',
  414. 'only_matching': True,
  415. }]
  416. def _real_extract(self, url):
  417. channel_id = self._match_id(url)
  418. stream = self._call_api(
  419. 'kraken/streams/%s?stream_type=all' % channel_id, channel_id,
  420. 'Downloading stream JSON').get('stream')
  421. if not stream:
  422. raise ExtractorError('%s is offline' % channel_id, expected=True)
  423. # Channel name may be typed if different case than the original channel name
  424. # (e.g. http://www.twitch.tv/TWITCHPLAYSPOKEMON) that will lead to constructing
  425. # an invalid m3u8 URL. Working around by use of original channel name from stream
  426. # JSON and fallback to lowercase if it's not available.
  427. channel_id = stream.get('channel', {}).get('name') or channel_id.lower()
  428. access_token = self._call_api(
  429. 'api/channels/%s/access_token' % channel_id, channel_id,
  430. 'Downloading channel access token')
  431. query = {
  432. 'allow_source': 'true',
  433. 'allow_audio_only': 'true',
  434. 'allow_spectre': 'true',
  435. 'p': random.randint(1000000, 10000000),
  436. 'player': 'twitchweb',
  437. 'segment_preference': '4',
  438. 'sig': access_token['sig'].encode('utf-8'),
  439. 'token': access_token['token'].encode('utf-8'),
  440. }
  441. formats = self._extract_m3u8_formats(
  442. '%s/api/channel/hls/%s.m3u8?%s'
  443. % (self._USHER_BASE, channel_id, compat_urllib_parse_urlencode(query)),
  444. channel_id, 'mp4')
  445. self._prefer_source(formats)
  446. view_count = stream.get('viewers')
  447. timestamp = parse_iso8601(stream.get('created_at'))
  448. channel = stream['channel']
  449. title = self._live_title(channel.get('display_name') or channel.get('name'))
  450. description = channel.get('status')
  451. thumbnails = []
  452. for thumbnail_key, thumbnail_url in stream['preview'].items():
  453. m = re.search(r'(?P<width>\d+)x(?P<height>\d+)\.jpg$', thumbnail_key)
  454. if not m:
  455. continue
  456. thumbnails.append({
  457. 'url': thumbnail_url,
  458. 'width': int(m.group('width')),
  459. 'height': int(m.group('height')),
  460. })
  461. return {
  462. 'id': compat_str(stream['_id']),
  463. 'display_id': channel_id,
  464. 'title': title,
  465. 'description': description,
  466. 'thumbnails': thumbnails,
  467. 'uploader': channel.get('display_name'),
  468. 'uploader_id': channel.get('name'),
  469. 'timestamp': timestamp,
  470. 'view_count': view_count,
  471. 'formats': formats,
  472. 'is_live': True,
  473. }
  474. class TwitchClipsIE(InfoExtractor):
  475. IE_NAME = 'twitch:clips'
  476. _VALID_URL = r'https?://clips\.twitch\.tv/(?:[^/]+/)*(?P<id>[^/?#&]+)'
  477. _TESTS = [{
  478. 'url': 'https://clips.twitch.tv/ea/AggressiveCobraPoooound',
  479. 'md5': '761769e1eafce0ffebfb4089cb3847cd',
  480. 'info_dict': {
  481. 'id': 'AggressiveCobraPoooound',
  482. 'ext': 'mp4',
  483. 'title': 'EA Play 2016 Live from the Novo Theatre',
  484. 'thumbnail': 're:^https?://.*\.jpg',
  485. 'creator': 'EA',
  486. 'uploader': 'stereotype_',
  487. 'uploader_id': 'stereotype_',
  488. },
  489. }, {
  490. # multiple formats
  491. 'url': 'https://clips.twitch.tv/rflegendary/UninterestedBeeDAESuppy',
  492. 'only_matching': True,
  493. }]
  494. def _real_extract(self, url):
  495. video_id = self._match_id(url)
  496. webpage = self._download_webpage(url, video_id)
  497. clip = self._parse_json(
  498. self._search_regex(
  499. r'(?s)clipInfo\s*=\s*({.+?});', webpage, 'clip info'),
  500. video_id, transform_source=js_to_json)
  501. title = clip.get('channel_title') or self._og_search_title(webpage)
  502. formats = [{
  503. 'url': option['source'],
  504. 'format_id': option.get('quality'),
  505. 'height': int_or_none(option.get('quality')),
  506. } for option in clip.get('quality_options', []) if option.get('source')]
  507. if not formats:
  508. formats = [{
  509. 'url': clip['clip_video_url'],
  510. }]
  511. self._sort_formats(formats)
  512. return {
  513. 'id': video_id,
  514. 'title': title,
  515. 'thumbnail': self._og_search_thumbnail(webpage),
  516. 'creator': clip.get('broadcaster_display_name') or clip.get('broadcaster_login'),
  517. 'uploader': clip.get('curator_login'),
  518. 'uploader_id': clip.get('curator_display_name'),
  519. 'formats': formats,
  520. }