logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

tumblr.py (24113B)


  1. from .common import InfoExtractor
  2. from ..utils import (
  3. ExtractorError,
  4. int_or_none,
  5. traverse_obj,
  6. url_or_none,
  7. urlencode_postdata,
  8. )
  9. class TumblrIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?P<blog_name_1>[^/?#&]+)\.tumblr\.com/(?:post|video|(?P<blog_name_2>[a-zA-Z\d-]+))/(?P<id>[0-9]+)(?:$|[/?#])'
  11. _NETRC_MACHINE = 'tumblr'
  12. _LOGIN_URL = 'https://www.tumblr.com/login'
  13. _OAUTH_URL = 'https://www.tumblr.com/api/v2/oauth2/token'
  14. _TESTS = [{
  15. 'url': 'http://tatianamaslanydaily.tumblr.com/post/54196191430/orphan-black-dvd-extra-behind-the-scenes',
  16. 'md5': '479bb068e5b16462f5176a6828829767',
  17. 'info_dict': {
  18. 'id': '54196191430',
  19. 'ext': 'mp4',
  20. 'title': 'md5:dfac39636969fe6bf1caa2d50405f069',
  21. 'description': 'md5:390ab77358960235b6937ab3b8528956',
  22. 'uploader_id': 'tatianamaslanydaily',
  23. 'uploader_url': 'https://tatianamaslanydaily.tumblr.com/',
  24. 'thumbnail': r're:^https?://.*\.jpg',
  25. 'duration': 127,
  26. 'like_count': int,
  27. 'repost_count': int,
  28. 'age_limit': 0,
  29. 'tags': ['Orphan Black', 'Tatiana Maslany', 'Interview', 'Video', 'OB S1 DVD Extras'],
  30. },
  31. }, {
  32. 'note': 'multiple formats',
  33. 'url': 'https://maskofthedragon.tumblr.com/post/626907179849564160/mona-talking-in-english',
  34. 'md5': 'f43ff8a8861712b6cf0e0c2bd84cfc68',
  35. 'info_dict': {
  36. 'id': '626907179849564160',
  37. 'ext': 'mp4',
  38. 'title': 'Mona\xa0“talking” in\xa0“english”',
  39. 'description': 'md5:082a3a621530cb786ad2b7592a6d9e2c',
  40. 'uploader_id': 'maskofthedragon',
  41. 'uploader_url': 'https://maskofthedragon.tumblr.com/',
  42. 'thumbnail': r're:^https?://.*\.jpg',
  43. 'duration': 7,
  44. 'like_count': int,
  45. 'repost_count': int,
  46. 'age_limit': 0,
  47. 'tags': 'count:19',
  48. },
  49. 'params': {
  50. 'format': 'hd',
  51. },
  52. }, {
  53. 'note': 'non-iframe video (with related posts)',
  54. 'url': 'https://shieldfoss.tumblr.com/post/675519763813908480',
  55. 'md5': '12bdb75661ef443bffe5a4dac1dbf118',
  56. 'info_dict': {
  57. 'id': '675519763813908480',
  58. 'ext': 'mp4',
  59. 'title': 'Shieldfoss',
  60. 'uploader_id': 'nerviovago',
  61. 'uploader_url': 'https://nerviovago.tumblr.com/',
  62. 'thumbnail': r're:^https?://.*\.jpg',
  63. 'like_count': int,
  64. 'repost_count': int,
  65. 'age_limit': 0,
  66. 'tags': [],
  67. },
  68. 'skip': '404',
  69. }, {
  70. 'note': 'dashboard only (original post)',
  71. 'url': 'https://jujanon.tumblr.com/post/159704441298/my-baby-eating',
  72. 'md5': '029f7c91ab386701b211e3d494d2d95e',
  73. 'info_dict': {
  74. 'id': '159704441298',
  75. 'ext': 'mp4',
  76. 'title': 'md5:ba79365861101f4911452728d2950561',
  77. 'description': 'md5:773738196cea76b6996ec71e285bdabc',
  78. 'uploader_id': 'jujanon',
  79. 'uploader_url': 'https://jujanon.tumblr.com/',
  80. 'thumbnail': r're:^https?://.*\.jpg',
  81. 'like_count': int,
  82. 'repost_count': int,
  83. 'age_limit': 0,
  84. 'tags': ['crabs', 'my video', 'my pets'],
  85. },
  86. }, {
  87. 'note': 'dashboard only (reblog)',
  88. 'url': 'https://bartlebyshop.tumblr.com/post/180294460076/duality-of-bird',
  89. 'md5': '04334e7cadb1af680d162912559f51a5',
  90. 'info_dict': {
  91. 'id': '180294460076',
  92. 'ext': 'mp4',
  93. 'title': 'duality of bird',
  94. 'description': 'duality of bird',
  95. 'uploader_id': 'todaysbird',
  96. 'uploader_url': 'https://todaysbird.tumblr.com/',
  97. 'thumbnail': r're:^https?://.*\.jpg',
  98. 'like_count': int,
  99. 'repost_count': int,
  100. 'age_limit': 0,
  101. },
  102. }, {
  103. 'note': 'dashboard only (external)',
  104. 'url': 'https://afloweroutofstone.tumblr.com/post/675661759168823296/the-blues-remembers-everything-the-country-forgot',
  105. 'info_dict': {
  106. 'id': 'q67_fd7b8SU',
  107. 'ext': 'mp4',
  108. 'title': 'The Blues Remembers Everything the Country Forgot',
  109. 'alt_title': 'The Blues Remembers Everything the Country Forgot',
  110. 'description': 'md5:1a6b4097e451216835a24c1023707c79',
  111. 'creator': 'md5:c2239ba15430e87c3b971ba450773272',
  112. 'uploader': 'Moor Mother - Topic',
  113. 'upload_date': '20201223',
  114. 'uploader_id': 'UCxrMtFBRkFvQJ_vVM4il08w',
  115. 'uploader_url': 'http://www.youtube.com/channel/UCxrMtFBRkFvQJ_vVM4il08w',
  116. 'thumbnail': r're:^https?://i.ytimg.com/.*',
  117. 'channel': 'Moor Mother',
  118. 'channel_id': 'UCxrMtFBRkFvQJ_vVM4il08w',
  119. 'channel_url': 'https://www.youtube.com/channel/UCxrMtFBRkFvQJ_vVM4il08w',
  120. 'channel_follower_count': int,
  121. 'duration': 181,
  122. 'view_count': int,
  123. 'like_count': int,
  124. 'age_limit': 0,
  125. 'categories': ['Music'],
  126. 'tags': 'count:7',
  127. 'live_status': 'not_live',
  128. 'playable_in_embed': True,
  129. 'availability': 'public',
  130. 'track': 'The Blues Remembers Everything the Country Forgot',
  131. 'artist': 'md5:c2239ba15430e87c3b971ba450773272',
  132. 'album': 'Brass',
  133. 'release_year': 2020,
  134. },
  135. 'add_ie': ['Youtube'],
  136. 'skip': 'Video Unavailable',
  137. }, {
  138. 'url': 'https://prozdvoices.tumblr.com/post/673201091169681408/what-recording-voice-acting-sounds-like',
  139. 'md5': 'cb8328a6723c30556cef59e370202918',
  140. 'info_dict': {
  141. 'id': 'eomhW5MLGWA',
  142. 'ext': 'mp4',
  143. 'title': 'what recording voice acting sounds like',
  144. 'description': 'md5:1da3faa22d0e0b1d8b50216c284ee798',
  145. 'uploader': 'ProZD',
  146. 'upload_date': '20220112',
  147. 'uploader_id': '@ProZD',
  148. 'uploader_url': 'https://www.youtube.com/@ProZD',
  149. 'thumbnail': r're:^https?://i.ytimg.com/.*',
  150. 'channel': 'ProZD',
  151. 'channel_id': 'UC6MFZAOHXlKK1FI7V0XQVeA',
  152. 'channel_url': 'https://www.youtube.com/channel/UC6MFZAOHXlKK1FI7V0XQVeA',
  153. 'channel_follower_count': int,
  154. 'duration': 20,
  155. 'view_count': int,
  156. 'like_count': int,
  157. 'age_limit': 0,
  158. 'categories': ['Film & Animation'],
  159. 'tags': [],
  160. 'live_status': 'not_live',
  161. 'playable_in_embed': True,
  162. 'availability': 'public',
  163. 'heatmap': 'count:100',
  164. 'channel_is_verified': True,
  165. 'timestamp': 1642014562,
  166. 'comment_count': int,
  167. },
  168. 'add_ie': ['Youtube'],
  169. }, {
  170. 'url': 'https://dominustempori.tumblr.com/post/673572712813297664/youtubes-all-right-for-some-pretty-cool',
  171. 'md5': '203e9eb8077e3f45bfaeb4c86c1467b8',
  172. 'info_dict': {
  173. 'id': '87816359',
  174. 'ext': 'mp4',
  175. 'title': 'Harold Ramis',
  176. 'description': 'md5:c99882405fcca0b1d348ad093f8f1672',
  177. 'uploader': 'Resolution Productions Group',
  178. 'uploader_id': 'resolutionproductions',
  179. 'uploader_url': 'https://vimeo.com/resolutionproductions',
  180. 'upload_date': '20140227',
  181. 'thumbnail': r're:^https?://i.vimeocdn.com/video/.*',
  182. 'timestamp': 1393541719,
  183. 'duration': 291,
  184. 'comment_count': int,
  185. 'like_count': int,
  186. 'release_timestamp': 1393541719,
  187. 'release_date': '20140227',
  188. },
  189. 'add_ie': ['Vimeo'],
  190. }, {
  191. 'url': 'https://silami.tumblr.com/post/84250043974/my-bad-river-flows-in-you-impression-on-maschine',
  192. 'md5': '3c92d7c3d867f14ccbeefa2119022277',
  193. 'info_dict': {
  194. 'id': 'nYtvtTPuTl',
  195. 'ext': 'mp4',
  196. 'title': 'Video by silbulterman',
  197. 'description': '#maschine',
  198. 'uploader_id': '242859024',
  199. 'thumbnail': r're:^https?://.*\.jpg',
  200. 'timestamp': 1398801174,
  201. 'like_count': int,
  202. 'uploader': 'Sil',
  203. 'channel': 'silbulterman',
  204. 'comment_count': int,
  205. 'upload_date': '20140429',
  206. },
  207. 'add_ie': ['Instagram'],
  208. }, {
  209. 'note': 'new url scheme',
  210. 'url': 'https://www.tumblr.com/autumnsister/765162750456578048?source=share',
  211. 'info_dict': {
  212. 'id': '765162750456578048',
  213. 'ext': 'mp4',
  214. 'uploader_url': 'https://autumnsister.tumblr.com/',
  215. 'tags': ['autumn', 'food', 'curators on tumblr'],
  216. 'like_count': int,
  217. 'thumbnail': 'https://64.media.tumblr.com/tumblr_sklad89N3x1ygquow_frame1.jpg',
  218. 'title': '🪹',
  219. 'uploader_id': 'autumnsister',
  220. 'repost_count': int,
  221. 'age_limit': 0,
  222. },
  223. }, {
  224. 'note': 'bandcamp album embed',
  225. 'url': 'https://patricia-taxxon.tumblr.com/post/704473755725004800/patricia-taxxon-agnes-hilda-patricia-taxxon',
  226. 'info_dict': {
  227. 'id': 'agnes-hilda',
  228. 'title': 'Agnes & Hilda',
  229. 'description': 'The inexplicable joy of an artist. Wash paws after listening.',
  230. 'uploader_id': 'patriciataxxon',
  231. },
  232. 'playlist_count': 8,
  233. }, {
  234. 'note': 'bandcamp track embeds (many)',
  235. 'url': 'https://www.tumblr.com/felixcosm/730460905855467520/if-youre-looking-for-new-music-to-write-or',
  236. 'info_dict': {
  237. 'id': '730460905855467520',
  238. 'uploader_id': 'felixcosm',
  239. 'repost_count': int,
  240. 'tags': 'count:15',
  241. 'description': 'md5:2eb3482a3c6987280cbefb6839068f32',
  242. 'like_count': int,
  243. 'age_limit': 0,
  244. 'title': 'If you\'re looking for new music to write or imagine scenerios to: STOP. This is for you.',
  245. 'uploader_url': 'https://felixcosm.tumblr.com/',
  246. },
  247. 'playlist_count': 10,
  248. }, {
  249. 'note': 'soundcloud track embed',
  250. 'url': 'https://silverfoxstole.tumblr.com/post/765305403763556352/jamie-robertson-doctor-who-8th-doctor',
  251. 'info_dict': {
  252. 'id': '1218136399',
  253. 'ext': 'opus',
  254. 'comment_count': int,
  255. 'genres': [],
  256. 'repost_count': int,
  257. 'uploader': 'Jamie Robertson',
  258. 'title': 'Doctor Who - 8th doctor - Stranded Theme never released and used.',
  259. 'duration': 46.106,
  260. 'uploader_id': '2731064',
  261. 'thumbnail': 'https://i1.sndcdn.com/artworks-MVgcPm5jN42isC5M-6Dz22w-original.jpg',
  262. 'timestamp': 1645181261,
  263. 'uploader_url': 'https://soundcloud.com/jamierobertson',
  264. 'view_count': int,
  265. 'upload_date': '20220218',
  266. 'description': 'md5:ab924dd9994d0a7d64d6d31bf2af4625',
  267. 'license': 'all-rights-reserved',
  268. 'like_count': int,
  269. },
  270. }, {
  271. 'note': 'soundcloud set embed',
  272. 'url': 'https://www.tumblr.com/beyourselfchulanmaria/703505323122638848/chu-lan-maria-the-playlist-%E5%BF%83%E7%9A%84%E5%91%BC%E5%96%9A-call-of-the',
  273. 'info_dict': {
  274. 'id': '691222680',
  275. 'title': '心的呼喚 Call of the heart I',
  276. 'description': 'md5:25952a8d178a3aa55e40fcbb646a38c3',
  277. },
  278. 'playlist_mincount': 19,
  279. }, {
  280. 'note': 'dailymotion video embed',
  281. 'url': 'https://www.tumblr.com/funvibecentral/759390024460632064',
  282. 'info_dict': {
  283. 'id': 'x94cnnk',
  284. 'ext': 'mp4',
  285. 'description': 'Funny dailymotion shorts.\n#funny #fun#comedy #romantic #exciting',
  286. 'uploader': 'FunVibe Central',
  287. 'like_count': int,
  288. 'view_count': int,
  289. 'timestamp': 1724210553,
  290. 'title': 'Woman watching other Woman',
  291. 'tags': [],
  292. 'upload_date': '20240821',
  293. 'age_limit': 0,
  294. 'uploader_id': 'x32m6ye',
  295. 'duration': 20,
  296. 'thumbnail': r're:https://(?:s[12]\.)dmcdn\.net/v/Wtqh01cnxKNXLG1N8/x1080',
  297. },
  298. }, {
  299. 'note': 'tiktok video embed',
  300. 'url': 'https://fansofcolor.tumblr.com/post/660637918605475840/blockquote-class-tiktok-embed',
  301. 'info_dict': {
  302. 'id': '7000937272010935558',
  303. 'ext': 'mp4',
  304. 'artists': ['Alicia Dreaming'],
  305. 'like_count': int,
  306. 'repost_count': int,
  307. 'thumbnail': r're:^https?://[\w\/\.\-]+(~[\w\-]+\.image)?',
  308. 'channel_id': 'MS4wLjABAAAAsJohwz_dU4KfAOc61cbGDAZ46-5hg2ANTXVQlRe1ipDhpX08PywR3PPiple1NTAo',
  309. 'uploader': 'aliciadreaming',
  310. 'description': 'huge casting news Greyworm will be #louisdulac #racebending #interviewwiththevampire',
  311. 'title': 'huge casting news Greyworm will be #louisdulac #racebending #interviewwiththevampire',
  312. 'channel_url': 'https://www.tiktok.com/@MS4wLjABAAAAsJohwz_dU4KfAOc61cbGDAZ46-5hg2ANTXVQlRe1ipDhpX08PywR3PPiple1NTAo',
  313. 'uploader_id': '7000478462196990982',
  314. 'uploader_url': 'https://www.tiktok.com/@aliciadreaming',
  315. 'timestamp': 1630032733,
  316. 'channel': 'Alicia Dreaming',
  317. 'track': 'original sound',
  318. 'upload_date': '20210827',
  319. 'view_count': int,
  320. 'comment_count': int,
  321. 'duration': 59,
  322. },
  323. }, {
  324. 'note': 'tumblr video AND youtube embed',
  325. 'url': 'https://www.tumblr.com/anyaboz/765332564457209856/my-music-video-for-selkie-by-nobodys-wolf-child',
  326. 'info_dict': {
  327. 'id': '765332564457209856',
  328. 'uploader_id': 'anyaboz',
  329. 'repost_count': int,
  330. 'age_limit': 0,
  331. 'uploader_url': 'https://anyaboz.tumblr.com/',
  332. 'description': 'md5:9a129cf6ce9d87a80ffd3c6dedd4d1e6',
  333. 'like_count': int,
  334. 'title': 'md5:b18a2ac9387681d20303e485db85c1b5',
  335. 'tags': ['music video', 'nobodys wolf child', 'selkie', 'Stop Motion Animation', 'stop Motion', 'room guardians', 'Youtube'],
  336. },
  337. 'playlist_count': 2,
  338. }, {
  339. # twitch_live provider - error when linked account is not live
  340. 'url': 'https://www.tumblr.com/anarcho-skamunist/722224493650722816/hollow-knight-stream-right-now-going-to-fight',
  341. 'only_matching': True,
  342. }]
  343. _providers = {
  344. 'instagram': 'Instagram',
  345. 'vimeo': 'Vimeo',
  346. 'youtube': 'Youtube',
  347. 'dailymotion': 'Dailymotion',
  348. 'tiktok': 'TikTok',
  349. 'twitch_live': 'TwitchStream',
  350. 'bandcamp': None,
  351. 'soundcloud': None,
  352. }
  353. # known not to be supported
  354. _unsupported_providers = {
  355. # seems like podcasts can't be embedded
  356. 'spotify',
  357. }
  358. _ACCESS_TOKEN = None
  359. def _initialize_pre_login(self):
  360. login_page = self._download_webpage(
  361. self._LOGIN_URL, None, 'Downloading login page', fatal=False)
  362. if login_page:
  363. self._ACCESS_TOKEN = self._search_regex(
  364. r'"API_TOKEN":\s*"(\w+)"', login_page, 'API access token', fatal=False)
  365. if not self._ACCESS_TOKEN:
  366. self.report_warning('Failed to get access token; metadata will be missing and some videos may not work')
  367. def _perform_login(self, username, password):
  368. if not self._ACCESS_TOKEN:
  369. return
  370. data = {
  371. 'password': password,
  372. 'grant_type': 'password',
  373. 'username': username,
  374. }
  375. if self.get_param('twofactor'):
  376. data['tfa_token'] = self.get_param('twofactor')
  377. def _call_login():
  378. return self._download_json(
  379. self._OAUTH_URL, None, 'Logging in',
  380. data=urlencode_postdata(data),
  381. headers={
  382. 'Content-Type': 'application/x-www-form-urlencoded',
  383. 'Authorization': f'Bearer {self._ACCESS_TOKEN}',
  384. },
  385. errnote='Login failed', fatal=False,
  386. expected_status=lambda s: 400 <= s < 500)
  387. response = _call_login()
  388. if traverse_obj(response, 'error') == 'tfa_required':
  389. data['tfa_token'] = self._get_tfa_info()
  390. response = _call_login()
  391. if traverse_obj(response, 'error'):
  392. raise ExtractorError(
  393. f'API returned error {": ".join(traverse_obj(response, (("error", "error_description"), {str})))}')
  394. def _real_extract(self, url):
  395. blog_1, blog_2, video_id = self._match_valid_url(url).groups()
  396. blog = blog_2 or blog_1
  397. url = f'http://{blog}.tumblr.com/post/{video_id}'
  398. webpage, urlh = self._download_webpage_handle(
  399. url, video_id, headers={'User-Agent': 'WhatsApp/2.0'}) # whatsapp ua bypasses problems
  400. redirect_url = urlh.url
  401. api_only = bool(self._search_regex(
  402. r'(tumblr.com|^)/(safe-mode|login_required|blog/view)',
  403. redirect_url, 'redirect', default=None))
  404. if api_only and not self._ACCESS_TOKEN:
  405. raise ExtractorError('Cannot get data for dashboard-only post without access token')
  406. post_json = {}
  407. if self._ACCESS_TOKEN:
  408. post_json = traverse_obj(
  409. self._download_json(
  410. f'https://www.tumblr.com/api/v2/blog/{blog}/posts/{video_id}/permalink',
  411. video_id, headers={'Authorization': f'Bearer {self._ACCESS_TOKEN}'}, fatal=False),
  412. ('response', 'timeline', 'elements', 0, {dict})) or {}
  413. content_json = traverse_obj(post_json, ((('trail', 0), None), 'content', ..., {dict}))
  414. # the url we're extracting from might be an original post or it might be a reblog.
  415. # if it's a reblog, og:description will be the reblogger's comment, not the uploader's.
  416. # content_json is always the op, so if it exists but has no text, there's no description
  417. if content_json:
  418. description = '\n\n'.join(
  419. item.get('text') for item in content_json if item.get('type') == 'text') or None
  420. else:
  421. description = self._og_search_description(webpage, default=None)
  422. uploader_id = traverse_obj(post_json, 'reblogged_root_name', 'blog_name')
  423. info_dict = {
  424. 'id': video_id,
  425. 'title': post_json.get('summary') or (blog if api_only else self._html_search_regex(
  426. r'(?s)<title>(?P<title>.*?)(?: \| Tumblr)?</title>', webpage, 'title', default=blog)),
  427. 'description': description,
  428. 'uploader_id': uploader_id,
  429. 'uploader_url': f'https://{uploader_id}.tumblr.com/' if uploader_id else None,
  430. **traverse_obj(post_json, {
  431. 'like_count': ('like_count', {int_or_none}),
  432. 'repost_count': ('reblog_count', {int_or_none}),
  433. 'tags': ('tags', ..., {str}),
  434. }),
  435. 'age_limit': {True: 18, False: 0}.get(post_json.get('is_nsfw')),
  436. }
  437. # for tumblr's own video hosting
  438. fallback_format = None
  439. formats = []
  440. video_url = self._og_search_video_url(webpage, default=None)
  441. # for external video hosts
  442. entries = []
  443. ignored_providers = set()
  444. unknown_providers = set()
  445. for video_json in traverse_obj(content_json, lambda _, v: v['type'] in ('video', 'audio')):
  446. media_json = video_json.get('media') or {}
  447. if api_only and not media_json.get('url') and not video_json.get('url'):
  448. raise ExtractorError('Failed to find video data for dashboard-only post')
  449. provider = video_json.get('provider')
  450. if provider in ('tumblr', None):
  451. fallback_format = {
  452. 'url': media_json.get('url') or video_url,
  453. 'width': int_or_none(
  454. media_json.get('width') or self._og_search_property('video:width', webpage, default=None)),
  455. 'height': int_or_none(
  456. media_json.get('height') or self._og_search_property('video:height', webpage, default=None)),
  457. }
  458. continue
  459. elif provider in self._unsupported_providers:
  460. ignored_providers.add(provider)
  461. continue
  462. elif provider and provider not in self._providers:
  463. unknown_providers.add(provider)
  464. if video_json.get('url'):
  465. # external video host
  466. entries.append(self.url_result(
  467. video_json['url'], self._providers.get(provider)))
  468. duration = None
  469. # iframes can supply duration and sometimes additional formats, so check for one
  470. iframe_url = self._search_regex(
  471. fr'src=\'(https?://www\.tumblr\.com/video/{blog}/{video_id}/[^\']+)\'',
  472. webpage, 'iframe url', default=None)
  473. if iframe_url:
  474. iframe = self._download_webpage(
  475. iframe_url, video_id, 'Downloading iframe page',
  476. headers={'Referer': redirect_url})
  477. options = self._parse_json(
  478. self._search_regex(
  479. r'data-crt-options=(["\'])(?P<options>.+?)\1', iframe,
  480. 'hd video url', default='', group='options'),
  481. video_id, fatal=False)
  482. if options:
  483. duration = int_or_none(options.get('duration'))
  484. hd_url = options.get('hdUrl')
  485. if hd_url:
  486. # there are multiple formats; extract them
  487. # ignore other sources of width/height data as they may be wrong
  488. sources = []
  489. sd_url = self._search_regex(
  490. r'<source[^>]+src=(["\'])(?P<url>.+?)\1', iframe,
  491. 'sd video url', default=None, group='url')
  492. if sd_url:
  493. sources.append((sd_url, 'sd'))
  494. sources.append((hd_url, 'hd'))
  495. formats = [{
  496. 'url': video_url,
  497. 'format_id': format_id,
  498. 'height': int_or_none(self._search_regex(
  499. r'_(\d+)\.\w+$', video_url, 'height', default=None)),
  500. 'quality': quality,
  501. } for quality, (video_url, format_id) in enumerate(sources)]
  502. if not formats and fallback_format:
  503. formats.append(fallback_format)
  504. if formats:
  505. # tumblr's own video is always above embeds
  506. entries.insert(0, {
  507. **info_dict,
  508. 'formats': formats,
  509. 'duration': duration,
  510. 'thumbnail': (traverse_obj(video_json, ('poster', 0, 'url', {url_or_none}))
  511. or self._og_search_thumbnail(webpage, default=None)),
  512. })
  513. if ignored_providers:
  514. if not entries:
  515. raise ExtractorError(f'None of embed providers are supported: {", ".join(ignored_providers)!s}', video_id=video_id, expected=True)
  516. else:
  517. self.report_warning(f'Skipped embeds from unsupported providers: {", ".join(ignored_providers)!s}', video_id)
  518. if unknown_providers:
  519. self.report_warning(f'Unrecognized providers, please report: {", ".join(unknown_providers)!s}', video_id)
  520. if not entries:
  521. self.raise_no_formats('No video could be found in this post', expected=True, video_id=video_id)
  522. if len(entries) == 1:
  523. return {
  524. **info_dict,
  525. **entries[0],
  526. }
  527. return {
  528. **info_dict,
  529. '_type': 'playlist',
  530. 'entries': entries,
  531. }