You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

559 lines
22 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..compat import compat_urlparse
  6. from ..utils import (
  7. determine_ext,
  8. dict_get,
  9. ExtractorError,
  10. float_or_none,
  11. int_or_none,
  12. remove_end,
  13. try_get,
  14. xpath_text,
  15. )
  16. from .periscope import PeriscopeIE
  17. class TwitterBaseIE(InfoExtractor):
  18. def _extract_formats_from_vmap_url(self, vmap_url, video_id):
  19. vmap_data = self._download_xml(vmap_url, video_id)
  20. video_url = xpath_text(vmap_data, './/MediaFile').strip()
  21. if determine_ext(video_url) == 'm3u8':
  22. return self._extract_m3u8_formats(
  23. video_url, video_id, ext='mp4', m3u8_id='hls',
  24. entry_protocol='m3u8_native')
  25. return [{
  26. 'url': video_url,
  27. }]
  28. @staticmethod
  29. def _search_dimensions_in_video_url(a_format, video_url):
  30. m = re.search(r'/(?P<width>\d+)x(?P<height>\d+)/', video_url)
  31. if m:
  32. a_format.update({
  33. 'width': int(m.group('width')),
  34. 'height': int(m.group('height')),
  35. })
  36. class TwitterCardIE(TwitterBaseIE):
  37. IE_NAME = 'twitter:card'
  38. _VALID_URL = r'https?://(?:www\.)?twitter\.com/i/(?P<path>cards/tfw/v1|videos(?:/tweet)?)/(?P<id>\d+)'
  39. _TESTS = [
  40. {
  41. 'url': 'https://twitter.com/i/cards/tfw/v1/560070183650213889',
  42. # MD5 checksums are different in different places
  43. 'info_dict': {
  44. 'id': '560070183650213889',
  45. 'ext': 'mp4',
  46. 'title': 'Twitter web player',
  47. 'thumbnail': r're:^https?://.*\.jpg$',
  48. 'duration': 30.033,
  49. },
  50. },
  51. {
  52. 'url': 'https://twitter.com/i/cards/tfw/v1/623160978427936768',
  53. 'md5': '7ee2a553b63d1bccba97fbed97d9e1c8',
  54. 'info_dict': {
  55. 'id': '623160978427936768',
  56. 'ext': 'mp4',
  57. 'title': 'Twitter web player',
  58. 'thumbnail': r're:^https?://.*$',
  59. },
  60. },
  61. {
  62. 'url': 'https://twitter.com/i/cards/tfw/v1/654001591733886977',
  63. 'md5': 'b6d9683dd3f48e340ded81c0e917ad46',
  64. 'info_dict': {
  65. 'id': 'dq4Oj5quskI',
  66. 'ext': 'mp4',
  67. 'title': 'Ubuntu 11.10 Overview',
  68. 'description': 'md5:a831e97fa384863d6e26ce48d1c43376',
  69. 'upload_date': '20111013',
  70. 'uploader': 'OMG! Ubuntu!',
  71. 'uploader_id': 'omgubuntu',
  72. },
  73. 'add_ie': ['Youtube'],
  74. },
  75. {
  76. 'url': 'https://twitter.com/i/cards/tfw/v1/665289828897005568',
  77. 'md5': '6dabeaca9e68cbb71c99c322a4b42a11',
  78. 'info_dict': {
  79. 'id': 'iBb2x00UVlv',
  80. 'ext': 'mp4',
  81. 'upload_date': '20151113',
  82. 'uploader_id': '1189339351084113920',
  83. 'uploader': 'ArsenalTerje',
  84. 'title': 'Vine by ArsenalTerje',
  85. 'timestamp': 1447451307,
  86. },
  87. 'add_ie': ['Vine'],
  88. }, {
  89. 'url': 'https://twitter.com/i/videos/tweet/705235433198714880',
  90. 'md5': '884812a2adc8aaf6fe52b15ccbfa3b88',
  91. 'info_dict': {
  92. 'id': '705235433198714880',
  93. 'ext': 'mp4',
  94. 'title': 'Twitter web player',
  95. 'thumbnail': r're:^https?://.*',
  96. },
  97. }, {
  98. 'url': 'https://twitter.com/i/videos/752274308186120192',
  99. 'only_matching': True,
  100. },
  101. ]
  102. _API_BASE = 'https://api.twitter.com/1.1'
  103. def _parse_media_info(self, media_info, video_id):
  104. formats = []
  105. for media_variant in media_info.get('variants', []):
  106. media_url = media_variant['url']
  107. if media_url.endswith('.m3u8'):
  108. formats.extend(self._extract_m3u8_formats(media_url, video_id, ext='mp4', m3u8_id='hls'))
  109. elif media_url.endswith('.mpd'):
  110. formats.extend(self._extract_mpd_formats(media_url, video_id, mpd_id='dash'))
  111. else:
  112. tbr = int_or_none(dict_get(media_variant, ('bitRate', 'bitrate')), scale=1000)
  113. a_format = {
  114. 'url': media_url,
  115. 'format_id': 'http-%d' % tbr if tbr else 'http',
  116. 'tbr': tbr,
  117. }
  118. # Reported bitRate may be zero
  119. if not a_format['tbr']:
  120. del a_format['tbr']
  121. self._search_dimensions_in_video_url(a_format, media_url)
  122. formats.append(a_format)
  123. return formats
  124. def _extract_mobile_formats(self, username, video_id):
  125. webpage = self._download_webpage(
  126. 'https://mobile.twitter.com/%s/status/%s' % (username, video_id),
  127. video_id, 'Downloading mobile webpage',
  128. headers={
  129. # A recent mobile UA is necessary for `gt` cookie
  130. 'User-Agent': 'Mozilla/5.0 (Android 6.0.1; Mobile; rv:54.0) Gecko/54.0 Firefox/54.0',
  131. })
  132. main_script_url = self._html_search_regex(
  133. r'<script[^>]+src="([^"]+main\.[^"]+)"', webpage, 'main script URL')
  134. main_script = self._download_webpage(
  135. main_script_url, video_id, 'Downloading main script')
  136. bearer_token = self._search_regex(
  137. r'BEARER_TOKEN\s*:\s*"([^"]+)"',
  138. main_script, 'bearer token')
  139. # https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-show-id
  140. api_data = self._download_json(
  141. '%s/statuses/show/%s.json' % (self._API_BASE, video_id),
  142. video_id, 'Downloading API data',
  143. headers={
  144. 'Authorization': 'Bearer ' + bearer_token,
  145. })
  146. media_info = try_get(api_data, lambda o: o['extended_entities']['media'][0]['video_info']) or {}
  147. return self._parse_media_info(media_info, video_id)
  148. def _real_extract(self, url):
  149. path, video_id = re.search(self._VALID_URL, url).groups()
  150. config = None
  151. formats = []
  152. duration = None
  153. urls = [url]
  154. if path.startswith('cards/'):
  155. urls.append('https://twitter.com/i/videos/' + video_id)
  156. for u in urls:
  157. webpage = self._download_webpage(
  158. u, video_id, headers={'Referer': 'https://twitter.com/'})
  159. iframe_url = self._html_search_regex(
  160. r'<iframe[^>]+src="((?:https?:)?//(?:www\.youtube\.com/embed/[^"]+|(?:www\.)?vine\.co/v/\w+/card))"',
  161. webpage, 'video iframe', default=None)
  162. if iframe_url:
  163. return self.url_result(iframe_url)
  164. config = self._parse_json(self._html_search_regex(
  165. r'data-(?:player-)?config="([^"]+)"', webpage,
  166. 'data player config', default='{}'),
  167. video_id)
  168. if config.get('source_type') == 'vine':
  169. return self.url_result(config['player_url'], 'Vine')
  170. periscope_url = PeriscopeIE._extract_url(webpage)
  171. if periscope_url:
  172. return self.url_result(periscope_url, PeriscopeIE.ie_key())
  173. video_url = config.get('video_url') or config.get('playlist', [{}])[0].get('source')
  174. if video_url:
  175. if determine_ext(video_url) == 'm3u8':
  176. formats.extend(self._extract_m3u8_formats(video_url, video_id, ext='mp4', m3u8_id='hls'))
  177. else:
  178. f = {
  179. 'url': video_url,
  180. }
  181. self._search_dimensions_in_video_url(f, video_url)
  182. formats.append(f)
  183. vmap_url = config.get('vmapUrl') or config.get('vmap_url')
  184. if vmap_url:
  185. formats.extend(
  186. self._extract_formats_from_vmap_url(vmap_url, video_id))
  187. media_info = None
  188. for entity in config.get('status', {}).get('entities', []):
  189. if 'mediaInfo' in entity:
  190. media_info = entity['mediaInfo']
  191. if media_info:
  192. formats.extend(self._parse_media_info(media_info, video_id))
  193. duration = float_or_none(media_info.get('duration', {}).get('nanos'), scale=1e9)
  194. username = config.get('user', {}).get('screen_name')
  195. if username:
  196. formats.extend(self._extract_mobile_formats(username, video_id))
  197. if formats:
  198. title = self._search_regex(r'<title>([^<]+)</title>', webpage, 'title')
  199. thumbnail = config.get('posterImageUrl') or config.get('image_src')
  200. duration = float_or_none(config.get('duration'), scale=1000) or duration
  201. break
  202. if not formats:
  203. headers = {
  204. 'Authorization': 'Bearer AAAAAAAAAAAAAAAAAAAAAPYXBAAAAAAACLXUNDekMxqa8h%2F40K4moUkGsoc%3DTYfbDKbT3jJPCEVnMYqilB28NHfOPqkca3qaAxGfsyKCs0wRbw',
  205. 'Referer': url,
  206. }
  207. ct0 = self._get_cookies(url).get('ct0')
  208. if ct0:
  209. headers['csrf_token'] = ct0.value
  210. guest_token = self._download_json(
  211. '%s/guest/activate.json' % self._API_BASE, video_id,
  212. 'Downloading guest token', data=b'',
  213. headers=headers)['guest_token']
  214. headers['x-guest-token'] = guest_token
  215. self._set_cookie('api.twitter.com', 'gt', guest_token)
  216. config = self._download_json(
  217. '%s/videos/tweet/config/%s.json' % (self._API_BASE, video_id),
  218. video_id, headers=headers)
  219. track = config['track']
  220. vmap_url = track.get('vmapUrl')
  221. if vmap_url:
  222. formats = self._extract_formats_from_vmap_url(vmap_url, video_id)
  223. else:
  224. playback_url = track['playbackUrl']
  225. if determine_ext(playback_url) == 'm3u8':
  226. formats = self._extract_m3u8_formats(
  227. playback_url, video_id, 'mp4',
  228. entry_protocol='m3u8_native', m3u8_id='hls')
  229. else:
  230. formats = [{
  231. 'url': playback_url,
  232. }]
  233. title = 'Twitter web player'
  234. thumbnail = config.get('posterImage')
  235. duration = float_or_none(track.get('durationMs'), scale=1000)
  236. self._remove_duplicate_formats(formats)
  237. self._sort_formats(formats)
  238. return {
  239. 'id': video_id,
  240. 'title': title,
  241. 'thumbnail': thumbnail,
  242. 'duration': duration,
  243. 'formats': formats,
  244. }
  245. class TwitterIE(InfoExtractor):
  246. IE_NAME = 'twitter'
  247. _VALID_URL = r'https?://(?:www\.|m\.|mobile\.)?twitter\.com/(?:i/web|(?P<user_id>[^/]+))/status/(?P<id>\d+)'
  248. _TEMPLATE_URL = 'https://twitter.com/%s/status/%s'
  249. _TEMPLATE_STATUSES_URL = 'https://twitter.com/statuses/%s'
  250. _TESTS = [{
  251. 'url': 'https://twitter.com/freethenipple/status/643211948184596480',
  252. 'info_dict': {
  253. 'id': '643211948184596480',
  254. 'ext': 'mp4',
  255. 'title': 'FREE THE NIPPLE - FTN supporters on Hollywood Blvd today!',
  256. 'thumbnail': r're:^https?://.*\.jpg',
  257. 'description': 'FREE THE NIPPLE on Twitter: "FTN supporters on Hollywood Blvd today! http://t.co/c7jHH749xJ"',
  258. 'uploader': 'FREE THE NIPPLE',
  259. 'uploader_id': 'freethenipple',
  260. 'duration': 12.922,
  261. },
  262. }, {
  263. 'url': 'https://twitter.com/giphz/status/657991469417025536/photo/1',
  264. 'md5': 'f36dcd5fb92bf7057f155e7d927eeb42',
  265. 'info_dict': {
  266. 'id': '657991469417025536',
  267. 'ext': 'mp4',
  268. 'title': 'Gifs - tu vai cai tu vai cai tu nao eh capaz disso tu vai cai',
  269. 'description': 'Gifs on Twitter: "tu vai cai tu vai cai tu nao eh capaz disso tu vai cai https://t.co/tM46VHFlO5"',
  270. 'thumbnail': r're:^https?://.*\.png',
  271. 'uploader': 'Gifs',
  272. 'uploader_id': 'giphz',
  273. },
  274. 'expected_warnings': ['height', 'width'],
  275. 'skip': 'Account suspended',
  276. }, {
  277. 'url': 'https://twitter.com/starwars/status/665052190608723968',
  278. 'info_dict': {
  279. 'id': '665052190608723968',
  280. 'ext': 'mp4',
  281. 'title': 'Star Wars - A new beginning is coming December 18. Watch the official 60 second #TV spot for #StarWars: #TheForceAwakens.',
  282. 'description': 'Star Wars on Twitter: "A new beginning is coming December 18. Watch the official 60 second #TV spot for #StarWars: #TheForceAwakens."',
  283. 'uploader_id': 'starwars',
  284. 'uploader': 'Star Wars',
  285. },
  286. }, {
  287. 'url': 'https://twitter.com/BTNBrentYarina/status/705235433198714880',
  288. 'info_dict': {
  289. 'id': '705235433198714880',
  290. 'ext': 'mp4',
  291. 'title': 'Brent Yarina - Khalil Iverson\'s missed highlight dunk. And made highlight dunk. In one highlight.',
  292. 'description': 'Brent Yarina on Twitter: "Khalil Iverson\'s missed highlight dunk. And made highlight dunk. In one highlight."',
  293. 'uploader_id': 'BTNBrentYarina',
  294. 'uploader': 'Brent Yarina',
  295. },
  296. 'params': {
  297. # The same video as https://twitter.com/i/videos/tweet/705235433198714880
  298. # Test case of TwitterCardIE
  299. 'skip_download': True,
  300. },
  301. }, {
  302. 'url': 'https://twitter.com/jaydingeer/status/700207533655363584',
  303. 'info_dict': {
  304. 'id': '700207533655363584',
  305. 'ext': 'mp4',
  306. 'title': 'JG - BEAT PROD: @suhmeduh #Damndaniel',
  307. 'description': 'JG on Twitter: "BEAT PROD: @suhmeduh https://t.co/HBrQ4AfpvZ #Damndaniel https://t.co/byBooq2ejZ"',
  308. 'thumbnail': r're:^https?://.*\.jpg',
  309. 'uploader': 'JG',
  310. 'uploader_id': 'jaydingeer',
  311. 'duration': 30.0,
  312. },
  313. }, {
  314. 'url': 'https://twitter.com/Filmdrunk/status/713801302971588609',
  315. 'md5': '89a15ed345d13b86e9a5a5e051fa308a',
  316. 'info_dict': {
  317. 'id': 'MIOxnrUteUd',
  318. 'ext': 'mp4',
  319. 'title': 'Vince Mancini - Vine of the day',
  320. 'description': 'Vince Mancini on Twitter: "Vine of the day https://t.co/xmTvRdqxWf"',
  321. 'uploader': 'Vince Mancini',
  322. 'uploader_id': 'Filmdrunk',
  323. 'timestamp': 1402826626,
  324. 'upload_date': '20140615',
  325. },
  326. 'add_ie': ['Vine'],
  327. }, {
  328. 'url': 'https://twitter.com/captainamerica/status/719944021058060289',
  329. 'info_dict': {
  330. 'id': '719944021058060289',
  331. 'ext': 'mp4',
  332. 'title': 'Captain America - @King0fNerd Are you sure you made the right choice? Find out in theaters.',
  333. 'description': 'Captain America on Twitter: "@King0fNerd Are you sure you made the right choice? Find out in theaters. https://t.co/GpgYi9xMJI"',
  334. 'uploader_id': 'captainamerica',
  335. 'uploader': 'Captain America',
  336. 'duration': 3.17,
  337. },
  338. }, {
  339. 'url': 'https://twitter.com/OPP_HSD/status/779210622571536384',
  340. 'info_dict': {
  341. 'id': '1zqKVVlkqLaKB',
  342. 'ext': 'mp4',
  343. 'title': 'Sgt Kerry Schmidt - LIVE on #Periscope: Road rage, mischief, assault, rollover and fire in one occurrence',
  344. 'description': 'Sgt Kerry Schmidt on Twitter: "LIVE on #Periscope: Road rage, mischief, assault, rollover and fire in one occurrence https://t.co/EKrVgIXF3s"',
  345. 'upload_date': '20160923',
  346. 'uploader_id': 'OPP_HSD',
  347. 'uploader': 'Sgt Kerry Schmidt',
  348. 'timestamp': 1474613214,
  349. },
  350. 'add_ie': ['Periscope'],
  351. }, {
  352. # has mp4 formats via mobile API
  353. 'url': 'https://twitter.com/news_al3alm/status/852138619213144067',
  354. 'info_dict': {
  355. 'id': '852138619213144067',
  356. 'ext': 'mp4',
  357. 'title': 'عالم الأخبار - كلمة تاريخية بجلسة الجناسي التاريخية.. النائب خالد مؤنس العتيبي للمعارضين : اتقوا الله .. الظلم ظلمات يوم القيامة',
  358. 'description': 'عالم الأخبار on Twitter: "كلمة تاريخية بجلسة الجناسي التاريخية.. النائب خالد مؤنس العتيبي للمعارضين : اتقوا الله .. الظلم ظلمات يوم القيامة https://t.co/xg6OhpyKfN"',
  359. 'uploader': 'عالم الأخبار',
  360. 'uploader_id': 'news_al3alm',
  361. 'duration': 277.4,
  362. },
  363. }, {
  364. 'url': 'https://twitter.com/i/web/status/910031516746514432',
  365. 'info_dict': {
  366. 'id': '910031516746514432',
  367. 'ext': 'mp4',
  368. 'title': 'Préfet de Guadeloupe - [Direct] #Maria Le centre se trouve actuellement au sud de Basse-Terre. Restez confinés. Réfugiez-vous dans la pièce la + sûre.',
  369. 'thumbnail': r're:^https?://.*\.jpg',
  370. 'description': 'Préfet de Guadeloupe on Twitter: "[Direct] #Maria Le centre se trouve actuellement au sud de Basse-Terre. Restez confinés. Réfugiez-vous dans la pièce la + sûre. https://t.co/mwx01Rs4lo"',
  371. 'uploader': 'Préfet de Guadeloupe',
  372. 'uploader_id': 'Prefet971',
  373. 'duration': 47.48,
  374. },
  375. 'params': {
  376. 'skip_download': True, # requires ffmpeg
  377. },
  378. }, {
  379. # card via api.twitter.com/1.1/videos/tweet/config
  380. 'url': 'https://twitter.com/LisPower1/status/1001551623938805763',
  381. 'info_dict': {
  382. 'id': '1001551623938805763',
  383. 'ext': 'mp4',
  384. 'title': 're:.*?Shep is on a roll today.*?',
  385. 'thumbnail': r're:^https?://.*\.jpg',
  386. 'description': 'md5:63b036c228772523ae1924d5f8e5ed6b',
  387. 'uploader': 'Lis Power',
  388. 'uploader_id': 'LisPower1',
  389. 'duration': 111.278,
  390. },
  391. 'params': {
  392. 'skip_download': True, # requires ffmpeg
  393. },
  394. }]
  395. def _real_extract(self, url):
  396. mobj = re.match(self._VALID_URL, url)
  397. user_id = mobj.group('user_id')
  398. twid = mobj.group('id')
  399. webpage, urlh = self._download_webpage_handle(
  400. self._TEMPLATE_STATUSES_URL % twid, twid)
  401. if 'twitter.com/account/suspended' in urlh.geturl():
  402. raise ExtractorError('Account suspended by Twitter.', expected=True)
  403. if user_id is None:
  404. mobj = re.match(self._VALID_URL, urlh.geturl())
  405. user_id = mobj.group('user_id')
  406. username = remove_end(self._og_search_title(webpage), ' on Twitter')
  407. title = description = self._og_search_description(webpage).strip('').replace('\n', ' ').strip('“”')
  408. # strip 'https -_t.co_BJYgOjSeGA' junk from filenames
  409. title = re.sub(r'\s+(https?://[^ ]+)', '', title)
  410. info = {
  411. 'uploader_id': user_id,
  412. 'uploader': username,
  413. 'webpage_url': url,
  414. 'description': '%s on Twitter: "%s"' % (username, description),
  415. 'title': username + ' - ' + title,
  416. }
  417. mobj = re.search(r'''(?x)
  418. <video[^>]+class="animated-gif"(?P<more_info>[^>]+)>\s*
  419. <source[^>]+video-src="(?P<url>[^"]+)"
  420. ''', webpage)
  421. if mobj:
  422. more_info = mobj.group('more_info')
  423. height = int_or_none(self._search_regex(
  424. r'data-height="(\d+)"', more_info, 'height', fatal=False))
  425. width = int_or_none(self._search_regex(
  426. r'data-width="(\d+)"', more_info, 'width', fatal=False))
  427. thumbnail = self._search_regex(
  428. r'poster="([^"]+)"', more_info, 'poster', fatal=False)
  429. info.update({
  430. 'id': twid,
  431. 'url': mobj.group('url'),
  432. 'height': height,
  433. 'width': width,
  434. 'thumbnail': thumbnail,
  435. })
  436. return info
  437. twitter_card_url = None
  438. if 'class="PlayableMedia' in webpage:
  439. twitter_card_url = '%s//twitter.com/i/videos/tweet/%s' % (self.http_scheme(), twid)
  440. else:
  441. twitter_card_iframe_url = self._search_regex(
  442. r'data-full-card-iframe-url=([\'"])(?P<url>(?:(?!\1).)+)\1',
  443. webpage, 'Twitter card iframe URL', default=None, group='url')
  444. if twitter_card_iframe_url:
  445. twitter_card_url = compat_urlparse.urljoin(url, twitter_card_iframe_url)
  446. if twitter_card_url:
  447. info.update({
  448. '_type': 'url_transparent',
  449. 'ie_key': 'TwitterCard',
  450. 'url': twitter_card_url,
  451. })
  452. return info
  453. raise ExtractorError('There\'s no video in this tweet.')
  454. class TwitterAmplifyIE(TwitterBaseIE):
  455. IE_NAME = 'twitter:amplify'
  456. _VALID_URL = r'https?://amp\.twimg\.com/v/(?P<id>[0-9a-f\-]{36})'
  457. _TEST = {
  458. 'url': 'https://amp.twimg.com/v/0ba0c3c7-0af3-4c0a-bed5-7efd1ffa2951',
  459. 'md5': '7df102d0b9fd7066b86f3159f8e81bf6',
  460. 'info_dict': {
  461. 'id': '0ba0c3c7-0af3-4c0a-bed5-7efd1ffa2951',
  462. 'ext': 'mp4',
  463. 'title': 'Twitter Video',
  464. 'thumbnail': 're:^https?://.*',
  465. },
  466. }
  467. def _real_extract(self, url):
  468. video_id = self._match_id(url)
  469. webpage = self._download_webpage(url, video_id)
  470. vmap_url = self._html_search_meta(
  471. 'twitter:amplify:vmap', webpage, 'vmap url')
  472. formats = self._extract_formats_from_vmap_url(vmap_url, video_id)
  473. thumbnails = []
  474. thumbnail = self._html_search_meta(
  475. 'twitter:image:src', webpage, 'thumbnail', fatal=False)
  476. def _find_dimension(target):
  477. w = int_or_none(self._html_search_meta(
  478. 'twitter:%s:width' % target, webpage, fatal=False))
  479. h = int_or_none(self._html_search_meta(
  480. 'twitter:%s:height' % target, webpage, fatal=False))
  481. return w, h
  482. if thumbnail:
  483. thumbnail_w, thumbnail_h = _find_dimension('image')
  484. thumbnails.append({
  485. 'url': thumbnail,
  486. 'width': thumbnail_w,
  487. 'height': thumbnail_h,
  488. })
  489. video_w, video_h = _find_dimension('player')
  490. formats[0].update({
  491. 'width': video_w,
  492. 'height': video_h,
  493. })
  494. return {
  495. 'id': video_id,
  496. 'title': 'Twitter Video',
  497. 'formats': formats,
  498. 'thumbnails': thumbnails,
  499. }