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.

1613 lines
64 KiB

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