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.

1546 lines
61 KiB

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