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.

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