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.

1722 lines
69 KiB

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