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.

1398 lines
55 KiB

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