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.

1883 lines
75 KiB

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