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.

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