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.

1378 lines
54 KiB

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