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.

1693 lines
67 KiB

10 years ago
11 years ago
11 years ago
11 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_urllib_parse_unquote,
  10. compat_urllib_request,
  11. compat_urlparse,
  12. compat_xml_parse_error,
  13. )
  14. from ..utils import (
  15. determine_ext,
  16. ExtractorError,
  17. float_or_none,
  18. HEADRequest,
  19. is_html,
  20. orderedSet,
  21. parse_xml,
  22. smuggle_url,
  23. unescapeHTML,
  24. unified_strdate,
  25. unsmuggle_url,
  26. UnsupportedError,
  27. url_basename,
  28. xpath_text,
  29. )
  30. from .brightcove import BrightcoveIE
  31. from .nbc import NBCSportsVPlayerIE
  32. from .ooyala import OoyalaIE
  33. from .rutv import RUTVIE
  34. from .tvc import TVCIE
  35. from .sportbox import SportBoxEmbedIE
  36. from .smotri import SmotriIE
  37. from .condenast import CondeNastIE
  38. from .udn import UDNEmbedIE
  39. from .senateisvp import SenateISVPIE
  40. from .bliptv import BlipTVIE
  41. from .svt import SVTIE
  42. from .pornhub import PornHubIE
  43. from .xhamster import XHamsterEmbedIE
  44. from .vimeo import VimeoIE
  45. from .dailymotion import DailymotionCloudIE
  46. from .onionstudios import OnionStudiosIE
  47. from .snagfilms import SnagFilmsEmbedIE
  48. class GenericIE(InfoExtractor):
  49. IE_DESC = 'Generic downloader that works on some sites'
  50. _VALID_URL = r'.*'
  51. IE_NAME = 'generic'
  52. _TESTS = [
  53. # Direct link to a video
  54. {
  55. 'url': 'http://media.w3.org/2010/05/sintel/trailer.mp4',
  56. 'md5': '67d406c2bcb6af27fa886f31aa934bbe',
  57. 'info_dict': {
  58. 'id': 'trailer',
  59. 'ext': 'mp4',
  60. 'title': 'trailer',
  61. 'upload_date': '20100513',
  62. }
  63. },
  64. # Direct link to media delivered compressed (until Accept-Encoding is *)
  65. {
  66. 'url': 'http://calimero.tk/muzik/FictionJunction-Parallel_Hearts.flac',
  67. 'md5': '128c42e68b13950268b648275386fc74',
  68. 'info_dict': {
  69. 'id': 'FictionJunction-Parallel_Hearts',
  70. 'ext': 'flac',
  71. 'title': 'FictionJunction-Parallel_Hearts',
  72. 'upload_date': '20140522',
  73. },
  74. 'expected_warnings': [
  75. 'URL could be a direct video link, returning it as such.'
  76. ]
  77. },
  78. # Direct download with broken HEAD
  79. {
  80. 'url': 'http://ai-radio.org:8000/radio.opus',
  81. 'info_dict': {
  82. 'id': 'radio',
  83. 'ext': 'opus',
  84. 'title': 'radio',
  85. },
  86. 'params': {
  87. 'skip_download': True, # infinite live stream
  88. },
  89. 'expected_warnings': [
  90. r'501.*Not Implemented'
  91. ],
  92. },
  93. # Direct link with incorrect MIME type
  94. {
  95. 'url': 'http://ftp.nluug.nl/video/nluug/2014-11-20_nj14/zaal-2/5_Lennart_Poettering_-_Systemd.webm',
  96. 'md5': '4ccbebe5f36706d85221f204d7eb5913',
  97. 'info_dict': {
  98. 'url': 'http://ftp.nluug.nl/video/nluug/2014-11-20_nj14/zaal-2/5_Lennart_Poettering_-_Systemd.webm',
  99. 'id': '5_Lennart_Poettering_-_Systemd',
  100. 'ext': 'webm',
  101. 'title': '5_Lennart_Poettering_-_Systemd',
  102. 'upload_date': '20141120',
  103. },
  104. 'expected_warnings': [
  105. 'URL could be a direct video link, returning it as such.'
  106. ]
  107. },
  108. # RSS feed
  109. {
  110. 'url': 'http://phihag.de/2014/youtube-dl/rss2.xml',
  111. 'info_dict': {
  112. 'id': 'http://phihag.de/2014/youtube-dl/rss2.xml',
  113. 'title': 'Zero Punctuation',
  114. 'description': 're:.*groundbreaking video review series.*'
  115. },
  116. 'playlist_mincount': 11,
  117. },
  118. # RSS feed with enclosure
  119. {
  120. 'url': 'http://podcastfeeds.nbcnews.com/audio/podcast/MSNBC-MADDOW-NETCAST-M4V.xml',
  121. 'info_dict': {
  122. 'id': 'pdv_maddow_netcast_m4v-02-27-2015-201624',
  123. 'ext': 'm4v',
  124. 'upload_date': '20150228',
  125. 'title': 'pdv_maddow_netcast_m4v-02-27-2015-201624',
  126. }
  127. },
  128. # google redirect
  129. {
  130. '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',
  131. 'info_dict': {
  132. 'id': 'cmQHVoWB5FY',
  133. 'ext': 'mp4',
  134. 'upload_date': '20130224',
  135. 'uploader_id': 'TheVerge',
  136. 'description': 're:^Chris Ziegler takes a look at the\.*',
  137. 'uploader': 'The Verge',
  138. 'title': 'First Firefox OS phones side-by-side',
  139. },
  140. 'params': {
  141. 'skip_download': False,
  142. }
  143. },
  144. {
  145. 'url': 'http://www.hodiho.fr/2013/02/regis-plante-sa-jeep.html',
  146. 'md5': '85b90ccc9d73b4acd9138d3af4c27f89',
  147. 'info_dict': {
  148. 'id': '13601338388002',
  149. 'ext': 'mp4',
  150. 'uploader': 'www.hodiho.fr',
  151. 'title': 'R\u00e9gis plante sa Jeep',
  152. }
  153. },
  154. # bandcamp page with custom domain
  155. {
  156. 'add_ie': ['Bandcamp'],
  157. 'url': 'http://bronyrock.com/track/the-pony-mash',
  158. 'info_dict': {
  159. 'id': '3235767654',
  160. 'ext': 'mp3',
  161. 'title': 'The Pony Mash',
  162. 'uploader': 'M_Pallante',
  163. },
  164. 'skip': 'There is a limit of 200 free downloads / month for the test song',
  165. },
  166. # embedded brightcove video
  167. # it also tests brightcove videos that need to set the 'Referer' in the
  168. # http requests
  169. {
  170. 'add_ie': ['Brightcove'],
  171. 'url': 'http://www.bfmtv.com/video/bfmbusiness/cours-bourse/cours-bourse-l-analyse-technique-154522/',
  172. 'info_dict': {
  173. 'id': '2765128793001',
  174. 'ext': 'mp4',
  175. 'title': 'Le cours de bourse : l’analyse technique',
  176. 'description': 'md5:7e9ad046e968cb2d1114004aba466fd9',
  177. 'uploader': 'BFM BUSINESS',
  178. },
  179. 'params': {
  180. 'skip_download': True,
  181. },
  182. },
  183. {
  184. # https://github.com/rg3/youtube-dl/issues/2253
  185. 'url': 'http://bcove.me/i6nfkrc3',
  186. 'md5': '0ba9446db037002366bab3b3eb30c88c',
  187. 'info_dict': {
  188. 'id': '3101154703001',
  189. 'ext': 'mp4',
  190. 'title': 'Still no power',
  191. 'uploader': 'thestar.com',
  192. '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.',
  193. },
  194. 'add_ie': ['Brightcove'],
  195. },
  196. {
  197. 'url': 'http://www.championat.com/video/football/v/87/87499.html',
  198. 'md5': 'fb973ecf6e4a78a67453647444222983',
  199. 'info_dict': {
  200. 'id': '3414141473001',
  201. 'ext': 'mp4',
  202. 'title': 'Видео. Удаление Дзагоева (ЦСКА)',
  203. 'description': 'Онлайн-трансляция матча ЦСКА - "Волга"',
  204. 'uploader': 'Championat',
  205. },
  206. },
  207. {
  208. # https://github.com/rg3/youtube-dl/issues/3541
  209. 'add_ie': ['Brightcove'],
  210. 'url': 'http://www.kijk.nl/sbs6/leermijvrouwenkennen/videos/jqMiXKAYan2S/aflevering-1',
  211. 'info_dict': {
  212. 'id': '3866516442001',
  213. 'ext': 'mp4',
  214. 'title': 'Leer mij vrouwen kennen: Aflevering 1',
  215. 'description': 'Leer mij vrouwen kennen: Aflevering 1',
  216. 'uploader': 'SBS Broadcasting',
  217. },
  218. 'skip': 'Restricted to Netherlands',
  219. 'params': {
  220. 'skip_download': True, # m3u8 download
  221. },
  222. },
  223. # ooyala video
  224. {
  225. 'url': 'http://www.rollingstone.com/music/videos/norwegian-dj-cashmere-cat-goes-spartan-on-with-me-premiere-20131219',
  226. 'md5': '166dd577b433b4d4ebfee10b0824d8ff',
  227. 'info_dict': {
  228. 'id': 'BwY2RxaTrTkslxOfcan0UCf0YqyvWysJ',
  229. 'ext': 'mp4',
  230. 'title': '2cc213299525360.mov', # that's what we get
  231. },
  232. 'add_ie': ['Ooyala'],
  233. },
  234. # multiple ooyala embeds on SBN network websites
  235. {
  236. 'url': 'http://www.sbnation.com/college-football-recruiting/2015/2/3/7970291/national-signing-day-rationalizations-itll-be-ok-itll-be-ok',
  237. 'info_dict': {
  238. 'id': 'national-signing-day-rationalizations-itll-be-ok-itll-be-ok',
  239. 'title': '25 lies you will tell yourself on National Signing Day - SBNation.com',
  240. },
  241. 'playlist_mincount': 3,
  242. 'params': {
  243. 'skip_download': True,
  244. },
  245. 'add_ie': ['Ooyala'],
  246. },
  247. # embed.ly video
  248. {
  249. 'url': 'http://www.tested.com/science/weird/460206-tested-grinding-coffee-2000-frames-second/',
  250. 'info_dict': {
  251. 'id': '9ODmcdjQcHQ',
  252. 'ext': 'mp4',
  253. 'title': 'Tested: Grinding Coffee at 2000 Frames Per Second',
  254. 'upload_date': '20140225',
  255. 'description': 'md5:06a40fbf30b220468f1e0957c0f558ff',
  256. 'uploader': 'Tested',
  257. 'uploader_id': 'testedcom',
  258. },
  259. # No need to test YoutubeIE here
  260. 'params': {
  261. 'skip_download': True,
  262. },
  263. },
  264. # funnyordie embed
  265. {
  266. 'url': 'http://www.theguardian.com/world/2014/mar/11/obama-zach-galifianakis-between-two-ferns',
  267. 'info_dict': {
  268. 'id': '18e820ec3f',
  269. 'ext': 'mp4',
  270. 'title': 'Between Two Ferns with Zach Galifianakis: President Barack Obama',
  271. 'description': 'Episode 18: President Barack Obama sits down with Zach Galifianakis for his most memorable interview yet.',
  272. },
  273. },
  274. # BBC iPlayer embeds
  275. {
  276. 'url': 'http://www.bbc.co.uk/blogs/adamcurtis/posts/BUGGER',
  277. 'info_dict': {
  278. 'title': 'BBC - Blogs - Adam Curtis - BUGGER',
  279. },
  280. 'playlist_mincount': 18,
  281. },
  282. # RUTV embed
  283. {
  284. 'url': 'http://www.rg.ru/2014/03/15/reg-dfo/anklav-anons.html',
  285. 'info_dict': {
  286. 'id': '776940',
  287. 'ext': 'mp4',
  288. 'title': 'Охотское море стало целиком российским',
  289. 'description': 'md5:5ed62483b14663e2a95ebbe115eb8f43',
  290. },
  291. 'params': {
  292. # m3u8 download
  293. 'skip_download': True,
  294. },
  295. },
  296. # TVC embed
  297. {
  298. 'url': 'http://sch1298sz.mskobr.ru/dou_edu/karamel_ki/filial_galleries/video/iframe_src_http_tvc_ru_video_iframe_id_55304_isplay_false_acc_video_id_channel_brand_id_11_show_episodes_episode_id_32307_frameb/',
  299. 'info_dict': {
  300. 'id': '55304',
  301. 'ext': 'mp4',
  302. 'title': 'Дошкольное воспитание',
  303. },
  304. },
  305. # SportBox embed
  306. {
  307. 'url': 'http://www.vestifinance.ru/articles/25753',
  308. 'info_dict': {
  309. 'id': '25753',
  310. 'title': 'Вести Экономика ― Прямые трансляции с Форума-выставки "Госзаказ-2013"',
  311. },
  312. 'playlist': [{
  313. 'info_dict': {
  314. 'id': '370908',
  315. 'title': 'Госзаказ. День 3',
  316. 'ext': 'mp4',
  317. }
  318. }, {
  319. 'info_dict': {
  320. 'id': '370905',
  321. 'title': 'Госзаказ. День 2',
  322. 'ext': 'mp4',
  323. }
  324. }, {
  325. 'info_dict': {
  326. 'id': '370902',
  327. 'title': 'Госзаказ. День 1',
  328. 'ext': 'mp4',
  329. }
  330. }],
  331. 'params': {
  332. # m3u8 download
  333. 'skip_download': True,
  334. },
  335. },
  336. # XHamster embed
  337. {
  338. 'url': 'http://www.numisc.com/forum/showthread.php?11696-FM15-which-pumiscer-was-this-%28-vid-%29-%28-alfa-as-fuck-srx-%29&s=711f5db534502e22260dec8c5e2d66d8',
  339. 'info_dict': {
  340. 'id': 'showthread',
  341. 'title': '[NSFL] [FM15] which pumiscer was this ( vid ) ( alfa as fuck srx )',
  342. },
  343. 'playlist_mincount': 7,
  344. },
  345. # Embedded TED video
  346. {
  347. 'url': 'http://en.support.wordpress.com/videos/ted-talks/',
  348. 'md5': '65fdff94098e4a607385a60c5177c638',
  349. 'info_dict': {
  350. 'id': '1969',
  351. 'ext': 'mp4',
  352. 'title': 'Hidden miracles of the natural world',
  353. 'uploader': 'Louie Schwartzberg',
  354. 'description': 'md5:8145d19d320ff3e52f28401f4c4283b9',
  355. }
  356. },
  357. # Embeded Ustream video
  358. {
  359. 'url': 'http://www.american.edu/spa/pti/nsa-privacy-janus-2014.cfm',
  360. 'md5': '27b99cdb639c9b12a79bca876a073417',
  361. 'info_dict': {
  362. 'id': '45734260',
  363. 'ext': 'flv',
  364. 'uploader': 'AU SPA: The NSA and Privacy',
  365. 'title': 'NSA and Privacy Forum Debate featuring General Hayden and Barton Gellman'
  366. }
  367. },
  368. # nowvideo embed hidden behind percent encoding
  369. {
  370. 'url': 'http://www.waoanime.tv/the-super-dimension-fortress-macross-episode-1/',
  371. 'md5': '2baf4ddd70f697d94b1c18cf796d5107',
  372. 'info_dict': {
  373. 'id': '06e53103ca9aa',
  374. 'ext': 'flv',
  375. 'title': 'Macross Episode 001 Watch Macross Episode 001 onl',
  376. 'description': 'No description',
  377. },
  378. },
  379. # arte embed
  380. {
  381. 'url': 'http://www.tv-replay.fr/redirection/20-03-14/x-enius-arte-10753389.html',
  382. 'md5': '7653032cbb25bf6c80d80f217055fa43',
  383. 'info_dict': {
  384. 'id': '048195-004_PLUS7-F',
  385. 'ext': 'flv',
  386. 'title': 'X:enius',
  387. 'description': 'md5:d5fdf32ef6613cdbfd516ae658abf168',
  388. 'upload_date': '20140320',
  389. },
  390. 'params': {
  391. 'skip_download': 'Requires rtmpdump'
  392. }
  393. },
  394. # Condé Nast embed
  395. {
  396. 'url': 'http://www.wired.com/2014/04/honda-asimo/',
  397. 'md5': 'ba0dfe966fa007657bd1443ee672db0f',
  398. 'info_dict': {
  399. 'id': '53501be369702d3275860000',
  400. 'ext': 'mp4',
  401. 'title': 'Honda’s New Asimo Robot Is More Human Than Ever',
  402. }
  403. },
  404. # Dailymotion embed
  405. {
  406. 'url': 'http://www.spi0n.com/zap-spi0n-com-n216/',
  407. 'md5': '441aeeb82eb72c422c7f14ec533999cd',
  408. 'info_dict': {
  409. 'id': 'k2mm4bCdJ6CQ2i7c8o2',
  410. 'ext': 'mp4',
  411. 'title': 'Le Zap de Spi0n n°216 - Zapping du Web',
  412. 'uploader': 'Spi0n',
  413. },
  414. 'add_ie': ['Dailymotion'],
  415. },
  416. # YouTube embed
  417. {
  418. 'url': 'http://www.badzine.de/ansicht/datum/2014/06/09/so-funktioniert-die-neue-englische-badminton-liga.html',
  419. 'info_dict': {
  420. 'id': 'FXRb4ykk4S0',
  421. 'ext': 'mp4',
  422. 'title': 'The NBL Auction 2014',
  423. 'uploader': 'BADMINTON England',
  424. 'uploader_id': 'BADMINTONEvents',
  425. 'upload_date': '20140603',
  426. 'description': 'md5:9ef128a69f1e262a700ed83edb163a73',
  427. },
  428. 'add_ie': ['Youtube'],
  429. 'params': {
  430. 'skip_download': True,
  431. }
  432. },
  433. # MTVSercices embed
  434. {
  435. 'url': 'http://www.gametrailers.com/news-post/76093/north-america-europe-is-getting-that-mario-kart-8-mercedes-dlc-too',
  436. 'md5': '35727f82f58c76d996fc188f9755b0d5',
  437. 'info_dict': {
  438. 'id': '0306a69b-8adf-4fb5-aace-75f8e8cbfca9',
  439. 'ext': 'mp4',
  440. 'title': 'Review',
  441. 'description': 'Mario\'s life in the fast lane has never looked so good.',
  442. },
  443. },
  444. # YouTube embed via <data-embed-url="">
  445. {
  446. 'url': 'https://play.google.com/store/apps/details?id=com.gameloft.android.ANMP.GloftA8HM',
  447. 'info_dict': {
  448. 'id': '4vAffPZIT44',
  449. 'ext': 'mp4',
  450. 'title': 'Asphalt 8: Airborne - Update - Welcome to Dubai!',
  451. 'uploader': 'Gameloft',
  452. 'uploader_id': 'gameloft',
  453. 'upload_date': '20140828',
  454. 'description': 'md5:c80da9ed3d83ae6d1876c834de03e1c4',
  455. },
  456. 'params': {
  457. 'skip_download': True,
  458. }
  459. },
  460. # Camtasia studio
  461. {
  462. 'url': 'http://www.ll.mit.edu/workshops/education/videocourses/antennas/lecture1/video/',
  463. 'playlist': [{
  464. 'md5': '0c5e352edabf715d762b0ad4e6d9ee67',
  465. 'info_dict': {
  466. 'id': 'Fenn-AA_PA_Radar_Course_Lecture_1c_Final',
  467. 'title': 'Fenn-AA_PA_Radar_Course_Lecture_1c_Final - video1',
  468. 'ext': 'flv',
  469. 'duration': 2235.90,
  470. }
  471. }, {
  472. 'md5': '10e4bb3aaca9fd630e273ff92d9f3c63',
  473. 'info_dict': {
  474. 'id': 'Fenn-AA_PA_Radar_Course_Lecture_1c_Final_PIP',
  475. 'title': 'Fenn-AA_PA_Radar_Course_Lecture_1c_Final - pip',
  476. 'ext': 'flv',
  477. 'duration': 2235.93,
  478. }
  479. }],
  480. 'info_dict': {
  481. 'title': 'Fenn-AA_PA_Radar_Course_Lecture_1c_Final',
  482. }
  483. },
  484. # Flowplayer
  485. {
  486. 'url': 'http://www.handjobhub.com/video/busty-blonde-siri-tit-fuck-while-wank-6313.html',
  487. 'md5': '9d65602bf31c6e20014319c7d07fba27',
  488. 'info_dict': {
  489. 'id': '5123ea6d5e5a7',
  490. 'ext': 'mp4',
  491. 'age_limit': 18,
  492. 'uploader': 'www.handjobhub.com',
  493. 'title': 'Busty Blonde Siri Tit Fuck While Wank at HandjobHub.com',
  494. }
  495. },
  496. # Multiple brightcove videos
  497. # https://github.com/rg3/youtube-dl/issues/2283
  498. {
  499. 'url': 'http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html',
  500. 'info_dict': {
  501. 'id': 'always-never',
  502. 'title': 'Always / Never - The New Yorker',
  503. },
  504. 'playlist_count': 3,
  505. 'params': {
  506. 'extract_flat': False,
  507. 'skip_download': True,
  508. }
  509. },
  510. # MLB embed
  511. {
  512. 'url': 'http://umpire-empire.com/index.php/topic/58125-laz-decides-no-thats-low/',
  513. 'md5': '96f09a37e44da40dd083e12d9a683327',
  514. 'info_dict': {
  515. 'id': '33322633',
  516. 'ext': 'mp4',
  517. 'title': 'Ump changes call to ball',
  518. 'description': 'md5:71c11215384298a172a6dcb4c2e20685',
  519. 'duration': 48,
  520. 'timestamp': 1401537900,
  521. 'upload_date': '20140531',
  522. 'thumbnail': 're:^https?://.*\.jpg$',
  523. },
  524. },
  525. # Wistia embed
  526. {
  527. 'url': 'http://education-portal.com/academy/lesson/north-american-exploration-failed-colonies-of-spain-france-england.html#lesson',
  528. 'md5': '8788b683c777a5cf25621eaf286d0c23',
  529. 'info_dict': {
  530. 'id': '1cfaf6b7ea',
  531. 'ext': 'mov',
  532. 'title': 'md5:51364a8d3d009997ba99656004b5e20d',
  533. 'duration': 643.0,
  534. 'filesize': 182808282,
  535. 'uploader': 'education-portal.com',
  536. },
  537. },
  538. {
  539. 'url': 'http://thoughtworks.wistia.com/medias/uxjb0lwrcz',
  540. 'md5': 'baf49c2baa8a7de5f3fc145a8506dcd4',
  541. 'info_dict': {
  542. 'id': 'uxjb0lwrcz',
  543. 'ext': 'mp4',
  544. 'title': 'Conversation about Hexagonal Rails Part 1 - ThoughtWorks',
  545. 'duration': 1715.0,
  546. 'uploader': 'thoughtworks.wistia.com',
  547. },
  548. },
  549. # Soundcloud embed
  550. {
  551. 'url': 'http://nakedsecurity.sophos.com/2014/10/29/sscc-171-are-you-sure-that-1234-is-a-bad-password-podcast/',
  552. 'info_dict': {
  553. 'id': '174391317',
  554. 'ext': 'mp3',
  555. 'description': 'md5:ff867d6b555488ad3c52572bb33d432c',
  556. 'uploader': 'Sophos Security',
  557. 'title': 'Chet Chat 171 - Oct 29, 2014',
  558. 'upload_date': '20141029',
  559. }
  560. },
  561. # Livestream embed
  562. {
  563. 'url': 'http://www.esa.int/Our_Activities/Space_Science/Rosetta/Philae_comet_touch-down_webcast',
  564. 'info_dict': {
  565. 'id': '67864563',
  566. 'ext': 'flv',
  567. 'upload_date': '20141112',
  568. 'title': 'Rosetta #CometLanding webcast HL 10',
  569. }
  570. },
  571. # LazyYT
  572. {
  573. 'url': 'http://discourse.ubuntu.com/t/unity-8-desktop-mode-windows-on-mir/1986',
  574. 'info_dict': {
  575. 'id': '1986',
  576. 'title': 'Unity 8 desktop-mode windows on Mir! - Ubuntu Discourse',
  577. },
  578. 'playlist_mincount': 2,
  579. },
  580. # Cinchcast embed
  581. {
  582. 'url': 'http://undergroundwellness.com/podcasts/306-5-steps-to-permanent-gut-healing/',
  583. 'info_dict': {
  584. 'id': '7141703',
  585. 'ext': 'mp3',
  586. 'upload_date': '20141126',
  587. 'title': 'Jack Tips: 5 Steps to Permanent Gut Healing',
  588. }
  589. },
  590. # Cinerama player
  591. {
  592. 'url': 'http://www.abc.net.au/7.30/content/2015/s4164797.htm',
  593. 'info_dict': {
  594. 'id': '730m_DandD_1901_512k',
  595. 'ext': 'mp4',
  596. 'uploader': 'www.abc.net.au',
  597. 'title': 'Game of Thrones with dice - Dungeons and Dragons fantasy role-playing game gets new life - 19/01/2015',
  598. }
  599. },
  600. # embedded viddler video
  601. {
  602. 'url': 'http://deadspin.com/i-cant-stop-watching-john-wall-chop-the-nuggets-with-th-1681801597',
  603. 'info_dict': {
  604. 'id': '4d03aad9',
  605. 'ext': 'mp4',
  606. 'uploader': 'deadspin',
  607. 'title': 'WALL-TO-GORTAT',
  608. 'timestamp': 1422285291,
  609. 'upload_date': '20150126',
  610. },
  611. 'add_ie': ['Viddler'],
  612. },
  613. # Libsyn embed
  614. {
  615. 'url': 'http://thedailyshow.cc.com/podcast/episodetwelve',
  616. 'info_dict': {
  617. 'id': '3377616',
  618. 'ext': 'mp3',
  619. 'title': "The Daily Show Podcast without Jon Stewart - Episode 12: Bassem Youssef: Egypt's Jon Stewart",
  620. 'description': 'md5:601cb790edd05908957dae8aaa866465',
  621. 'upload_date': '20150220',
  622. },
  623. },
  624. # jwplayer YouTube
  625. {
  626. 'url': 'http://media.nationalarchives.gov.uk/index.php/webinar-using-discovery-national-archives-online-catalogue/',
  627. 'info_dict': {
  628. 'id': 'Mrj4DVp2zeA',
  629. 'ext': 'mp4',
  630. 'upload_date': '20150212',
  631. 'uploader': 'The National Archives UK',
  632. 'description': 'md5:a236581cd2449dd2df4f93412f3f01c6',
  633. 'uploader_id': 'NationalArchives08',
  634. 'title': 'Webinar: Using Discovery, The National Archives’ online catalogue',
  635. },
  636. },
  637. # rtl.nl embed
  638. {
  639. 'url': 'http://www.rtlnieuws.nl/nieuws/buitenland/aanslagen-kopenhagen',
  640. 'playlist_mincount': 5,
  641. 'info_dict': {
  642. 'id': 'aanslagen-kopenhagen',
  643. 'title': 'Aanslagen Kopenhagen | RTL Nieuws',
  644. }
  645. },
  646. # Zapiks embed
  647. {
  648. 'url': 'http://www.skipass.com/news/116090-bon-appetit-s5ep3-baqueira-mi-cor.html',
  649. 'info_dict': {
  650. 'id': '118046',
  651. 'ext': 'mp4',
  652. 'title': 'EP3S5 - Bon Appétit - Baqueira Mi Corazon !',
  653. }
  654. },
  655. # Kaltura embed
  656. {
  657. 'url': 'http://www.monumentalnetwork.com/videos/john-carlson-postgame-2-25-15',
  658. 'info_dict': {
  659. 'id': '1_eergr3h1',
  660. 'ext': 'mp4',
  661. 'upload_date': '20150226',
  662. 'uploader_id': 'MonumentalSports-Kaltura@perfectsensedigital.com',
  663. 'timestamp': int,
  664. 'title': 'John Carlson Postgame 2/25/15',
  665. },
  666. },
  667. # Eagle.Platform embed (generic URL)
  668. {
  669. 'url': 'http://lenta.ru/news/2015/03/06/navalny/',
  670. 'info_dict': {
  671. 'id': '227304',
  672. 'ext': 'mp4',
  673. 'title': 'Навальный вышел на свободу',
  674. 'description': 'md5:d97861ac9ae77377f3f20eaf9d04b4f5',
  675. 'thumbnail': 're:^https?://.*\.jpg$',
  676. 'duration': 87,
  677. 'view_count': int,
  678. 'age_limit': 0,
  679. },
  680. },
  681. # ClipYou (Eagle.Platform) embed (custom URL)
  682. {
  683. 'url': 'http://muz-tv.ru/play/7129/',
  684. 'info_dict': {
  685. 'id': '12820',
  686. 'ext': 'mp4',
  687. 'title': "'O Sole Mio",
  688. 'thumbnail': 're:^https?://.*\.jpg$',
  689. 'duration': 216,
  690. 'view_count': int,
  691. },
  692. },
  693. # Pladform embed
  694. {
  695. 'url': 'http://muz-tv.ru/kinozal/view/7400/',
  696. 'info_dict': {
  697. 'id': '100183293',
  698. 'ext': 'mp4',
  699. 'title': 'Тайны перевала Дятлова • 1 серия 2 часть',
  700. 'description': 'Документальный сериал-расследование одной из самых жутких тайн ХХ века',
  701. 'thumbnail': 're:^https?://.*\.jpg$',
  702. 'duration': 694,
  703. 'age_limit': 0,
  704. },
  705. },
  706. # Playwire embed
  707. {
  708. 'url': 'http://www.cinemablend.com/new/First-Joe-Dirt-2-Trailer-Teaser-Stupid-Greatness-70874.html',
  709. 'info_dict': {
  710. 'id': '3519514',
  711. 'ext': 'mp4',
  712. 'title': 'Joe Dirt 2 Beautiful Loser Teaser Trailer',
  713. 'thumbnail': 're:^https?://.*\.png$',
  714. 'duration': 45.115,
  715. },
  716. },
  717. # 5min embed
  718. {
  719. 'url': 'http://techcrunch.com/video/facebook-creates-on-this-day-crunch-report/518726732/',
  720. 'md5': '4c6f127a30736b59b3e2c19234ee2bf7',
  721. 'info_dict': {
  722. 'id': '518726732',
  723. 'ext': 'mp4',
  724. 'title': 'Facebook Creates "On This Day" | Crunch Report',
  725. },
  726. },
  727. # SVT embed
  728. {
  729. 'url': 'http://www.svt.se/sport/ishockey/jagr-tacklar-giroux-under-intervjun',
  730. 'info_dict': {
  731. 'id': '2900353',
  732. 'ext': 'flv',
  733. 'title': 'Här trycker Jagr till Giroux (under SVT-intervjun)',
  734. 'duration': 27,
  735. 'age_limit': 0,
  736. },
  737. },
  738. # Crooks and Liars embed
  739. {
  740. 'url': 'http://crooksandliars.com/2015/04/fox-friends-says-protecting-atheists',
  741. 'info_dict': {
  742. 'id': '8RUoRhRi',
  743. 'ext': 'mp4',
  744. 'title': "Fox & Friends Says Protecting Atheists From Discrimination Is Anti-Christian!",
  745. 'description': 'md5:e1a46ad1650e3a5ec7196d432799127f',
  746. 'timestamp': 1428207000,
  747. 'upload_date': '20150405',
  748. 'uploader': 'Heather',
  749. },
  750. },
  751. # Crooks and Liars external embed
  752. {
  753. 'url': 'http://theothermccain.com/2010/02/02/video-proves-that-bill-kristol-has-been-watching-glenn-beck/comment-page-1/',
  754. 'info_dict': {
  755. 'id': 'MTE3MjUtMzQ2MzA',
  756. 'ext': 'mp4',
  757. 'title': 'md5:5e3662a81a4014d24c250d76d41a08d5',
  758. 'description': 'md5:9b8e9542d6c3c5de42d6451b7d780cec',
  759. 'timestamp': 1265032391,
  760. 'upload_date': '20100201',
  761. 'uploader': 'Heather',
  762. },
  763. },
  764. # NBC Sports vplayer embed
  765. {
  766. 'url': 'http://www.riderfans.com/forum/showthread.php?121827-Freeman&s=e98fa1ea6dc08e886b1678d35212494a',
  767. 'info_dict': {
  768. 'id': 'ln7x1qSThw4k',
  769. 'ext': 'flv',
  770. 'title': "PFT Live: New leader in the 'new-look' defense",
  771. 'description': 'md5:65a19b4bbfb3b0c0c5768bed1dfad74e',
  772. },
  773. },
  774. # UDN embed
  775. {
  776. 'url': 'http://www.udn.com/news/story/7314/822787',
  777. 'md5': 'fd2060e988c326991037b9aff9df21a6',
  778. 'info_dict': {
  779. 'id': '300346',
  780. 'ext': 'mp4',
  781. 'title': '中一中男師變性 全校師生力挺',
  782. 'thumbnail': 're:^https?://.*\.jpg$',
  783. }
  784. },
  785. # Ooyala embed
  786. {
  787. 'url': 'http://www.businessinsider.com/excel-index-match-vlookup-video-how-to-2015-2?IR=T',
  788. 'info_dict': {
  789. 'id': '50YnY4czr4ms1vJ7yz3xzq0excz_pUMs',
  790. 'ext': 'mp4',
  791. 'description': 'VIDEO: Index/Match versus VLOOKUP.',
  792. 'title': 'This is what separates the Excel masters from the wannabes',
  793. },
  794. 'params': {
  795. # m3u8 downloads
  796. 'skip_download': True,
  797. }
  798. },
  799. # Contains a SMIL manifest
  800. {
  801. 'url': 'http://www.telewebion.com/fa/1263668/%D9%82%D8%B1%D8%B9%D9%87%E2%80%8C%DA%A9%D8%B4%DB%8C-%D9%84%DB%8C%DA%AF-%D9%82%D9%87%D8%B1%D9%85%D8%A7%D9%86%D8%A7%D9%86-%D8%A7%D8%B1%D9%88%D9%BE%D8%A7/%2B-%D9%81%D9%88%D8%AA%D8%A8%D8%A7%D9%84.html',
  802. 'info_dict': {
  803. 'id': 'file',
  804. 'ext': 'flv',
  805. 'title': '+ Football: Lottery Champions League Europe',
  806. 'uploader': 'www.telewebion.com',
  807. },
  808. 'params': {
  809. # rtmpe downloads
  810. 'skip_download': True,
  811. }
  812. },
  813. # Brightcove URL in single quotes
  814. {
  815. 'url': 'http://www.sportsnet.ca/baseball/mlb/sn-presents-russell-martin-world-citizen/',
  816. 'md5': '4ae374f1f8b91c889c4b9203c8c752af',
  817. 'info_dict': {
  818. 'id': '4255764656001',
  819. 'ext': 'mp4',
  820. 'title': 'SN Presents: Russell Martin, World Citizen',
  821. 'description': 'To understand why he was the Toronto Blue Jays’ top off-season priority is to appreciate his background and upbringing in Montreal, where he first developed his baseball skills. Written and narrated by Stephen Brunt.',
  822. 'uploader': 'Rogers Sportsnet',
  823. },
  824. },
  825. # Dailymotion Cloud video
  826. {
  827. 'url': 'http://replay.publicsenat.fr/vod/le-debat/florent-kolandjian,dominique-cena,axel-decourtye,laurence-abeille,bruno-parmentier/175910',
  828. 'md5': '49444254273501a64675a7e68c502681',
  829. 'info_dict': {
  830. 'id': '5585de919473990de4bee11b',
  831. 'ext': 'mp4',
  832. 'title': 'Le débat',
  833. 'thumbnail': 're:^https?://.*\.jpe?g$',
  834. }
  835. },
  836. # OnionStudios embed
  837. {
  838. 'url': 'http://www.clickhole.com/video/dont-understand-bitcoin-man-will-mumble-explanatio-2537',
  839. 'info_dict': {
  840. 'id': '2855',
  841. 'ext': 'mp4',
  842. 'title': 'Don’t Understand Bitcoin? This Man Will Mumble An Explanation At You',
  843. 'thumbnail': 're:^https?://.*\.jpe?g$',
  844. 'uploader': 'ClickHole',
  845. 'uploader_id': 'clickhole',
  846. }
  847. },
  848. # SnagFilms embed
  849. {
  850. 'url': 'http://whilewewatch.blogspot.ru/2012/06/whilewewatch-whilewewatch-gripping.html',
  851. 'info_dict': {
  852. 'id': '74849a00-85a9-11e1-9660-123139220831',
  853. 'ext': 'mp4',
  854. 'title': '#whilewewatch',
  855. }
  856. },
  857. # AdobeTVVideo embed
  858. {
  859. 'url': 'https://helpx.adobe.com/acrobat/how-to/new-experience-acrobat-dc.html?set=acrobat--get-started--essential-beginners',
  860. 'md5': '43662b577c018ad707a63766462b1e87',
  861. 'info_dict': {
  862. 'id': '2456',
  863. 'ext': 'mp4',
  864. 'title': 'New experience with Acrobat DC',
  865. 'description': 'New experience with Acrobat DC',
  866. 'duration': 248.667,
  867. },
  868. }
  869. ]
  870. def report_following_redirect(self, new_url):
  871. """Report information extraction."""
  872. self._downloader.to_screen('[redirect] Following redirect to %s' % new_url)
  873. def _extract_rss(self, url, video_id, doc):
  874. playlist_title = doc.find('./channel/title').text
  875. playlist_desc_el = doc.find('./channel/description')
  876. playlist_desc = None if playlist_desc_el is None else playlist_desc_el.text
  877. entries = []
  878. for it in doc.findall('./channel/item'):
  879. next_url = xpath_text(it, 'link', fatal=False)
  880. if not next_url:
  881. enclosure_nodes = it.findall('./enclosure')
  882. for e in enclosure_nodes:
  883. next_url = e.attrib.get('url')
  884. if next_url:
  885. break
  886. if not next_url:
  887. continue
  888. entries.append({
  889. '_type': 'url',
  890. 'url': next_url,
  891. 'title': it.find('title').text,
  892. })
  893. return {
  894. '_type': 'playlist',
  895. 'id': url,
  896. 'title': playlist_title,
  897. 'description': playlist_desc,
  898. 'entries': entries,
  899. }
  900. def _extract_camtasia(self, url, video_id, webpage):
  901. """ Returns None if no camtasia video can be found. """
  902. camtasia_cfg = self._search_regex(
  903. r'fo\.addVariable\(\s*"csConfigFile",\s*"([^"]+)"\s*\);',
  904. webpage, 'camtasia configuration file', default=None)
  905. if camtasia_cfg is None:
  906. return None
  907. title = self._html_search_meta('DC.title', webpage, fatal=True)
  908. camtasia_url = compat_urlparse.urljoin(url, camtasia_cfg)
  909. camtasia_cfg = self._download_xml(
  910. camtasia_url, video_id,
  911. note='Downloading camtasia configuration',
  912. errnote='Failed to download camtasia configuration')
  913. fileset_node = camtasia_cfg.find('./playlist/array/fileset')
  914. entries = []
  915. for n in fileset_node.getchildren():
  916. url_n = n.find('./uri')
  917. if url_n is None:
  918. continue
  919. entries.append({
  920. 'id': os.path.splitext(url_n.text.rpartition('/')[2])[0],
  921. 'title': '%s - %s' % (title, n.tag),
  922. 'url': compat_urlparse.urljoin(url, url_n.text),
  923. 'duration': float_or_none(n.find('./duration').text),
  924. })
  925. return {
  926. '_type': 'playlist',
  927. 'entries': entries,
  928. 'title': title,
  929. }
  930. def _real_extract(self, url):
  931. if url.startswith('//'):
  932. return {
  933. '_type': 'url',
  934. 'url': self.http_scheme() + url,
  935. }
  936. parsed_url = compat_urlparse.urlparse(url)
  937. if not parsed_url.scheme:
  938. default_search = self._downloader.params.get('default_search')
  939. if default_search is None:
  940. default_search = 'fixup_error'
  941. if default_search in ('auto', 'auto_warning', 'fixup_error'):
  942. if '/' in url:
  943. self._downloader.report_warning('The url doesn\'t specify the protocol, trying with http')
  944. return self.url_result('http://' + url)
  945. elif default_search != 'fixup_error':
  946. if default_search == 'auto_warning':
  947. if re.match(r'^(?:url|URL)$', url):
  948. raise ExtractorError(
  949. 'Invalid URL: %r . Call youtube-dl like this: youtube-dl -v "https://www.youtube.com/watch?v=BaW_jenozKc" ' % url,
  950. expected=True)
  951. else:
  952. self._downloader.report_warning(
  953. 'Falling back to youtube search for %s . Set --default-search "auto" to suppress this warning.' % url)
  954. return self.url_result('ytsearch:' + url)
  955. if default_search in ('error', 'fixup_error'):
  956. raise ExtractorError(
  957. '%r is not a valid URL. '
  958. 'Set --default-search "ytsearch" (or run youtube-dl "ytsearch:%s" ) to search YouTube'
  959. % (url, url), expected=True)
  960. else:
  961. if ':' not in default_search:
  962. default_search += ':'
  963. return self.url_result(default_search + url)
  964. url, smuggled_data = unsmuggle_url(url)
  965. force_videoid = None
  966. is_intentional = smuggled_data and smuggled_data.get('to_generic')
  967. if smuggled_data and 'force_videoid' in smuggled_data:
  968. force_videoid = smuggled_data['force_videoid']
  969. video_id = force_videoid
  970. else:
  971. video_id = compat_urllib_parse_unquote(os.path.splitext(url.rstrip('/').split('/')[-1])[0])
  972. self.to_screen('%s: Requesting header' % video_id)
  973. head_req = HEADRequest(url)
  974. head_response = self._request_webpage(
  975. head_req, video_id,
  976. note=False, errnote='Could not send HEAD request to %s' % url,
  977. fatal=False)
  978. if head_response is not False:
  979. # Check for redirect
  980. new_url = head_response.geturl()
  981. if url != new_url:
  982. self.report_following_redirect(new_url)
  983. if force_videoid:
  984. new_url = smuggle_url(
  985. new_url, {'force_videoid': force_videoid})
  986. return self.url_result(new_url)
  987. full_response = None
  988. if head_response is False:
  989. request = compat_urllib_request.Request(url)
  990. request.add_header('Accept-Encoding', '*')
  991. full_response = self._request_webpage(request, video_id)
  992. head_response = full_response
  993. # Check for direct link to a video
  994. content_type = head_response.headers.get('Content-Type', '')
  995. m = re.match(r'^(?P<type>audio|video|application(?=/ogg$))/(?P<format_id>.+)$', content_type)
  996. if m:
  997. upload_date = unified_strdate(
  998. head_response.headers.get('Last-Modified'))
  999. return {
  1000. 'id': video_id,
  1001. 'title': compat_urllib_parse_unquote(os.path.splitext(url_basename(url))[0]),
  1002. 'direct': True,
  1003. 'formats': [{
  1004. 'format_id': m.group('format_id'),
  1005. 'url': url,
  1006. 'vcodec': 'none' if m.group('type') == 'audio' else None
  1007. }],
  1008. 'upload_date': upload_date,
  1009. }
  1010. if not self._downloader.params.get('test', False) and not is_intentional:
  1011. force = self._downloader.params.get('force_generic_extractor', False)
  1012. self._downloader.report_warning(
  1013. '%s on generic information extractor.' % ('Forcing' if force else 'Falling back'))
  1014. if not full_response:
  1015. request = compat_urllib_request.Request(url)
  1016. # Some webservers may serve compressed content of rather big size (e.g. gzipped flac)
  1017. # making it impossible to download only chunk of the file (yet we need only 512kB to
  1018. # test whether it's HTML or not). According to youtube-dl default Accept-Encoding
  1019. # that will always result in downloading the whole file that is not desirable.
  1020. # Therefore for extraction pass we have to override Accept-Encoding to any in order
  1021. # to accept raw bytes and being able to download only a chunk.
  1022. # It may probably better to solve this by checking Content-Type for application/octet-stream
  1023. # after HEAD request finishes, but not sure if we can rely on this.
  1024. request.add_header('Accept-Encoding', '*')
  1025. full_response = self._request_webpage(request, video_id)
  1026. # Maybe it's a direct link to a video?
  1027. # Be careful not to download the whole thing!
  1028. first_bytes = full_response.read(512)
  1029. if not is_html(first_bytes):
  1030. self._downloader.report_warning(
  1031. 'URL could be a direct video link, returning it as such.')
  1032. upload_date = unified_strdate(
  1033. head_response.headers.get('Last-Modified'))
  1034. return {
  1035. 'id': video_id,
  1036. 'title': compat_urllib_parse_unquote(os.path.splitext(url_basename(url))[0]),
  1037. 'direct': True,
  1038. 'url': url,
  1039. 'upload_date': upload_date,
  1040. }
  1041. webpage = self._webpage_read_content(
  1042. full_response, url, video_id, prefix=first_bytes)
  1043. self.report_extraction(video_id)
  1044. # Is it an RSS feed?
  1045. try:
  1046. doc = parse_xml(webpage)
  1047. if doc.tag == 'rss':
  1048. return self._extract_rss(url, video_id, doc)
  1049. except compat_xml_parse_error:
  1050. pass
  1051. # Is it a Camtasia project?
  1052. camtasia_res = self._extract_camtasia(url, video_id, webpage)
  1053. if camtasia_res is not None:
  1054. return camtasia_res
  1055. # Sometimes embedded video player is hidden behind percent encoding
  1056. # (e.g. https://github.com/rg3/youtube-dl/issues/2448)
  1057. # Unescaping the whole page allows to handle those cases in a generic way
  1058. webpage = compat_urllib_parse.unquote(webpage)
  1059. # it's tempting to parse this further, but you would
  1060. # have to take into account all the variations like
  1061. # Video Title - Site Name
  1062. # Site Name | Video Title
  1063. # Video Title - Tagline | Site Name
  1064. # and so on and so forth; it's just not practical
  1065. video_title = self._html_search_regex(
  1066. r'(?s)<title>(.*?)</title>', webpage, 'video title',
  1067. default='video')
  1068. # Try to detect age limit automatically
  1069. age_limit = self._rta_search(webpage)
  1070. # And then there are the jokers who advertise that they use RTA,
  1071. # but actually don't.
  1072. AGE_LIMIT_MARKERS = [
  1073. r'Proudly Labeled <a href="http://www.rtalabel.org/" title="Restricted to Adults">RTA</a>',
  1074. ]
  1075. if any(re.search(marker, webpage) for marker in AGE_LIMIT_MARKERS):
  1076. age_limit = 18
  1077. # video uploader is domain name
  1078. video_uploader = self._search_regex(
  1079. r'^(?:https?://)?([^/]*)/.*', url, 'video uploader')
  1080. # Helper method
  1081. def _playlist_from_matches(matches, getter=None, ie=None):
  1082. urlrs = orderedSet(
  1083. self.url_result(self._proto_relative_url(getter(m) if getter else m), ie)
  1084. for m in matches)
  1085. return self.playlist_result(
  1086. urlrs, playlist_id=video_id, playlist_title=video_title)
  1087. # Look for BrightCove:
  1088. bc_urls = BrightcoveIE._extract_brightcove_urls(webpage)
  1089. if bc_urls:
  1090. self.to_screen('Brightcove video detected.')
  1091. entries = [{
  1092. '_type': 'url',
  1093. 'url': smuggle_url(bc_url, {'Referer': url}),
  1094. 'ie_key': 'Brightcove'
  1095. } for bc_url in bc_urls]
  1096. return {
  1097. '_type': 'playlist',
  1098. 'title': video_title,
  1099. 'id': video_id,
  1100. 'entries': entries,
  1101. }
  1102. # Look for embedded rtl.nl player
  1103. matches = re.findall(
  1104. r'<iframe[^>]+?src="((?:https?:)?//(?:www\.)?rtl\.nl/system/videoplayer/[^"]+(?:video_)?embed[^"]+)"',
  1105. webpage)
  1106. if matches:
  1107. return _playlist_from_matches(matches, ie='RtlNl')
  1108. vimeo_url = VimeoIE._extract_vimeo_url(url, webpage)
  1109. if vimeo_url is not None:
  1110. return self.url_result(vimeo_url)
  1111. # Look for embedded YouTube player
  1112. matches = re.findall(r'''(?x)
  1113. (?:
  1114. <iframe[^>]+?src=|
  1115. data-video-url=|
  1116. <embed[^>]+?src=|
  1117. embedSWF\(?:\s*|
  1118. new\s+SWFObject\(
  1119. )
  1120. (["\'])
  1121. (?P<url>(?:https?:)?//(?:www\.)?youtube(?:-nocookie)?\.com/
  1122. (?:embed|v|p)/.+?)
  1123. \1''', webpage)
  1124. if matches:
  1125. return _playlist_from_matches(
  1126. matches, lambda m: unescapeHTML(m[1]))
  1127. # Look for lazyYT YouTube embed
  1128. matches = re.findall(
  1129. r'class="lazyYT" data-youtube-id="([^"]+)"', webpage)
  1130. if matches:
  1131. return _playlist_from_matches(matches, lambda m: unescapeHTML(m))
  1132. # Look for embedded Dailymotion player
  1133. matches = re.findall(
  1134. r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?dailymotion\.com/embed/video/.+?)\1', webpage)
  1135. if matches:
  1136. return _playlist_from_matches(
  1137. matches, lambda m: unescapeHTML(m[1]))
  1138. # Look for embedded Dailymotion playlist player (#3822)
  1139. m = re.search(
  1140. r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?dailymotion\.[a-z]{2,3}/widget/jukebox\?.+?)\1', webpage)
  1141. if m:
  1142. playlists = re.findall(
  1143. r'list\[\]=/playlist/([^/]+)/', unescapeHTML(m.group('url')))
  1144. if playlists:
  1145. return _playlist_from_matches(
  1146. playlists, lambda p: '//dailymotion.com/playlist/%s' % p)
  1147. # Look for embedded Wistia player
  1148. match = re.search(
  1149. r'<(?:meta[^>]+?content|iframe[^>]+?src)=(["\'])(?P<url>(?:https?:)?//(?:fast\.)?wistia\.net/embed/iframe/.+?)\1', webpage)
  1150. if match:
  1151. embed_url = self._proto_relative_url(
  1152. unescapeHTML(match.group('url')))
  1153. return {
  1154. '_type': 'url_transparent',
  1155. 'url': embed_url,
  1156. 'ie_key': 'Wistia',
  1157. 'uploader': video_uploader,
  1158. 'title': video_title,
  1159. 'id': video_id,
  1160. }
  1161. match = re.search(r'(?:id=["\']wistia_|data-wistia-?id=["\']|Wistia\.embed\(["\'])(?P<id>[^"\']+)', webpage)
  1162. if match:
  1163. return {
  1164. '_type': 'url_transparent',
  1165. 'url': 'http://fast.wistia.net/embed/iframe/{0:}'.format(match.group('id')),
  1166. 'ie_key': 'Wistia',
  1167. 'uploader': video_uploader,
  1168. 'title': video_title,
  1169. 'id': match.group('id')
  1170. }
  1171. # Look for embedded blip.tv player
  1172. bliptv_url = BlipTVIE._extract_url(webpage)
  1173. if bliptv_url:
  1174. return self.url_result(bliptv_url, 'BlipTV')
  1175. # Look for SVT player
  1176. svt_url = SVTIE._extract_url(webpage)
  1177. if svt_url:
  1178. return self.url_result(svt_url, 'SVT')
  1179. # Look for embedded condenast player
  1180. matches = re.findall(
  1181. r'<iframe\s+(?:[a-zA-Z-]+="[^"]+"\s+)*?src="(https?://player\.cnevids\.com/embed/[^"]+")',
  1182. webpage)
  1183. if matches:
  1184. return {
  1185. '_type': 'playlist',
  1186. 'entries': [{
  1187. '_type': 'url',
  1188. 'ie_key': 'CondeNast',
  1189. 'url': ma,
  1190. } for ma in matches],
  1191. 'title': video_title,
  1192. 'id': video_id,
  1193. }
  1194. # Look for Bandcamp pages with custom domain
  1195. mobj = re.search(r'<meta property="og:url"[^>]*?content="(.*?bandcamp\.com.*?)"', webpage)
  1196. if mobj is not None:
  1197. burl = unescapeHTML(mobj.group(1))
  1198. # Don't set the extractor because it can be a track url or an album
  1199. return self.url_result(burl)
  1200. # Look for embedded Vevo player
  1201. mobj = re.search(
  1202. r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:cache\.)?vevo\.com/.+?)\1', webpage)
  1203. if mobj is not None:
  1204. return self.url_result(mobj.group('url'))
  1205. # Look for embedded Viddler player
  1206. mobj = re.search(
  1207. r'<(?:iframe[^>]+?src|param[^>]+?value)=(["\'])(?P<url>(?:https?:)?//(?:www\.)?viddler\.com/(?:embed|player)/.+?)\1',
  1208. webpage)
  1209. if mobj is not None:
  1210. return self.url_result(mobj.group('url'))
  1211. # Look for NYTimes player
  1212. mobj = re.search(
  1213. r'<iframe[^>]+src=(["\'])(?P<url>(?:https?:)?//graphics8\.nytimes\.com/bcvideo/[^/]+/iframe/embed\.html.+?)\1>',
  1214. webpage)
  1215. if mobj is not None:
  1216. return self.url_result(mobj.group('url'))
  1217. # Look for Libsyn player
  1218. mobj = re.search(
  1219. r'<iframe[^>]+src=(["\'])(?P<url>(?:https?:)?//html5-player\.libsyn\.com/embed/.+?)\1', webpage)
  1220. if mobj is not None:
  1221. return self.url_result(mobj.group('url'))
  1222. # Look for Ooyala videos
  1223. mobj = (re.search(r'player\.ooyala\.com/[^"?]+\?[^"]*?(?:embedCode|ec)=(?P<ec>[^"&]+)', webpage) or
  1224. re.search(r'OO\.Player\.create\([\'"].*?[\'"],\s*[\'"](?P<ec>.{32})[\'"]', webpage) or
  1225. re.search(r'SBN\.VideoLinkset\.ooyala\([\'"](?P<ec>.{32})[\'"]\)', webpage) or
  1226. re.search(r'data-ooyala-video-id\s*=\s*[\'"](?P<ec>.{32})[\'"]', webpage))
  1227. if mobj is not None:
  1228. return OoyalaIE._build_url_result(mobj.group('ec'))
  1229. # Look for multiple Ooyala embeds on SBN network websites
  1230. mobj = re.search(r'SBN\.VideoLinkset\.entryGroup\((\[.*?\])', webpage)
  1231. if mobj is not None:
  1232. embeds = self._parse_json(mobj.group(1), video_id, fatal=False)
  1233. if embeds:
  1234. return _playlist_from_matches(
  1235. embeds, getter=lambda v: OoyalaIE._url_for_embed_code(v['provider_video_id']), ie='Ooyala')
  1236. # Look for Aparat videos
  1237. mobj = re.search(r'<iframe .*?src="(http://www\.aparat\.com/video/[^"]+)"', webpage)
  1238. if mobj is not None:
  1239. return self.url_result(mobj.group(1), 'Aparat')
  1240. # Look for MPORA videos
  1241. mobj = re.search(r'<iframe .*?src="(http://mpora\.(?:com|de)/videos/[^"]+)"', webpage)
  1242. if mobj is not None:
  1243. return self.url_result(mobj.group(1), 'Mpora')
  1244. # Look for embedded NovaMov-based player
  1245. mobj = re.search(
  1246. r'''(?x)<(?:pagespeed_)?iframe[^>]+?src=(["\'])
  1247. (?P<url>http://(?:(?:embed|www)\.)?
  1248. (?:novamov\.com|
  1249. nowvideo\.(?:ch|sx|eu|at|ag|co)|
  1250. videoweed\.(?:es|com)|
  1251. movshare\.(?:net|sx|ag)|
  1252. divxstage\.(?:eu|net|ch|co|at|ag))
  1253. /embed\.php.+?)\1''', webpage)
  1254. if mobj is not None:
  1255. return self.url_result(mobj.group('url'))
  1256. # Look for embedded Facebook player
  1257. mobj = re.search(
  1258. r'<iframe[^>]+?src=(["\'])(?P<url>https://www\.facebook\.com/video/embed.+?)\1', webpage)
  1259. if mobj is not None:
  1260. return self.url_result(mobj.group('url'), 'Facebook')
  1261. # Look for embedded VK player
  1262. mobj = re.search(r'<iframe[^>]+?src=(["\'])(?P<url>https?://vk\.com/video_ext\.php.+?)\1', webpage)
  1263. if mobj is not None:
  1264. return self.url_result(mobj.group('url'), 'VK')
  1265. # Look for embedded ivi player
  1266. mobj = re.search(r'<embed[^>]+?src=(["\'])(?P<url>https?://(?:www\.)?ivi\.ru/video/player.+?)\1', webpage)
  1267. if mobj is not None:
  1268. return self.url_result(mobj.group('url'), 'Ivi')
  1269. # Look for embedded Huffington Post player
  1270. mobj = re.search(
  1271. r'<iframe[^>]+?src=(["\'])(?P<url>https?://embed\.live\.huffingtonpost\.com/.+?)\1', webpage)
  1272. if mobj is not None:
  1273. return self.url_result(mobj.group('url'), 'HuffPost')
  1274. # Look for embed.ly
  1275. mobj = re.search(r'class=["\']embedly-card["\'][^>]href=["\'](?P<url>[^"\']+)', webpage)
  1276. if mobj is not None:
  1277. return self.url_result(mobj.group('url'))
  1278. mobj = re.search(r'class=["\']embedly-embed["\'][^>]src=["\'][^"\']*url=(?P<url>[^&]+)', webpage)
  1279. if mobj is not None:
  1280. return self.url_result(compat_urllib_parse.unquote(mobj.group('url')))
  1281. # Look for funnyordie embed
  1282. matches = re.findall(r'<iframe[^>]+?src="(https?://(?:www\.)?funnyordie\.com/embed/[^"]+)"', webpage)
  1283. if matches:
  1284. return _playlist_from_matches(
  1285. matches, getter=unescapeHTML, ie='FunnyOrDie')
  1286. # Look for BBC iPlayer embed
  1287. matches = re.findall(r'setPlaylist\("(https?://www\.bbc\.co\.uk/iplayer/[^/]+/[\da-z]{8})"\)', webpage)
  1288. if matches:
  1289. return _playlist_from_matches(matches, ie='BBCCoUk')
  1290. # Look for embedded RUTV player
  1291. rutv_url = RUTVIE._extract_url(webpage)
  1292. if rutv_url:
  1293. return self.url_result(rutv_url, 'RUTV')
  1294. # Look for embedded TVC player
  1295. tvc_url = TVCIE._extract_url(webpage)
  1296. if tvc_url:
  1297. return self.url_result(tvc_url, 'TVC')
  1298. # Look for embedded SportBox player
  1299. sportbox_urls = SportBoxEmbedIE._extract_urls(webpage)
  1300. if sportbox_urls:
  1301. return _playlist_from_matches(sportbox_urls, ie='SportBoxEmbed')
  1302. # Look for embedded PornHub player
  1303. pornhub_url = PornHubIE._extract_url(webpage)
  1304. if pornhub_url:
  1305. return self.url_result(pornhub_url, 'PornHub')
  1306. # Look for embedded XHamster player
  1307. xhamster_urls = XHamsterEmbedIE._extract_urls(webpage)
  1308. if xhamster_urls:
  1309. return _playlist_from_matches(xhamster_urls, ie='XHamsterEmbed')
  1310. # Look for embedded Tvigle player
  1311. mobj = re.search(
  1312. r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//cloud\.tvigle\.ru/video/.+?)\1', webpage)
  1313. if mobj is not None:
  1314. return self.url_result(mobj.group('url'), 'Tvigle')
  1315. # Look for embedded TED player
  1316. mobj = re.search(
  1317. r'<iframe[^>]+?src=(["\'])(?P<url>https?://embed(?:-ssl)?\.ted\.com/.+?)\1', webpage)
  1318. if mobj is not None:
  1319. return self.url_result(mobj.group('url'), 'TED')
  1320. # Look for embedded Ustream videos
  1321. mobj = re.search(
  1322. r'<iframe[^>]+?src=(["\'])(?P<url>http://www\.ustream\.tv/embed/.+?)\1', webpage)
  1323. if mobj is not None:
  1324. return self.url_result(mobj.group('url'), 'Ustream')
  1325. # Look for embedded arte.tv player
  1326. mobj = re.search(
  1327. r'<script [^>]*?src="(?P<url>http://www\.arte\.tv/playerv2/embed[^"]+)"',
  1328. webpage)
  1329. if mobj is not None:
  1330. return self.url_result(mobj.group('url'), 'ArteTVEmbed')
  1331. # Look for embedded smotri.com player
  1332. smotri_url = SmotriIE._extract_url(webpage)
  1333. if smotri_url:
  1334. return self.url_result(smotri_url, 'Smotri')
  1335. # Look for embeded soundcloud player
  1336. mobj = re.search(
  1337. r'<iframe\s+(?:[a-zA-Z0-9_-]+="[^"]+"\s+)*src="(?P<url>https?://(?:w\.)?soundcloud\.com/player[^"]+)"',
  1338. webpage)
  1339. if mobj is not None:
  1340. url = unescapeHTML(mobj.group('url'))
  1341. return self.url_result(url)
  1342. # Look for embedded vulture.com player
  1343. mobj = re.search(
  1344. r'<iframe src="(?P<url>https?://video\.vulture\.com/[^"]+)"',
  1345. webpage)
  1346. if mobj is not None:
  1347. url = unescapeHTML(mobj.group('url'))
  1348. return self.url_result(url, ie='Vulture')
  1349. # Look for embedded mtvservices player
  1350. mobj = re.search(
  1351. r'<iframe src="(?P<url>https?://media\.mtvnservices\.com/embed/[^"]+)"',
  1352. webpage)
  1353. if mobj is not None:
  1354. url = unescapeHTML(mobj.group('url'))
  1355. return self.url_result(url, ie='MTVServicesEmbedded')
  1356. # Look for embedded yahoo player
  1357. mobj = re.search(
  1358. r'<iframe[^>]+?src=(["\'])(?P<url>https?://(?:screen|movies)\.yahoo\.com/.+?\.html\?format=embed)\1',
  1359. webpage)
  1360. if mobj is not None:
  1361. return self.url_result(mobj.group('url'), 'Yahoo')
  1362. # Look for embedded sbs.com.au player
  1363. mobj = re.search(
  1364. r'''(?x)
  1365. (?:
  1366. <meta\s+property="og:video"\s+content=|
  1367. <iframe[^>]+?src=
  1368. )
  1369. (["\'])(?P<url>https?://(?:www\.)?sbs\.com\.au/ondemand/video/.+?)\1''',
  1370. webpage)
  1371. if mobj is not None:
  1372. return self.url_result(mobj.group('url'), 'SBS')
  1373. # Look for embedded Cinchcast player
  1374. mobj = re.search(
  1375. r'<iframe[^>]+?src=(["\'])(?P<url>https?://player\.cinchcast\.com/.+?)\1',
  1376. webpage)
  1377. if mobj is not None:
  1378. return self.url_result(mobj.group('url'), 'Cinchcast')
  1379. mobj = re.search(
  1380. r'<iframe[^>]+?src=(["\'])(?P<url>https?://m(?:lb)?\.mlb\.com/shared/video/embed/embed\.html\?.+?)\1',
  1381. webpage)
  1382. if not mobj:
  1383. mobj = re.search(
  1384. r'data-video-link=["\'](?P<url>http://m.mlb.com/video/[^"\']+)',
  1385. webpage)
  1386. if mobj is not None:
  1387. return self.url_result(mobj.group('url'), 'MLB')
  1388. mobj = re.search(
  1389. r'<iframe[^>]+?src=(["\'])(?P<url>%s)\1' % CondeNastIE.EMBED_URL,
  1390. webpage)
  1391. if mobj is not None:
  1392. return self.url_result(self._proto_relative_url(mobj.group('url'), scheme='http:'), 'CondeNast')
  1393. mobj = re.search(
  1394. r'<iframe[^>]+src="(?P<url>https?://new\.livestream\.com/[^"]+/player[^"]+)"',
  1395. webpage)
  1396. if mobj is not None:
  1397. return self.url_result(mobj.group('url'), 'Livestream')
  1398. # Look for Zapiks embed
  1399. mobj = re.search(
  1400. r'<iframe[^>]+src="(?P<url>https?://(?:www\.)?zapiks\.fr/index\.php\?.+?)"', webpage)
  1401. if mobj is not None:
  1402. return self.url_result(mobj.group('url'), 'Zapiks')
  1403. # Look for Kaltura embeds
  1404. mobj = re.search(
  1405. r"(?s)kWidget\.(?:thumb)?[Ee]mbed\(\{.*?'wid'\s*:\s*'_?(?P<partner_id>[^']+)',.*?'entry_id'\s*:\s*'(?P<id>[^']+)',", webpage)
  1406. if mobj is not None:
  1407. return self.url_result('kaltura:%(partner_id)s:%(id)s' % mobj.groupdict(), 'Kaltura')
  1408. # Look for Eagle.Platform embeds
  1409. mobj = re.search(
  1410. r'<iframe[^>]+src="(?P<url>https?://.+?\.media\.eagleplatform\.com/index/player\?.+?)"', webpage)
  1411. if mobj is not None:
  1412. return self.url_result(mobj.group('url'), 'EaglePlatform')
  1413. # Look for ClipYou (uses Eagle.Platform) embeds
  1414. mobj = re.search(
  1415. r'<iframe[^>]+src="https?://(?P<host>media\.clipyou\.ru)/index/player\?.*\brecord_id=(?P<id>\d+).*"', webpage)
  1416. if mobj is not None:
  1417. return self.url_result('eagleplatform:%(host)s:%(id)s' % mobj.groupdict(), 'EaglePlatform')
  1418. # Look for Pladform embeds
  1419. mobj = re.search(
  1420. r'<iframe[^>]+src="(?P<url>https?://out\.pladform\.ru/player\?.+?)"', webpage)
  1421. if mobj is not None:
  1422. return self.url_result(mobj.group('url'), 'Pladform')
  1423. # Look for Playwire embeds
  1424. mobj = re.search(
  1425. r'<script[^>]+data-config=(["\'])(?P<url>(?:https?:)?//config\.playwire\.com/.+?)\1', webpage)
  1426. if mobj is not None:
  1427. return self.url_result(mobj.group('url'))
  1428. # Look for 5min embeds
  1429. mobj = re.search(
  1430. r'<meta[^>]+property="og:video"[^>]+content="https?://embed\.5min\.com/(?P<id>[0-9]+)/?', webpage)
  1431. if mobj is not None:
  1432. return self.url_result('5min:%s' % mobj.group('id'), 'FiveMin')
  1433. # Look for Crooks and Liars embeds
  1434. mobj = re.search(
  1435. r'<(?:iframe[^>]+src|param[^>]+value)=(["\'])(?P<url>(?:https?:)?//embed\.crooksandliars\.com/(?:embed|v)/.+?)\1', webpage)
  1436. if mobj is not None:
  1437. return self.url_result(mobj.group('url'))
  1438. # Look for NBC Sports VPlayer embeds
  1439. nbc_sports_url = NBCSportsVPlayerIE._extract_url(webpage)
  1440. if nbc_sports_url:
  1441. return self.url_result(nbc_sports_url, 'NBCSportsVPlayer')
  1442. # Look for UDN embeds
  1443. mobj = re.search(
  1444. r'<iframe[^>]+src="(?P<url>%s)"' % UDNEmbedIE._VALID_URL, webpage)
  1445. if mobj is not None:
  1446. return self.url_result(
  1447. compat_urlparse.urljoin(url, mobj.group('url')), 'UDNEmbed')
  1448. # Look for Senate ISVP iframe
  1449. senate_isvp_url = SenateISVPIE._search_iframe_url(webpage)
  1450. if senate_isvp_url:
  1451. return self.url_result(senate_isvp_url, 'SenateISVP')
  1452. # Look for Dailymotion Cloud videos
  1453. dmcloud_url = DailymotionCloudIE._extract_dmcloud_url(webpage)
  1454. if dmcloud_url:
  1455. return self.url_result(dmcloud_url, 'DailymotionCloud')
  1456. # Look for OnionStudios embeds
  1457. onionstudios_url = OnionStudiosIE._extract_url(webpage)
  1458. if onionstudios_url:
  1459. return self.url_result(onionstudios_url)
  1460. # Look for SnagFilms embeds
  1461. snagfilms_url = SnagFilmsEmbedIE._extract_url(webpage)
  1462. if snagfilms_url:
  1463. return self.url_result(snagfilms_url)
  1464. # Look for AdobeTVVideo embeds
  1465. mobj = re.search(
  1466. r'<iframe[^>]+src=[\'"]((?:https?:)?//video\.tv\.adobe\.com/v/\d+[^"]+)[\'"]',
  1467. webpage)
  1468. if mobj is not None:
  1469. return self.url_result(
  1470. self._proto_relative_url(unescapeHTML(mobj.group(1))),
  1471. 'AdobeTVVideo')
  1472. def check_video(vurl):
  1473. if YoutubeIE.suitable(vurl):
  1474. return True
  1475. vpath = compat_urlparse.urlparse(vurl).path
  1476. vext = determine_ext(vpath)
  1477. return '.' in vpath and vext not in ('swf', 'png', 'jpg', 'srt', 'sbv', 'sub', 'vtt', 'ttml')
  1478. def filter_video(urls):
  1479. return list(filter(check_video, urls))
  1480. # Start with something easy: JW Player in SWFObject
  1481. found = filter_video(re.findall(r'flashvars: [\'"](?:.*&)?file=(http[^\'"&]*)', webpage))
  1482. if not found:
  1483. # Look for gorilla-vid style embedding
  1484. found = filter_video(re.findall(r'''(?sx)
  1485. (?:
  1486. jw_plugins|
  1487. JWPlayerOptions|
  1488. jwplayer\s*\(\s*["'][^'"]+["']\s*\)\s*\.setup
  1489. )
  1490. .*?
  1491. ['"]?file['"]?\s*:\s*["\'](.*?)["\']''', webpage))
  1492. if not found:
  1493. # Broaden the search a little bit
  1494. found = filter_video(re.findall(r'[^A-Za-z0-9]?(?:file|source)=(http[^\'"&]*)', webpage))
  1495. if not found:
  1496. # Broaden the findall a little bit: JWPlayer JS loader
  1497. found = filter_video(re.findall(
  1498. r'[^A-Za-z0-9]?file["\']?:\s*["\'](http(?![^\'"]+\.[0-9]+[\'"])[^\'"]+)["\']', webpage))
  1499. if not found:
  1500. # Flow player
  1501. found = filter_video(re.findall(r'''(?xs)
  1502. flowplayer\("[^"]+",\s*
  1503. \{[^}]+?\}\s*,
  1504. \s*\{[^}]+? ["']?clip["']?\s*:\s*\{\s*
  1505. ["']?url["']?\s*:\s*["']([^"']+)["']
  1506. ''', webpage))
  1507. if not found:
  1508. # Cinerama player
  1509. found = re.findall(
  1510. r"cinerama\.embedPlayer\(\s*\'[^']+\',\s*'([^']+)'", webpage)
  1511. if not found:
  1512. # Try to find twitter cards info
  1513. found = filter_video(re.findall(
  1514. r'<meta (?:property|name)="twitter:player:stream" (?:content|value)="(.+?)"', webpage))
  1515. if not found:
  1516. # We look for Open Graph info:
  1517. # We have to match any number spaces between elements, some sites try to align them (eg.: statigr.am)
  1518. m_video_type = re.findall(r'<meta.*?property="og:video:type".*?content="video/(.*?)"', webpage)
  1519. # We only look in og:video if the MIME type is a video, don't try if it's a Flash player:
  1520. if m_video_type is not None:
  1521. found = filter_video(re.findall(r'<meta.*?property="og:video".*?content="(.*?)"', webpage))
  1522. if not found:
  1523. # HTML5 video
  1524. found = re.findall(r'(?s)<video[^<]*(?:>.*?<source[^>]*)?\s+src=["\'](.*?)["\']', webpage)
  1525. if not found:
  1526. REDIRECT_REGEX = r'[0-9]{,2};\s*(?:URL|url)=\'?([^\'"]+)'
  1527. found = re.search(
  1528. r'(?i)<meta\s+(?=(?:[a-z-]+="[^"]+"\s+)*http-equiv="refresh")'
  1529. r'(?:[a-z-]+="[^"]+"\s+)*?content="%s' % REDIRECT_REGEX,
  1530. webpage)
  1531. if not found:
  1532. # Look also in Refresh HTTP header
  1533. refresh_header = head_response.headers.get('Refresh')
  1534. if refresh_header:
  1535. found = re.search(REDIRECT_REGEX, refresh_header)
  1536. if found:
  1537. new_url = compat_urlparse.urljoin(url, found.group(1))
  1538. self.report_following_redirect(new_url)
  1539. return {
  1540. '_type': 'url',
  1541. 'url': new_url,
  1542. }
  1543. if not found:
  1544. raise UnsupportedError(url)
  1545. entries = []
  1546. for video_url in found:
  1547. video_url = compat_urlparse.urljoin(url, video_url)
  1548. video_id = compat_urllib_parse.unquote(os.path.basename(video_url))
  1549. # Sometimes, jwplayer extraction will result in a YouTube URL
  1550. if YoutubeIE.suitable(video_url):
  1551. entries.append(self.url_result(video_url, 'Youtube'))
  1552. continue
  1553. # here's a fun little line of code for you:
  1554. video_id = os.path.splitext(video_id)[0]
  1555. if determine_ext(video_url) == 'smil':
  1556. entries.append({
  1557. 'id': video_id,
  1558. 'formats': self._extract_smil_formats(video_url, video_id),
  1559. 'uploader': video_uploader,
  1560. 'title': video_title,
  1561. 'age_limit': age_limit,
  1562. })
  1563. else:
  1564. entries.append({
  1565. 'id': video_id,
  1566. 'url': video_url,
  1567. 'uploader': video_uploader,
  1568. 'title': video_title,
  1569. 'age_limit': age_limit,
  1570. })
  1571. if len(entries) == 1:
  1572. return entries[0]
  1573. else:
  1574. for num, e in enumerate(entries, start=1):
  1575. # 'url' results don't have a title
  1576. if e.get('title') is not None:
  1577. e['title'] = '%s (%d)' % (e['title'], num)
  1578. return {
  1579. '_type': 'playlist',
  1580. 'entries': entries,
  1581. }