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.

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