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.

1748 lines
70 KiB

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