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.

1141 lines
45 KiB

10 years ago
11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
10 years ago
  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import os
  4. import re
  5. from .common import InfoExtractor
  6. from .youtube import YoutubeIE
  7. from ..compat import (
  8. compat_urllib_parse,
  9. compat_urlparse,
  10. compat_xml_parse_error,
  11. )
  12. from ..utils import (
  13. determine_ext,
  14. ExtractorError,
  15. float_or_none,
  16. HEADRequest,
  17. is_html,
  18. orderedSet,
  19. parse_xml,
  20. smuggle_url,
  21. unescapeHTML,
  22. unified_strdate,
  23. unsmuggle_url,
  24. UnsupportedError,
  25. url_basename,
  26. )
  27. from .brightcove import BrightcoveIE
  28. from .ooyala import OoyalaIE
  29. from .rutv import RUTVIE
  30. from .smotri import SmotriIE
  31. from .condenast import CondeNastIE
  32. class GenericIE(InfoExtractor):
  33. IE_DESC = 'Generic downloader that works on some sites'
  34. _VALID_URL = r'.*'
  35. IE_NAME = 'generic'
  36. _TESTS = [
  37. {
  38. 'url': 'http://www.hodiho.fr/2013/02/regis-plante-sa-jeep.html',
  39. 'md5': '85b90ccc9d73b4acd9138d3af4c27f89',
  40. 'info_dict': {
  41. 'id': '13601338388002',
  42. 'ext': 'mp4',
  43. 'uploader': 'www.hodiho.fr',
  44. 'title': 'R\u00e9gis plante sa Jeep',
  45. }
  46. },
  47. # bandcamp page with custom domain
  48. {
  49. 'add_ie': ['Bandcamp'],
  50. 'url': 'http://bronyrock.com/track/the-pony-mash',
  51. 'info_dict': {
  52. 'id': '3235767654',
  53. 'ext': 'mp3',
  54. 'title': 'The Pony Mash',
  55. 'uploader': 'M_Pallante',
  56. },
  57. 'skip': 'There is a limit of 200 free downloads / month for the test song',
  58. },
  59. # embedded brightcove video
  60. # it also tests brightcove videos that need to set the 'Referer' in the
  61. # http requests
  62. {
  63. 'add_ie': ['Brightcove'],
  64. 'url': 'http://www.bfmtv.com/video/bfmbusiness/cours-bourse/cours-bourse-l-analyse-technique-154522/',
  65. 'info_dict': {
  66. 'id': '2765128793001',
  67. 'ext': 'mp4',
  68. 'title': 'Le cours de bourse : l’analyse technique',
  69. 'description': 'md5:7e9ad046e968cb2d1114004aba466fd9',
  70. 'uploader': 'BFM BUSINESS',
  71. },
  72. 'params': {
  73. 'skip_download': True,
  74. },
  75. },
  76. {
  77. # https://github.com/rg3/youtube-dl/issues/2253
  78. 'url': 'http://bcove.me/i6nfkrc3',
  79. 'md5': '0ba9446db037002366bab3b3eb30c88c',
  80. 'info_dict': {
  81. 'id': '3101154703001',
  82. 'ext': 'mp4',
  83. 'title': 'Still no power',
  84. 'uploader': 'thestar.com',
  85. 'description': 'Mississauga resident David Farmer is still out of power as a result of the ice storm a month ago. To keep the house warm, Farmer cuts wood from his property for a wood burning stove downstairs.',
  86. },
  87. 'add_ie': ['Brightcove'],
  88. },
  89. {
  90. 'url': 'http://www.championat.com/video/football/v/87/87499.html',
  91. 'md5': 'fb973ecf6e4a78a67453647444222983',
  92. 'info_dict': {
  93. 'id': '3414141473001',
  94. 'ext': 'mp4',
  95. 'title': 'Видео. Удаление Дзагоева (ЦСКА)',
  96. 'description': 'Онлайн-трансляция матча ЦСКА - "Волга"',
  97. 'uploader': 'Championat',
  98. },
  99. },
  100. {
  101. # https://github.com/rg3/youtube-dl/issues/3541
  102. 'add_ie': ['Brightcove'],
  103. 'url': 'http://www.kijk.nl/sbs6/leermijvrouwenkennen/videos/jqMiXKAYan2S/aflevering-1',
  104. 'info_dict': {
  105. 'id': '3866516442001',
  106. 'ext': 'mp4',
  107. 'title': 'Leer mij vrouwen kennen: Aflevering 1',
  108. 'description': 'Leer mij vrouwen kennen: Aflevering 1',
  109. 'uploader': 'SBS Broadcasting',
  110. },
  111. 'skip': 'Restricted to Netherlands',
  112. 'params': {
  113. 'skip_download': True, # m3u8 download
  114. },
  115. },
  116. # Direct link to a video
  117. {
  118. 'url': 'http://media.w3.org/2010/05/sintel/trailer.mp4',
  119. 'md5': '67d406c2bcb6af27fa886f31aa934bbe',
  120. 'info_dict': {
  121. 'id': 'trailer',
  122. 'ext': 'mp4',
  123. 'title': 'trailer',
  124. 'upload_date': '20100513',
  125. }
  126. },
  127. # ooyala video
  128. {
  129. 'url': 'http://www.rollingstone.com/music/videos/norwegian-dj-cashmere-cat-goes-spartan-on-with-me-premiere-20131219',
  130. 'md5': '166dd577b433b4d4ebfee10b0824d8ff',
  131. 'info_dict': {
  132. 'id': 'BwY2RxaTrTkslxOfcan0UCf0YqyvWysJ',
  133. 'ext': 'mp4',
  134. 'title': '2cc213299525360.mov', # that's what we get
  135. },
  136. 'add_ie': ['Ooyala'],
  137. },
  138. # google redirect
  139. {
  140. 'url': 'http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CCUQtwIwAA&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DcmQHVoWB5FY&ei=F-sNU-LLCaXk4QT52ICQBQ&usg=AFQjCNEw4hL29zgOohLXvpJ-Bdh2bils1Q&bvm=bv.61965928,d.bGE',
  141. 'info_dict': {
  142. 'id': 'cmQHVoWB5FY',
  143. 'ext': 'mp4',
  144. 'upload_date': '20130224',
  145. 'uploader_id': 'TheVerge',
  146. 'description': 're:^Chris Ziegler takes a look at the\.*',
  147. 'uploader': 'The Verge',
  148. 'title': 'First Firefox OS phones side-by-side',
  149. },
  150. 'params': {
  151. 'skip_download': False,
  152. }
  153. },
  154. # embed.ly video
  155. {
  156. 'url': 'http://www.tested.com/science/weird/460206-tested-grinding-coffee-2000-frames-second/',
  157. 'info_dict': {
  158. 'id': '9ODmcdjQcHQ',
  159. 'ext': 'mp4',
  160. 'title': 'Tested: Grinding Coffee at 2000 Frames Per Second',
  161. 'upload_date': '20140225',
  162. 'description': 'md5:06a40fbf30b220468f1e0957c0f558ff',
  163. 'uploader': 'Tested',
  164. 'uploader_id': 'testedcom',
  165. },
  166. # No need to test YoutubeIE here
  167. 'params': {
  168. 'skip_download': True,
  169. },
  170. },
  171. # funnyordie embed
  172. {
  173. 'url': 'http://www.theguardian.com/world/2014/mar/11/obama-zach-galifianakis-between-two-ferns',
  174. 'info_dict': {
  175. 'id': '18e820ec3f',
  176. 'ext': 'mp4',
  177. 'title': 'Between Two Ferns with Zach Galifianakis: President Barack Obama',
  178. 'description': 'Episode 18: President Barack Obama sits down with Zach Galifianakis for his most memorable interview yet.',
  179. },
  180. },
  181. # BBC iPlayer embeds
  182. {
  183. 'url': 'http://www.bbc.co.uk/blogs/adamcurtis/posts/BUGGER',
  184. 'info_dict': {
  185. 'title': 'BBC - Blogs - Adam Curtis - BUGGER',
  186. },
  187. 'playlist_mincount': 18,
  188. },
  189. # RUTV embed
  190. {
  191. 'url': 'http://www.rg.ru/2014/03/15/reg-dfo/anklav-anons.html',
  192. 'info_dict': {
  193. 'id': '776940',
  194. 'ext': 'mp4',
  195. 'title': 'Охотское море стало целиком российским',
  196. 'description': 'md5:5ed62483b14663e2a95ebbe115eb8f43',
  197. },
  198. 'params': {
  199. # m3u8 download
  200. 'skip_download': True,
  201. },
  202. },
  203. # Embedded TED video
  204. {
  205. 'url': 'http://en.support.wordpress.com/videos/ted-talks/',
  206. 'md5': '65fdff94098e4a607385a60c5177c638',
  207. 'info_dict': {
  208. 'id': '1969',
  209. 'ext': 'mp4',
  210. 'title': 'Hidden miracles of the natural world',
  211. 'uploader': 'Louie Schwartzberg',
  212. 'description': 'md5:8145d19d320ff3e52f28401f4c4283b9',
  213. }
  214. },
  215. # Embeded Ustream video
  216. {
  217. 'url': 'http://www.american.edu/spa/pti/nsa-privacy-janus-2014.cfm',
  218. 'md5': '27b99cdb639c9b12a79bca876a073417',
  219. 'info_dict': {
  220. 'id': '45734260',
  221. 'ext': 'flv',
  222. 'uploader': 'AU SPA: The NSA and Privacy',
  223. 'title': 'NSA and Privacy Forum Debate featuring General Hayden and Barton Gellman'
  224. }
  225. },
  226. # nowvideo embed hidden behind percent encoding
  227. {
  228. 'url': 'http://www.waoanime.tv/the-super-dimension-fortress-macross-episode-1/',
  229. 'md5': '2baf4ddd70f697d94b1c18cf796d5107',
  230. 'info_dict': {
  231. 'id': '06e53103ca9aa',
  232. 'ext': 'flv',
  233. 'title': 'Macross Episode 001 Watch Macross Episode 001 onl',
  234. 'description': 'No description',
  235. },
  236. },
  237. # arte embed
  238. {
  239. 'url': 'http://www.tv-replay.fr/redirection/20-03-14/x-enius-arte-10753389.html',
  240. 'md5': '7653032cbb25bf6c80d80f217055fa43',
  241. 'info_dict': {
  242. 'id': '048195-004_PLUS7-F',
  243. 'ext': 'flv',
  244. 'title': 'X:enius',
  245. 'description': 'md5:d5fdf32ef6613cdbfd516ae658abf168',
  246. 'upload_date': '20140320',
  247. },
  248. 'params': {
  249. 'skip_download': 'Requires rtmpdump'
  250. }
  251. },
  252. # Condé Nast embed
  253. {
  254. 'url': 'http://www.wired.com/2014/04/honda-asimo/',
  255. 'md5': 'ba0dfe966fa007657bd1443ee672db0f',
  256. 'info_dict': {
  257. 'id': '53501be369702d3275860000',
  258. 'ext': 'mp4',
  259. 'title': 'Honda’s New Asimo Robot Is More Human Than Ever',
  260. }
  261. },
  262. # Dailymotion embed
  263. {
  264. 'url': 'http://www.spi0n.com/zap-spi0n-com-n216/',
  265. 'md5': '441aeeb82eb72c422c7f14ec533999cd',
  266. 'info_dict': {
  267. 'id': 'k2mm4bCdJ6CQ2i7c8o2',
  268. 'ext': 'mp4',
  269. 'title': 'Le Zap de Spi0n n°216 - Zapping du Web',
  270. 'uploader': 'Spi0n',
  271. },
  272. 'add_ie': ['Dailymotion'],
  273. },
  274. # YouTube embed
  275. {
  276. 'url': 'http://www.badzine.de/ansicht/datum/2014/06/09/so-funktioniert-die-neue-englische-badminton-liga.html',
  277. 'info_dict': {
  278. 'id': 'FXRb4ykk4S0',
  279. 'ext': 'mp4',
  280. 'title': 'The NBL Auction 2014',
  281. 'uploader': 'BADMINTON England',
  282. 'uploader_id': 'BADMINTONEvents',
  283. 'upload_date': '20140603',
  284. 'description': 'md5:9ef128a69f1e262a700ed83edb163a73',
  285. },
  286. 'add_ie': ['Youtube'],
  287. 'params': {
  288. 'skip_download': True,
  289. }
  290. },
  291. # MTVSercices embed
  292. {
  293. 'url': 'http://www.gametrailers.com/news-post/76093/north-america-europe-is-getting-that-mario-kart-8-mercedes-dlc-too',
  294. 'md5': '35727f82f58c76d996fc188f9755b0d5',
  295. 'info_dict': {
  296. 'id': '0306a69b-8adf-4fb5-aace-75f8e8cbfca9',
  297. 'ext': 'mp4',
  298. 'title': 'Review',
  299. 'description': 'Mario\'s life in the fast lane has never looked so good.',
  300. },
  301. },
  302. # YouTube embed via <data-embed-url="">
  303. {
  304. 'url': 'https://play.google.com/store/apps/details?id=com.gameloft.android.ANMP.GloftA8HM',
  305. 'info_dict': {
  306. 'id': '4vAffPZIT44',
  307. 'ext': 'mp4',
  308. 'title': 'Asphalt 8: Airborne - Update - Welcome to Dubai!',
  309. 'uploader': 'Gameloft',
  310. 'uploader_id': 'gameloft',
  311. 'upload_date': '20140828',
  312. 'description': 'md5:c80da9ed3d83ae6d1876c834de03e1c4',
  313. },
  314. 'params': {
  315. 'skip_download': True,
  316. }
  317. },
  318. # Camtasia studio
  319. {
  320. 'url': 'http://www.ll.mit.edu/workshops/education/videocourses/antennas/lecture1/video/',
  321. 'playlist': [{
  322. 'md5': '0c5e352edabf715d762b0ad4e6d9ee67',
  323. 'info_dict': {
  324. 'id': 'Fenn-AA_PA_Radar_Course_Lecture_1c_Final',
  325. 'title': 'Fenn-AA_PA_Radar_Course_Lecture_1c_Final - video1',
  326. 'ext': 'flv',
  327. 'duration': 2235.90,
  328. }
  329. }, {
  330. 'md5': '10e4bb3aaca9fd630e273ff92d9f3c63',
  331. 'info_dict': {
  332. 'id': 'Fenn-AA_PA_Radar_Course_Lecture_1c_Final_PIP',
  333. 'title': 'Fenn-AA_PA_Radar_Course_Lecture_1c_Final - pip',
  334. 'ext': 'flv',
  335. 'duration': 2235.93,
  336. }
  337. }],
  338. 'info_dict': {
  339. 'title': 'Fenn-AA_PA_Radar_Course_Lecture_1c_Final',
  340. }
  341. },
  342. # Flowplayer
  343. {
  344. 'url': 'http://www.handjobhub.com/video/busty-blonde-siri-tit-fuck-while-wank-6313.html',
  345. 'md5': '9d65602bf31c6e20014319c7d07fba27',
  346. 'info_dict': {
  347. 'id': '5123ea6d5e5a7',
  348. 'ext': 'mp4',
  349. 'age_limit': 18,
  350. 'uploader': 'www.handjobhub.com',
  351. 'title': 'Busty Blonde Siri Tit Fuck While Wank at HandjobHub.com',
  352. }
  353. },
  354. # RSS feed
  355. {
  356. 'url': 'http://phihag.de/2014/youtube-dl/rss2.xml',
  357. 'info_dict': {
  358. 'id': 'http://phihag.de/2014/youtube-dl/rss2.xml',
  359. 'title': 'Zero Punctuation',
  360. 'description': 're:.*groundbreaking video review series.*'
  361. },
  362. 'playlist_mincount': 11,
  363. },
  364. # Multiple brightcove videos
  365. # https://github.com/rg3/youtube-dl/issues/2283
  366. {
  367. 'url': 'http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html',
  368. 'info_dict': {
  369. 'id': 'always-never',
  370. 'title': 'Always / Never - The New Yorker',
  371. },
  372. 'playlist_count': 3,
  373. 'params': {
  374. 'extract_flat': False,
  375. 'skip_download': True,
  376. }
  377. },
  378. # MLB embed
  379. {
  380. 'url': 'http://umpire-empire.com/index.php/topic/58125-laz-decides-no-thats-low/',
  381. 'md5': '96f09a37e44da40dd083e12d9a683327',
  382. 'info_dict': {
  383. 'id': '33322633',
  384. 'ext': 'mp4',
  385. 'title': 'Ump changes call to ball',
  386. 'description': 'md5:71c11215384298a172a6dcb4c2e20685',
  387. 'duration': 48,
  388. 'timestamp': 1401537900,
  389. 'upload_date': '20140531',
  390. 'thumbnail': 're:^https?://.*\.jpg$',
  391. },
  392. },
  393. # Wistia embed
  394. {
  395. 'url': 'http://education-portal.com/academy/lesson/north-american-exploration-failed-colonies-of-spain-france-england.html#lesson',
  396. 'md5': '8788b683c777a5cf25621eaf286d0c23',
  397. 'info_dict': {
  398. 'id': '1cfaf6b7ea',
  399. 'ext': 'mov',
  400. 'title': 'md5:51364a8d3d009997ba99656004b5e20d',
  401. 'duration': 643.0,
  402. 'filesize': 182808282,
  403. 'uploader': 'education-portal.com',
  404. },
  405. },
  406. {
  407. 'url': 'http://thoughtworks.wistia.com/medias/uxjb0lwrcz',
  408. 'md5': 'baf49c2baa8a7de5f3fc145a8506dcd4',
  409. 'info_dict': {
  410. 'id': 'uxjb0lwrcz',
  411. 'ext': 'mp4',
  412. 'title': 'Conversation about Hexagonal Rails Part 1 - ThoughtWorks',
  413. 'duration': 1715.0,
  414. 'uploader': 'thoughtworks.wistia.com',
  415. },
  416. },
  417. # Direct download with broken HEAD
  418. {
  419. 'url': 'http://ai-radio.org:8000/radio.opus',
  420. 'info_dict': {
  421. 'id': 'radio',
  422. 'ext': 'opus',
  423. 'title': 'radio',
  424. },
  425. 'params': {
  426. 'skip_download': True, # infinite live stream
  427. },
  428. 'expected_warnings': [
  429. r'501.*Not Implemented'
  430. ],
  431. },
  432. # Soundcloud embed
  433. {
  434. 'url': 'http://nakedsecurity.sophos.com/2014/10/29/sscc-171-are-you-sure-that-1234-is-a-bad-password-podcast/',
  435. 'info_dict': {
  436. 'id': '174391317',
  437. 'ext': 'mp3',
  438. 'description': 'md5:ff867d6b555488ad3c52572bb33d432c',
  439. 'uploader': 'Sophos Security',
  440. 'title': 'Chet Chat 171 - Oct 29, 2014',
  441. 'upload_date': '20141029',
  442. }
  443. },
  444. # Livestream embed
  445. {
  446. 'url': 'http://www.esa.int/Our_Activities/Space_Science/Rosetta/Philae_comet_touch-down_webcast',
  447. 'info_dict': {
  448. 'id': '67864563',
  449. 'ext': 'flv',
  450. 'upload_date': '20141112',
  451. 'title': 'Rosetta #CometLanding webcast HL 10',
  452. }
  453. },
  454. # LazyYT
  455. {
  456. 'url': 'http://discourse.ubuntu.com/t/unity-8-desktop-mode-windows-on-mir/1986',
  457. 'info_dict': {
  458. 'title': 'Unity 8 desktop-mode windows on Mir! - Ubuntu Discourse',
  459. },
  460. 'playlist_mincount': 2,
  461. },
  462. # Direct link with incorrect MIME type
  463. {
  464. 'url': 'http://ftp.nluug.nl/video/nluug/2014-11-20_nj14/zaal-2/5_Lennart_Poettering_-_Systemd.webm',
  465. 'md5': '4ccbebe5f36706d85221f204d7eb5913',
  466. 'info_dict': {
  467. 'url': 'http://ftp.nluug.nl/video/nluug/2014-11-20_nj14/zaal-2/5_Lennart_Poettering_-_Systemd.webm',
  468. 'id': '5_Lennart_Poettering_-_Systemd',
  469. 'ext': 'webm',
  470. 'title': '5_Lennart_Poettering_-_Systemd',
  471. 'upload_date': '20141120',
  472. },
  473. 'expected_warnings': [
  474. 'URL could be a direct video link, returning it as such.'
  475. ]
  476. },
  477. # Cinchcast embed
  478. {
  479. 'url': 'http://undergroundwellness.com/podcasts/306-5-steps-to-permanent-gut-healing/',
  480. 'info_dict': {
  481. 'id': '7141703',
  482. 'ext': 'mp3',
  483. 'upload_date': '20141126',
  484. 'title': 'Jack Tips: 5 Steps to Permanent Gut Healing',
  485. }
  486. },
  487. # Cinerama player
  488. {
  489. 'url': 'http://www.abc.net.au/7.30/content/2015/s4164797.htm',
  490. 'info_dict': {
  491. 'id': '730m_DandD_1901_512k',
  492. 'ext': 'mp4',
  493. 'uploader': 'www.abc.net.au',
  494. 'title': 'Game of Thrones with dice - Dungeons and Dragons fantasy role-playing game gets new life - 19/01/2015',
  495. }
  496. },
  497. # embedded viddler video
  498. {
  499. 'url': 'http://deadspin.com/i-cant-stop-watching-john-wall-chop-the-nuggets-with-th-1681801597',
  500. 'info_dict': {
  501. 'id': '4d03aad9',
  502. 'ext': 'mp4',
  503. 'uploader': 'deadspin',
  504. 'title': 'WALL-TO-GORTAT',
  505. 'timestamp': 1422285291,
  506. 'upload_date': '20150126',
  507. },
  508. 'add_ie': ['Viddler'],
  509. }
  510. ]
  511. def report_following_redirect(self, new_url):
  512. """Report information extraction."""
  513. self._downloader.to_screen('[redirect] Following redirect to %s' % new_url)
  514. def _extract_rss(self, url, video_id, doc):
  515. playlist_title = doc.find('./channel/title').text
  516. playlist_desc_el = doc.find('./channel/description')
  517. playlist_desc = None if playlist_desc_el is None else playlist_desc_el.text
  518. entries = [{
  519. '_type': 'url',
  520. 'url': e.find('link').text,
  521. 'title': e.find('title').text,
  522. } for e in doc.findall('./channel/item')]
  523. return {
  524. '_type': 'playlist',
  525. 'id': url,
  526. 'title': playlist_title,
  527. 'description': playlist_desc,
  528. 'entries': entries,
  529. }
  530. def _extract_camtasia(self, url, video_id, webpage):
  531. """ Returns None if no camtasia video can be found. """
  532. camtasia_cfg = self._search_regex(
  533. r'fo\.addVariable\(\s*"csConfigFile",\s*"([^"]+)"\s*\);',
  534. webpage, 'camtasia configuration file', default=None)
  535. if camtasia_cfg is None:
  536. return None
  537. title = self._html_search_meta('DC.title', webpage, fatal=True)
  538. camtasia_url = compat_urlparse.urljoin(url, camtasia_cfg)
  539. camtasia_cfg = self._download_xml(
  540. camtasia_url, video_id,
  541. note='Downloading camtasia configuration',
  542. errnote='Failed to download camtasia configuration')
  543. fileset_node = camtasia_cfg.find('./playlist/array/fileset')
  544. entries = []
  545. for n in fileset_node.getchildren():
  546. url_n = n.find('./uri')
  547. if url_n is None:
  548. continue
  549. entries.append({
  550. 'id': os.path.splitext(url_n.text.rpartition('/')[2])[0],
  551. 'title': '%s - %s' % (title, n.tag),
  552. 'url': compat_urlparse.urljoin(url, url_n.text),
  553. 'duration': float_or_none(n.find('./duration').text),
  554. })
  555. return {
  556. '_type': 'playlist',
  557. 'entries': entries,
  558. 'title': title,
  559. }
  560. def _real_extract(self, url):
  561. if url.startswith('//'):
  562. return {
  563. '_type': 'url',
  564. 'url': self.http_scheme() + url,
  565. }
  566. parsed_url = compat_urlparse.urlparse(url)
  567. if not parsed_url.scheme:
  568. default_search = self._downloader.params.get('default_search')
  569. if default_search is None:
  570. default_search = 'fixup_error'
  571. if default_search in ('auto', 'auto_warning', 'fixup_error'):
  572. if '/' in url:
  573. self._downloader.report_warning('The url doesn\'t specify the protocol, trying with http')
  574. return self.url_result('http://' + url)
  575. elif default_search != 'fixup_error':
  576. if default_search == 'auto_warning':
  577. if re.match(r'^(?:url|URL)$', url):
  578. raise ExtractorError(
  579. 'Invalid URL: %r . Call youtube-dl like this: youtube-dl -v "https://www.youtube.com/watch?v=BaW_jenozKc" ' % url,
  580. expected=True)
  581. else:
  582. self._downloader.report_warning(
  583. 'Falling back to youtube search for %s . Set --default-search "auto" to suppress this warning.' % url)
  584. return self.url_result('ytsearch:' + url)
  585. if default_search in ('error', 'fixup_error'):
  586. raise ExtractorError(
  587. '%r is not a valid URL. '
  588. 'Set --default-search "ytsearch" (or run youtube-dl "ytsearch:%s" ) to search YouTube'
  589. % (url, url), expected=True)
  590. else:
  591. if ':' not in default_search:
  592. default_search += ':'
  593. return self.url_result(default_search + url)
  594. url, smuggled_data = unsmuggle_url(url)
  595. force_videoid = None
  596. is_intentional = smuggled_data and smuggled_data.get('to_generic')
  597. if smuggled_data and 'force_videoid' in smuggled_data:
  598. force_videoid = smuggled_data['force_videoid']
  599. video_id = force_videoid
  600. else:
  601. video_id = os.path.splitext(url.rstrip('/').split('/')[-1])[0]
  602. self.to_screen('%s: Requesting header' % video_id)
  603. head_req = HEADRequest(url)
  604. head_response = self._request_webpage(
  605. head_req, video_id,
  606. note=False, errnote='Could not send HEAD request to %s' % url,
  607. fatal=False)
  608. if head_response is not False:
  609. # Check for redirect
  610. new_url = head_response.geturl()
  611. if url != new_url:
  612. self.report_following_redirect(new_url)
  613. if force_videoid:
  614. new_url = smuggle_url(
  615. new_url, {'force_videoid': force_videoid})
  616. return self.url_result(new_url)
  617. full_response = None
  618. if head_response is False:
  619. full_response = self._request_webpage(url, video_id)
  620. head_response = full_response
  621. # Check for direct link to a video
  622. content_type = head_response.headers.get('Content-Type', '')
  623. m = re.match(r'^(?P<type>audio|video|application(?=/ogg$))/(?P<format_id>.+)$', content_type)
  624. if m:
  625. upload_date = unified_strdate(
  626. head_response.headers.get('Last-Modified'))
  627. return {
  628. 'id': video_id,
  629. 'title': os.path.splitext(url_basename(url))[0],
  630. 'direct': True,
  631. 'formats': [{
  632. 'format_id': m.group('format_id'),
  633. 'url': url,
  634. 'vcodec': 'none' if m.group('type') == 'audio' else None
  635. }],
  636. 'upload_date': upload_date,
  637. }
  638. if not self._downloader.params.get('test', False) and not is_intentional:
  639. self._downloader.report_warning('Falling back on generic information extractor.')
  640. if not full_response:
  641. full_response = self._request_webpage(url, video_id)
  642. # Maybe it's a direct link to a video?
  643. # Be careful not to download the whole thing!
  644. first_bytes = full_response.read(512)
  645. if not is_html(first_bytes):
  646. self._downloader.report_warning(
  647. 'URL could be a direct video link, returning it as such.')
  648. upload_date = unified_strdate(
  649. head_response.headers.get('Last-Modified'))
  650. return {
  651. 'id': video_id,
  652. 'title': os.path.splitext(url_basename(url))[0],
  653. 'direct': True,
  654. 'url': url,
  655. 'upload_date': upload_date,
  656. }
  657. webpage = self._webpage_read_content(
  658. full_response, url, video_id, prefix=first_bytes)
  659. self.report_extraction(video_id)
  660. # Is it an RSS feed?
  661. try:
  662. doc = parse_xml(webpage)
  663. if doc.tag == 'rss':
  664. return self._extract_rss(url, video_id, doc)
  665. except compat_xml_parse_error:
  666. pass
  667. # Is it a Camtasia project?
  668. camtasia_res = self._extract_camtasia(url, video_id, webpage)
  669. if camtasia_res is not None:
  670. return camtasia_res
  671. # Sometimes embedded video player is hidden behind percent encoding
  672. # (e.g. https://github.com/rg3/youtube-dl/issues/2448)
  673. # Unescaping the whole page allows to handle those cases in a generic way
  674. webpage = compat_urllib_parse.unquote(webpage)
  675. # it's tempting to parse this further, but you would
  676. # have to take into account all the variations like
  677. # Video Title - Site Name
  678. # Site Name | Video Title
  679. # Video Title - Tagline | Site Name
  680. # and so on and so forth; it's just not practical
  681. video_title = self._html_search_regex(
  682. r'(?s)<title>(.*?)</title>', webpage, 'video title',
  683. default='video')
  684. # Try to detect age limit automatically
  685. age_limit = self._rta_search(webpage)
  686. # And then there are the jokers who advertise that they use RTA,
  687. # but actually don't.
  688. AGE_LIMIT_MARKERS = [
  689. r'Proudly Labeled <a href="http://www.rtalabel.org/" title="Restricted to Adults">RTA</a>',
  690. ]
  691. if any(re.search(marker, webpage) for marker in AGE_LIMIT_MARKERS):
  692. age_limit = 18
  693. # video uploader is domain name
  694. video_uploader = self._search_regex(
  695. r'^(?:https?://)?([^/]*)/.*', url, 'video uploader')
  696. # Helper method
  697. def _playlist_from_matches(matches, getter=None, ie=None):
  698. urlrs = orderedSet(
  699. self.url_result(self._proto_relative_url(getter(m) if getter else m), ie)
  700. for m in matches)
  701. return self.playlist_result(
  702. urlrs, playlist_id=video_id, playlist_title=video_title)
  703. # Look for BrightCove:
  704. bc_urls = BrightcoveIE._extract_brightcove_urls(webpage)
  705. if bc_urls:
  706. self.to_screen('Brightcove video detected.')
  707. entries = [{
  708. '_type': 'url',
  709. 'url': smuggle_url(bc_url, {'Referer': url}),
  710. 'ie_key': 'Brightcove'
  711. } for bc_url in bc_urls]
  712. return {
  713. '_type': 'playlist',
  714. 'title': video_title,
  715. 'id': video_id,
  716. 'entries': entries,
  717. }
  718. # Look for embedded (iframe) Vimeo player
  719. mobj = re.search(
  720. r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.vimeo\.com/video/.+?)\1', webpage)
  721. if mobj:
  722. player_url = unescapeHTML(mobj.group('url'))
  723. surl = smuggle_url(player_url, {'Referer': url})
  724. return self.url_result(surl)
  725. # Look for embedded (swf embed) Vimeo player
  726. mobj = re.search(
  727. r'<embed[^>]+?src="((?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)"', webpage)
  728. if mobj:
  729. return self.url_result(mobj.group(1))
  730. # Look for embedded YouTube player
  731. matches = re.findall(r'''(?x)
  732. (?:
  733. <iframe[^>]+?src=|
  734. data-video-url=|
  735. <embed[^>]+?src=|
  736. embedSWF\(?:\s*|
  737. new\s+SWFObject\(
  738. )
  739. (["\'])
  740. (?P<url>(?:https?:)?//(?:www\.)?youtube(?:-nocookie)?\.com/
  741. (?:embed|v|p)/.+?)
  742. \1''', webpage)
  743. if matches:
  744. return _playlist_from_matches(
  745. matches, lambda m: unescapeHTML(m[1]))
  746. # Look for lazyYT YouTube embed
  747. matches = re.findall(
  748. r'class="lazyYT" data-youtube-id="([^"]+)"', webpage)
  749. if matches:
  750. return _playlist_from_matches(matches, lambda m: unescapeHTML(m))
  751. # Look for embedded Dailymotion player
  752. matches = re.findall(
  753. r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?dailymotion\.com/embed/video/.+?)\1', webpage)
  754. if matches:
  755. return _playlist_from_matches(
  756. matches, lambda m: unescapeHTML(m[1]))
  757. # Look for embedded Dailymotion playlist player (#3822)
  758. m = re.search(
  759. r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?dailymotion\.[a-z]{2,3}/widget/jukebox\?.+?)\1', webpage)
  760. if m:
  761. playlists = re.findall(
  762. r'list\[\]=/playlist/([^/]+)/', unescapeHTML(m.group('url')))
  763. if playlists:
  764. return _playlist_from_matches(
  765. playlists, lambda p: '//dailymotion.com/playlist/%s' % p)
  766. # Look for embedded Wistia player
  767. match = re.search(
  768. r'<(?:meta[^>]+?content|iframe[^>]+?src)=(["\'])(?P<url>(?:https?:)?//(?:fast\.)?wistia\.net/embed/iframe/.+?)\1', webpage)
  769. if match:
  770. embed_url = self._proto_relative_url(
  771. unescapeHTML(match.group('url')))
  772. return {
  773. '_type': 'url_transparent',
  774. 'url': embed_url,
  775. 'ie_key': 'Wistia',
  776. 'uploader': video_uploader,
  777. 'title': video_title,
  778. 'id': video_id,
  779. }
  780. match = re.search(r'(?:id=["\']wistia_|data-wistia-?id=["\']|Wistia\.embed\(["\'])(?P<id>[^"\']+)', webpage)
  781. if match:
  782. return {
  783. '_type': 'url_transparent',
  784. 'url': 'http://fast.wistia.net/embed/iframe/{0:}'.format(match.group('id')),
  785. 'ie_key': 'Wistia',
  786. 'uploader': video_uploader,
  787. 'title': video_title,
  788. 'id': match.group('id')
  789. }
  790. # Look for embedded blip.tv player
  791. mobj = re.search(r'<meta\s[^>]*https?://api\.blip\.tv/\w+/redirect/\w+/(\d+)', webpage)
  792. if mobj:
  793. return self.url_result('http://blip.tv/a/a-' + mobj.group(1), 'BlipTV')
  794. mobj = re.search(r'<(?:iframe|embed|object)\s[^>]*(https?://(?:\w+\.)?blip\.tv/(?:play/|api\.swf#)[a-zA-Z0-9_]+)', webpage)
  795. if mobj:
  796. return self.url_result(mobj.group(1), 'BlipTV')
  797. # Look for embedded condenast player
  798. matches = re.findall(
  799. r'<iframe\s+(?:[a-zA-Z-]+="[^"]+"\s+)*?src="(https?://player\.cnevids\.com/embed/[^"]+")',
  800. webpage)
  801. if matches:
  802. return {
  803. '_type': 'playlist',
  804. 'entries': [{
  805. '_type': 'url',
  806. 'ie_key': 'CondeNast',
  807. 'url': ma,
  808. } for ma in matches],
  809. 'title': video_title,
  810. 'id': video_id,
  811. }
  812. # Look for Bandcamp pages with custom domain
  813. mobj = re.search(r'<meta property="og:url"[^>]*?content="(.*?bandcamp\.com.*?)"', webpage)
  814. if mobj is not None:
  815. burl = unescapeHTML(mobj.group(1))
  816. # Don't set the extractor because it can be a track url or an album
  817. return self.url_result(burl)
  818. # Look for embedded Vevo player
  819. mobj = re.search(
  820. r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:cache\.)?vevo\.com/.+?)\1', webpage)
  821. if mobj is not None:
  822. return self.url_result(mobj.group('url'))
  823. # Look for embedded Viddler player
  824. mobj = re.search(
  825. r'<(?:iframe[^>]+?src|param[^>]+?value)=(["\'])(?P<url>(?:https?:)?//(?:www\.)?viddler\.com/(?:embed|player)/.+?)\1',
  826. webpage)
  827. if mobj is not None:
  828. return self.url_result(mobj.group('url'))
  829. # Look for Ooyala videos
  830. mobj = (re.search(r'player\.ooyala\.com/[^"?]+\?[^"]*?(?:embedCode|ec)=(?P<ec>[^"&]+)', webpage) or
  831. re.search(r'OO\.Player\.create\([\'"].*?[\'"],\s*[\'"](?P<ec>.{32})[\'"]', webpage))
  832. if mobj is not None:
  833. return OoyalaIE._build_url_result(mobj.group('ec'))
  834. # Look for Aparat videos
  835. mobj = re.search(r'<iframe .*?src="(http://www\.aparat\.com/video/[^"]+)"', webpage)
  836. if mobj is not None:
  837. return self.url_result(mobj.group(1), 'Aparat')
  838. # Look for MPORA videos
  839. mobj = re.search(r'<iframe .*?src="(http://mpora\.(?:com|de)/videos/[^"]+)"', webpage)
  840. if mobj is not None:
  841. return self.url_result(mobj.group(1), 'Mpora')
  842. # Look for embedded NovaMov-based player
  843. mobj = re.search(
  844. r'''(?x)<(?:pagespeed_)?iframe[^>]+?src=(["\'])
  845. (?P<url>http://(?:(?:embed|www)\.)?
  846. (?:novamov\.com|
  847. nowvideo\.(?:ch|sx|eu|at|ag|co)|
  848. videoweed\.(?:es|com)|
  849. movshare\.(?:net|sx|ag)|
  850. divxstage\.(?:eu|net|ch|co|at|ag))
  851. /embed\.php.+?)\1''', webpage)
  852. if mobj is not None:
  853. return self.url_result(mobj.group('url'))
  854. # Look for embedded Facebook player
  855. mobj = re.search(
  856. r'<iframe[^>]+?src=(["\'])(?P<url>https://www\.facebook\.com/video/embed.+?)\1', webpage)
  857. if mobj is not None:
  858. return self.url_result(mobj.group('url'), 'Facebook')
  859. # Look for embedded VK player
  860. mobj = re.search(r'<iframe[^>]+?src=(["\'])(?P<url>https?://vk\.com/video_ext\.php.+?)\1', webpage)
  861. if mobj is not None:
  862. return self.url_result(mobj.group('url'), 'VK')
  863. # Look for embedded ivi player
  864. mobj = re.search(r'<embed[^>]+?src=(["\'])(?P<url>https?://(?:www\.)?ivi\.ru/video/player.+?)\1', webpage)
  865. if mobj is not None:
  866. return self.url_result(mobj.group('url'), 'Ivi')
  867. # Look for embedded Huffington Post player
  868. mobj = re.search(
  869. r'<iframe[^>]+?src=(["\'])(?P<url>https?://embed\.live\.huffingtonpost\.com/.+?)\1', webpage)
  870. if mobj is not None:
  871. return self.url_result(mobj.group('url'), 'HuffPost')
  872. # Look for embed.ly
  873. mobj = re.search(r'class=["\']embedly-card["\'][^>]href=["\'](?P<url>[^"\']+)', webpage)
  874. if mobj is not None:
  875. return self.url_result(mobj.group('url'))
  876. mobj = re.search(r'class=["\']embedly-embed["\'][^>]src=["\'][^"\']*url=(?P<url>[^&]+)', webpage)
  877. if mobj is not None:
  878. return self.url_result(compat_urllib_parse.unquote(mobj.group('url')))
  879. # Look for funnyordie embed
  880. matches = re.findall(r'<iframe[^>]+?src="(https?://(?:www\.)?funnyordie\.com/embed/[^"]+)"', webpage)
  881. if matches:
  882. return _playlist_from_matches(
  883. matches, getter=unescapeHTML, ie='FunnyOrDie')
  884. # Look for BBC iPlayer embed
  885. matches = re.findall(r'setPlaylist\("(https?://www\.bbc\.co\.uk/iplayer/[^/]+/[\da-z]{8})"\)', webpage)
  886. if matches:
  887. return _playlist_from_matches(matches, ie='BBCCoUk')
  888. # Look for embedded RUTV player
  889. rutv_url = RUTVIE._extract_url(webpage)
  890. if rutv_url:
  891. return self.url_result(rutv_url, 'RUTV')
  892. # Look for embedded TED player
  893. mobj = re.search(
  894. r'<iframe[^>]+?src=(["\'])(?P<url>https?://embed(?:-ssl)?\.ted\.com/.+?)\1', webpage)
  895. if mobj is not None:
  896. return self.url_result(mobj.group('url'), 'TED')
  897. # Look for embedded Ustream videos
  898. mobj = re.search(
  899. r'<iframe[^>]+?src=(["\'])(?P<url>http://www\.ustream\.tv/embed/.+?)\1', webpage)
  900. if mobj is not None:
  901. return self.url_result(mobj.group('url'), 'Ustream')
  902. # Look for embedded arte.tv player
  903. mobj = re.search(
  904. r'<script [^>]*?src="(?P<url>http://www\.arte\.tv/playerv2/embed[^"]+)"',
  905. webpage)
  906. if mobj is not None:
  907. return self.url_result(mobj.group('url'), 'ArteTVEmbed')
  908. # Look for embedded smotri.com player
  909. smotri_url = SmotriIE._extract_url(webpage)
  910. if smotri_url:
  911. return self.url_result(smotri_url, 'Smotri')
  912. # Look for embeded soundcloud player
  913. mobj = re.search(
  914. r'<iframe\s+(?:[a-zA-Z0-9_-]+="[^"]+"\s+)*src="(?P<url>https?://(?:w\.)?soundcloud\.com/player[^"]+)"',
  915. webpage)
  916. if mobj is not None:
  917. url = unescapeHTML(mobj.group('url'))
  918. return self.url_result(url)
  919. # Look for embedded vulture.com player
  920. mobj = re.search(
  921. r'<iframe src="(?P<url>https?://video\.vulture\.com/[^"]+)"',
  922. webpage)
  923. if mobj is not None:
  924. url = unescapeHTML(mobj.group('url'))
  925. return self.url_result(url, ie='Vulture')
  926. # Look for embedded mtvservices player
  927. mobj = re.search(
  928. r'<iframe src="(?P<url>https?://media\.mtvnservices\.com/embed/[^"]+)"',
  929. webpage)
  930. if mobj is not None:
  931. url = unescapeHTML(mobj.group('url'))
  932. return self.url_result(url, ie='MTVServicesEmbedded')
  933. # Look for embedded yahoo player
  934. mobj = re.search(
  935. r'<iframe[^>]+?src=(["\'])(?P<url>https?://(?:screen|movies)\.yahoo\.com/.+?\.html\?format=embed)\1',
  936. webpage)
  937. if mobj is not None:
  938. return self.url_result(mobj.group('url'), 'Yahoo')
  939. # Look for embedded sbs.com.au player
  940. mobj = re.search(
  941. r'<iframe[^>]+?src=(["\'])(?P<url>https?://(?:www\.)sbs\.com\.au/ondemand/video/single/.+?)\1',
  942. webpage)
  943. if mobj is not None:
  944. return self.url_result(mobj.group('url'), 'SBS')
  945. # Look for embedded Cinchcast player
  946. mobj = re.search(
  947. r'<iframe[^>]+?src=(["\'])(?P<url>https?://player\.cinchcast\.com/.+?)\1',
  948. webpage)
  949. if mobj is not None:
  950. return self.url_result(mobj.group('url'), 'Cinchcast')
  951. mobj = re.search(
  952. r'<iframe[^>]+?src=(["\'])(?P<url>https?://m(?:lb)?\.mlb\.com/shared/video/embed/embed\.html\?.+?)\1',
  953. webpage)
  954. if mobj is not None:
  955. return self.url_result(mobj.group('url'), 'MLB')
  956. mobj = re.search(
  957. r'<iframe[^>]+?src=(["\'])(?P<url>%s)\1' % CondeNastIE.EMBED_URL,
  958. webpage)
  959. if mobj is not None:
  960. return self.url_result(self._proto_relative_url(mobj.group('url'), scheme='http:'), 'CondeNast')
  961. mobj = re.search(
  962. r'<iframe[^>]+src="(?P<url>https?://new\.livestream\.com/[^"]+/player[^"]+)"',
  963. webpage)
  964. if mobj is not None:
  965. return self.url_result(mobj.group('url'), 'Livestream')
  966. def check_video(vurl):
  967. vpath = compat_urlparse.urlparse(vurl).path
  968. vext = determine_ext(vpath)
  969. return '.' in vpath and vext not in ('swf', 'png', 'jpg', 'srt', 'sbv', 'sub', 'vtt', 'ttml')
  970. def filter_video(urls):
  971. return list(filter(check_video, urls))
  972. # Start with something easy: JW Player in SWFObject
  973. found = filter_video(re.findall(r'flashvars: [\'"](?:.*&)?file=(http[^\'"&]*)', webpage))
  974. if not found:
  975. # Look for gorilla-vid style embedding
  976. found = filter_video(re.findall(r'''(?sx)
  977. (?:
  978. jw_plugins|
  979. JWPlayerOptions|
  980. jwplayer\s*\(\s*["'][^'"]+["']\s*\)\s*\.setup
  981. )
  982. .*?file\s*:\s*["\'](.*?)["\']''', webpage))
  983. if not found:
  984. # Broaden the search a little bit
  985. found = filter_video(re.findall(r'[^A-Za-z0-9]?(?:file|source)=(http[^\'"&]*)', webpage))
  986. if not found:
  987. # Broaden the findall a little bit: JWPlayer JS loader
  988. found = filter_video(re.findall(
  989. r'[^A-Za-z0-9]?file["\']?:\s*["\'](http(?![^\'"]+\.[0-9]+[\'"])[^\'"]+)["\']', webpage))
  990. if not found:
  991. # Flow player
  992. found = filter_video(re.findall(r'''(?xs)
  993. flowplayer\("[^"]+",\s*
  994. \{[^}]+?\}\s*,
  995. \s*\{[^}]+? ["']?clip["']?\s*:\s*\{\s*
  996. ["']?url["']?\s*:\s*["']([^"']+)["']
  997. ''', webpage))
  998. if not found:
  999. # Cinerama player
  1000. found = re.findall(
  1001. r"cinerama\.embedPlayer\(\s*\'[^']+\',\s*'([^']+)'", webpage)
  1002. if not found:
  1003. # Try to find twitter cards info
  1004. found = filter_video(re.findall(
  1005. r'<meta (?:property|name)="twitter:player:stream" (?:content|value)="(.+?)"', webpage))
  1006. if not found:
  1007. # We look for Open Graph info:
  1008. # We have to match any number spaces between elements, some sites try to align them (eg.: statigr.am)
  1009. m_video_type = re.findall(r'<meta.*?property="og:video:type".*?content="video/(.*?)"', webpage)
  1010. # We only look in og:video if the MIME type is a video, don't try if it's a Flash player:
  1011. if m_video_type is not None:
  1012. found = filter_video(re.findall(r'<meta.*?property="og:video".*?content="(.*?)"', webpage))
  1013. if not found:
  1014. # HTML5 video
  1015. found = re.findall(r'(?s)<video[^<]*(?:>.*?<source[^>]*)?\s+src=["\'](.*?)["\']', webpage)
  1016. if not found:
  1017. found = re.search(
  1018. r'(?i)<meta\s+(?=(?:[a-z-]+="[^"]+"\s+)*http-equiv="refresh")'
  1019. r'(?:[a-z-]+="[^"]+"\s+)*?content="[0-9]{,2};url=\'?([^\'"]+)',
  1020. webpage)
  1021. if found:
  1022. new_url = found.group(1)
  1023. self.report_following_redirect(new_url)
  1024. return {
  1025. '_type': 'url',
  1026. 'url': new_url,
  1027. }
  1028. if not found:
  1029. raise UnsupportedError(url)
  1030. entries = []
  1031. for video_url in found:
  1032. video_url = compat_urlparse.urljoin(url, video_url)
  1033. video_id = compat_urllib_parse.unquote(os.path.basename(video_url))
  1034. # Sometimes, jwplayer extraction will result in a YouTube URL
  1035. if YoutubeIE.suitable(video_url):
  1036. entries.append(self.url_result(video_url, 'Youtube'))
  1037. continue
  1038. # here's a fun little line of code for you:
  1039. video_id = os.path.splitext(video_id)[0]
  1040. entries.append({
  1041. 'id': video_id,
  1042. 'url': video_url,
  1043. 'uploader': video_uploader,
  1044. 'title': video_title,
  1045. 'age_limit': age_limit,
  1046. })
  1047. if len(entries) == 1:
  1048. return entries[0]
  1049. else:
  1050. for num, e in enumerate(entries, start=1):
  1051. e['title'] = '%s (%d)' % (e['title'], num)
  1052. return {
  1053. '_type': 'playlist',
  1054. 'entries': entries,
  1055. }