2
0

generic.py 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377
  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_urlparse,
  10. compat_xml_parse_error,
  11. )
  12. from ..utils import (
  13. determine_ext,
  14. ExtractorError,
  15. float_or_none,
  16. HEADRequest,
  17. is_html,
  18. orderedSet,
  19. parse_xml,
  20. smuggle_url,
  21. unescapeHTML,
  22. unified_strdate,
  23. unsmuggle_url,
  24. UnsupportedError,
  25. url_basename,
  26. xpath_text,
  27. )
  28. from .brightcove import BrightcoveIE
  29. from .nbc import NBCSportsVPlayerIE
  30. from .ooyala import OoyalaIE
  31. from .rutv import RUTVIE
  32. from .smotri import SmotriIE
  33. from .condenast import CondeNastIE
  34. class GenericIE(InfoExtractor):
  35. IE_DESC = 'Generic downloader that works on some sites'
  36. _VALID_URL = r'.*'
  37. IE_NAME = 'generic'
  38. _TESTS = [
  39. {
  40. 'url': 'http://www.hodiho.fr/2013/02/regis-plante-sa-jeep.html',
  41. 'md5': '85b90ccc9d73b4acd9138d3af4c27f89',
  42. 'info_dict': {
  43. 'id': '13601338388002',
  44. 'ext': 'mp4',
  45. 'uploader': 'www.hodiho.fr',
  46. 'title': 'R\u00e9gis plante sa Jeep',
  47. }
  48. },
  49. # bandcamp page with custom domain
  50. {
  51. 'add_ie': ['Bandcamp'],
  52. 'url': 'http://bronyrock.com/track/the-pony-mash',
  53. 'info_dict': {
  54. 'id': '3235767654',
  55. 'ext': 'mp3',
  56. 'title': 'The Pony Mash',
  57. 'uploader': 'M_Pallante',
  58. },
  59. 'skip': 'There is a limit of 200 free downloads / month for the test song',
  60. },
  61. # embedded brightcove video
  62. # it also tests brightcove videos that need to set the 'Referer' in the
  63. # http requests
  64. {
  65. 'add_ie': ['Brightcove'],
  66. 'url': 'http://www.bfmtv.com/video/bfmbusiness/cours-bourse/cours-bourse-l-analyse-technique-154522/',
  67. 'info_dict': {
  68. 'id': '2765128793001',
  69. 'ext': 'mp4',
  70. 'title': 'Le cours de bourse : l’analyse technique',
  71. 'description': 'md5:7e9ad046e968cb2d1114004aba466fd9',
  72. 'uploader': 'BFM BUSINESS',
  73. },
  74. 'params': {
  75. 'skip_download': True,
  76. },
  77. },
  78. {
  79. # https://github.com/rg3/youtube-dl/issues/2253
  80. 'url': 'http://bcove.me/i6nfkrc3',
  81. 'md5': '0ba9446db037002366bab3b3eb30c88c',
  82. 'info_dict': {
  83. 'id': '3101154703001',
  84. 'ext': 'mp4',
  85. 'title': 'Still no power',
  86. 'uploader': 'thestar.com',
  87. '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.',
  88. },
  89. 'add_ie': ['Brightcove'],
  90. },
  91. {
  92. 'url': 'http://www.championat.com/video/football/v/87/87499.html',
  93. 'md5': 'fb973ecf6e4a78a67453647444222983',
  94. 'info_dict': {
  95. 'id': '3414141473001',
  96. 'ext': 'mp4',
  97. 'title': 'Видео. Удаление Дзагоева (ЦСКА)',
  98. 'description': 'Онлайн-трансляция матча ЦСКА - "Волга"',
  99. 'uploader': 'Championat',
  100. },
  101. },
  102. {
  103. # https://github.com/rg3/youtube-dl/issues/3541
  104. 'add_ie': ['Brightcove'],
  105. 'url': 'http://www.kijk.nl/sbs6/leermijvrouwenkennen/videos/jqMiXKAYan2S/aflevering-1',
  106. 'info_dict': {
  107. 'id': '3866516442001',
  108. 'ext': 'mp4',
  109. 'title': 'Leer mij vrouwen kennen: Aflevering 1',
  110. 'description': 'Leer mij vrouwen kennen: Aflevering 1',
  111. 'uploader': 'SBS Broadcasting',
  112. },
  113. 'skip': 'Restricted to Netherlands',
  114. 'params': {
  115. 'skip_download': True, # m3u8 download
  116. },
  117. },
  118. # Direct link to a video
  119. {
  120. 'url': 'http://media.w3.org/2010/05/sintel/trailer.mp4',
  121. 'md5': '67d406c2bcb6af27fa886f31aa934bbe',
  122. 'info_dict': {
  123. 'id': 'trailer',
  124. 'ext': 'mp4',
  125. 'title': 'trailer',
  126. 'upload_date': '20100513',
  127. }
  128. },
  129. # ooyala video
  130. {
  131. 'url': 'http://www.rollingstone.com/music/videos/norwegian-dj-cashmere-cat-goes-spartan-on-with-me-premiere-20131219',
  132. 'md5': '166dd577b433b4d4ebfee10b0824d8ff',
  133. 'info_dict': {
  134. 'id': 'BwY2RxaTrTkslxOfcan0UCf0YqyvWysJ',
  135. 'ext': 'mp4',
  136. 'title': '2cc213299525360.mov', # that's what we get
  137. },
  138. 'add_ie': ['Ooyala'],
  139. },
  140. # multiple ooyala embeds on SBN network websites
  141. {
  142. 'url': 'http://www.sbnation.com/college-football-recruiting/2015/2/3/7970291/national-signing-day-rationalizations-itll-be-ok-itll-be-ok',
  143. 'info_dict': {
  144. 'id': 'national-signing-day-rationalizations-itll-be-ok-itll-be-ok',
  145. 'title': '25 lies you will tell yourself on National Signing Day - SBNation.com',
  146. },
  147. 'playlist_mincount': 3,
  148. 'params': {
  149. 'skip_download': True,
  150. },
  151. 'add_ie': ['Ooyala'],
  152. },
  153. # google redirect
  154. {
  155. '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',
  156. 'info_dict': {
  157. 'id': 'cmQHVoWB5FY',
  158. 'ext': 'mp4',
  159. 'upload_date': '20130224',
  160. 'uploader_id': 'TheVerge',
  161. 'description': 're:^Chris Ziegler takes a look at the\.*',
  162. 'uploader': 'The Verge',
  163. 'title': 'First Firefox OS phones side-by-side',
  164. },
  165. 'params': {
  166. 'skip_download': False,
  167. }
  168. },
  169. # embed.ly video
  170. {
  171. 'url': 'http://www.tested.com/science/weird/460206-tested-grinding-coffee-2000-frames-second/',
  172. 'info_dict': {
  173. 'id': '9ODmcdjQcHQ',
  174. 'ext': 'mp4',
  175. 'title': 'Tested: Grinding Coffee at 2000 Frames Per Second',
  176. 'upload_date': '20140225',
  177. 'description': 'md5:06a40fbf30b220468f1e0957c0f558ff',
  178. 'uploader': 'Tested',
  179. 'uploader_id': 'testedcom',
  180. },
  181. # No need to test YoutubeIE here
  182. 'params': {
  183. 'skip_download': True,
  184. },
  185. },
  186. # funnyordie embed
  187. {
  188. 'url': 'http://www.theguardian.com/world/2014/mar/11/obama-zach-galifianakis-between-two-ferns',
  189. 'info_dict': {
  190. 'id': '18e820ec3f',
  191. 'ext': 'mp4',
  192. 'title': 'Between Two Ferns with Zach Galifianakis: President Barack Obama',
  193. 'description': 'Episode 18: President Barack Obama sits down with Zach Galifianakis for his most memorable interview yet.',
  194. },
  195. },
  196. # BBC iPlayer embeds
  197. {
  198. 'url': 'http://www.bbc.co.uk/blogs/adamcurtis/posts/BUGGER',
  199. 'info_dict': {
  200. 'title': 'BBC - Blogs - Adam Curtis - BUGGER',
  201. },
  202. 'playlist_mincount': 18,
  203. },
  204. # RUTV embed
  205. {
  206. 'url': 'http://www.rg.ru/2014/03/15/reg-dfo/anklav-anons.html',
  207. 'info_dict': {
  208. 'id': '776940',
  209. 'ext': 'mp4',
  210. 'title': 'Охотское море стало целиком российским',
  211. 'description': 'md5:5ed62483b14663e2a95ebbe115eb8f43',
  212. },
  213. 'params': {
  214. # m3u8 download
  215. 'skip_download': True,
  216. },
  217. },
  218. # Embedded TED video
  219. {
  220. 'url': 'http://en.support.wordpress.com/videos/ted-talks/',
  221. 'md5': '65fdff94098e4a607385a60c5177c638',
  222. 'info_dict': {
  223. 'id': '1969',
  224. 'ext': 'mp4',
  225. 'title': 'Hidden miracles of the natural world',
  226. 'uploader': 'Louie Schwartzberg',
  227. 'description': 'md5:8145d19d320ff3e52f28401f4c4283b9',
  228. }
  229. },
  230. # Embeded Ustream video
  231. {
  232. 'url': 'http://www.american.edu/spa/pti/nsa-privacy-janus-2014.cfm',
  233. 'md5': '27b99cdb639c9b12a79bca876a073417',
  234. 'info_dict': {
  235. 'id': '45734260',
  236. 'ext': 'flv',
  237. 'uploader': 'AU SPA: The NSA and Privacy',
  238. 'title': 'NSA and Privacy Forum Debate featuring General Hayden and Barton Gellman'
  239. }
  240. },
  241. # nowvideo embed hidden behind percent encoding
  242. {
  243. 'url': 'http://www.waoanime.tv/the-super-dimension-fortress-macross-episode-1/',
  244. 'md5': '2baf4ddd70f697d94b1c18cf796d5107',
  245. 'info_dict': {
  246. 'id': '06e53103ca9aa',
  247. 'ext': 'flv',
  248. 'title': 'Macross Episode 001 Watch Macross Episode 001 onl',
  249. 'description': 'No description',
  250. },
  251. },
  252. # arte embed
  253. {
  254. 'url': 'http://www.tv-replay.fr/redirection/20-03-14/x-enius-arte-10753389.html',
  255. 'md5': '7653032cbb25bf6c80d80f217055fa43',
  256. 'info_dict': {
  257. 'id': '048195-004_PLUS7-F',
  258. 'ext': 'flv',
  259. 'title': 'X:enius',
  260. 'description': 'md5:d5fdf32ef6613cdbfd516ae658abf168',
  261. 'upload_date': '20140320',
  262. },
  263. 'params': {
  264. 'skip_download': 'Requires rtmpdump'
  265. }
  266. },
  267. # Condé Nast embed
  268. {
  269. 'url': 'http://www.wired.com/2014/04/honda-asimo/',
  270. 'md5': 'ba0dfe966fa007657bd1443ee672db0f',
  271. 'info_dict': {
  272. 'id': '53501be369702d3275860000',
  273. 'ext': 'mp4',
  274. 'title': 'Honda’s New Asimo Robot Is More Human Than Ever',
  275. }
  276. },
  277. # Dailymotion embed
  278. {
  279. 'url': 'http://www.spi0n.com/zap-spi0n-com-n216/',
  280. 'md5': '441aeeb82eb72c422c7f14ec533999cd',
  281. 'info_dict': {
  282. 'id': 'k2mm4bCdJ6CQ2i7c8o2',
  283. 'ext': 'mp4',
  284. 'title': 'Le Zap de Spi0n n°216 - Zapping du Web',
  285. 'uploader': 'Spi0n',
  286. },
  287. 'add_ie': ['Dailymotion'],
  288. },
  289. # YouTube embed
  290. {
  291. 'url': 'http://www.badzine.de/ansicht/datum/2014/06/09/so-funktioniert-die-neue-englische-badminton-liga.html',
  292. 'info_dict': {
  293. 'id': 'FXRb4ykk4S0',
  294. 'ext': 'mp4',
  295. 'title': 'The NBL Auction 2014',
  296. 'uploader': 'BADMINTON England',
  297. 'uploader_id': 'BADMINTONEvents',
  298. 'upload_date': '20140603',
  299. 'description': 'md5:9ef128a69f1e262a700ed83edb163a73',
  300. },
  301. 'add_ie': ['Youtube'],
  302. 'params': {
  303. 'skip_download': True,
  304. }
  305. },
  306. # MTVSercices embed
  307. {
  308. 'url': 'http://www.gametrailers.com/news-post/76093/north-america-europe-is-getting-that-mario-kart-8-mercedes-dlc-too',
  309. 'md5': '35727f82f58c76d996fc188f9755b0d5',
  310. 'info_dict': {
  311. 'id': '0306a69b-8adf-4fb5-aace-75f8e8cbfca9',
  312. 'ext': 'mp4',
  313. 'title': 'Review',
  314. 'description': 'Mario\'s life in the fast lane has never looked so good.',
  315. },
  316. },
  317. # YouTube embed via <data-embed-url="">
  318. {
  319. 'url': 'https://play.google.com/store/apps/details?id=com.gameloft.android.ANMP.GloftA8HM',
  320. 'info_dict': {
  321. 'id': '4vAffPZIT44',
  322. 'ext': 'mp4',
  323. 'title': 'Asphalt 8: Airborne - Update - Welcome to Dubai!',
  324. 'uploader': 'Gameloft',
  325. 'uploader_id': 'gameloft',
  326. 'upload_date': '20140828',
  327. 'description': 'md5:c80da9ed3d83ae6d1876c834de03e1c4',
  328. },
  329. 'params': {
  330. 'skip_download': True,
  331. }
  332. },
  333. # Camtasia studio
  334. {
  335. 'url': 'http://www.ll.mit.edu/workshops/education/videocourses/antennas/lecture1/video/',
  336. 'playlist': [{
  337. 'md5': '0c5e352edabf715d762b0ad4e6d9ee67',
  338. 'info_dict': {
  339. 'id': 'Fenn-AA_PA_Radar_Course_Lecture_1c_Final',
  340. 'title': 'Fenn-AA_PA_Radar_Course_Lecture_1c_Final - video1',
  341. 'ext': 'flv',
  342. 'duration': 2235.90,
  343. }
  344. }, {
  345. 'md5': '10e4bb3aaca9fd630e273ff92d9f3c63',
  346. 'info_dict': {
  347. 'id': 'Fenn-AA_PA_Radar_Course_Lecture_1c_Final_PIP',
  348. 'title': 'Fenn-AA_PA_Radar_Course_Lecture_1c_Final - pip',
  349. 'ext': 'flv',
  350. 'duration': 2235.93,
  351. }
  352. }],
  353. 'info_dict': {
  354. 'title': 'Fenn-AA_PA_Radar_Course_Lecture_1c_Final',
  355. }
  356. },
  357. # Flowplayer
  358. {
  359. 'url': 'http://www.handjobhub.com/video/busty-blonde-siri-tit-fuck-while-wank-6313.html',
  360. 'md5': '9d65602bf31c6e20014319c7d07fba27',
  361. 'info_dict': {
  362. 'id': '5123ea6d5e5a7',
  363. 'ext': 'mp4',
  364. 'age_limit': 18,
  365. 'uploader': 'www.handjobhub.com',
  366. 'title': 'Busty Blonde Siri Tit Fuck While Wank at HandjobHub.com',
  367. }
  368. },
  369. # RSS feed
  370. {
  371. 'url': 'http://phihag.de/2014/youtube-dl/rss2.xml',
  372. 'info_dict': {
  373. 'id': 'http://phihag.de/2014/youtube-dl/rss2.xml',
  374. 'title': 'Zero Punctuation',
  375. 'description': 're:.*groundbreaking video review series.*'
  376. },
  377. 'playlist_mincount': 11,
  378. },
  379. # Multiple brightcove videos
  380. # https://github.com/rg3/youtube-dl/issues/2283
  381. {
  382. 'url': 'http://www.newyorker.com/online/blogs/newsdesk/2014/01/always-never-nuclear-command-and-control.html',
  383. 'info_dict': {
  384. 'id': 'always-never',
  385. 'title': 'Always / Never - The New Yorker',
  386. },
  387. 'playlist_count': 3,
  388. 'params': {
  389. 'extract_flat': False,
  390. 'skip_download': True,
  391. }
  392. },
  393. # MLB embed
  394. {
  395. 'url': 'http://umpire-empire.com/index.php/topic/58125-laz-decides-no-thats-low/',
  396. 'md5': '96f09a37e44da40dd083e12d9a683327',
  397. 'info_dict': {
  398. 'id': '33322633',
  399. 'ext': 'mp4',
  400. 'title': 'Ump changes call to ball',
  401. 'description': 'md5:71c11215384298a172a6dcb4c2e20685',
  402. 'duration': 48,
  403. 'timestamp': 1401537900,
  404. 'upload_date': '20140531',
  405. 'thumbnail': 're:^https?://.*\.jpg$',
  406. },
  407. },
  408. # Wistia embed
  409. {
  410. 'url': 'http://education-portal.com/academy/lesson/north-american-exploration-failed-colonies-of-spain-france-england.html#lesson',
  411. 'md5': '8788b683c777a5cf25621eaf286d0c23',
  412. 'info_dict': {
  413. 'id': '1cfaf6b7ea',
  414. 'ext': 'mov',
  415. 'title': 'md5:51364a8d3d009997ba99656004b5e20d',
  416. 'duration': 643.0,
  417. 'filesize': 182808282,
  418. 'uploader': 'education-portal.com',
  419. },
  420. },
  421. {
  422. 'url': 'http://thoughtworks.wistia.com/medias/uxjb0lwrcz',
  423. 'md5': 'baf49c2baa8a7de5f3fc145a8506dcd4',
  424. 'info_dict': {
  425. 'id': 'uxjb0lwrcz',
  426. 'ext': 'mp4',
  427. 'title': 'Conversation about Hexagonal Rails Part 1 - ThoughtWorks',
  428. 'duration': 1715.0,
  429. 'uploader': 'thoughtworks.wistia.com',
  430. },
  431. },
  432. # Direct download with broken HEAD
  433. {
  434. 'url': 'http://ai-radio.org:8000/radio.opus',
  435. 'info_dict': {
  436. 'id': 'radio',
  437. 'ext': 'opus',
  438. 'title': 'radio',
  439. },
  440. 'params': {
  441. 'skip_download': True, # infinite live stream
  442. },
  443. 'expected_warnings': [
  444. r'501.*Not Implemented'
  445. ],
  446. },
  447. # Soundcloud embed
  448. {
  449. 'url': 'http://nakedsecurity.sophos.com/2014/10/29/sscc-171-are-you-sure-that-1234-is-a-bad-password-podcast/',
  450. 'info_dict': {
  451. 'id': '174391317',
  452. 'ext': 'mp3',
  453. 'description': 'md5:ff867d6b555488ad3c52572bb33d432c',
  454. 'uploader': 'Sophos Security',
  455. 'title': 'Chet Chat 171 - Oct 29, 2014',
  456. 'upload_date': '20141029',
  457. }
  458. },
  459. # Livestream embed
  460. {
  461. 'url': 'http://www.esa.int/Our_Activities/Space_Science/Rosetta/Philae_comet_touch-down_webcast',
  462. 'info_dict': {
  463. 'id': '67864563',
  464. 'ext': 'flv',
  465. 'upload_date': '20141112',
  466. 'title': 'Rosetta #CometLanding webcast HL 10',
  467. }
  468. },
  469. # LazyYT
  470. {
  471. 'url': 'http://discourse.ubuntu.com/t/unity-8-desktop-mode-windows-on-mir/1986',
  472. 'info_dict': {
  473. 'id': '1986',
  474. 'title': 'Unity 8 desktop-mode windows on Mir! - Ubuntu Discourse',
  475. },
  476. 'playlist_mincount': 2,
  477. },
  478. # Direct link with incorrect MIME type
  479. {
  480. 'url': 'http://ftp.nluug.nl/video/nluug/2014-11-20_nj14/zaal-2/5_Lennart_Poettering_-_Systemd.webm',
  481. 'md5': '4ccbebe5f36706d85221f204d7eb5913',
  482. 'info_dict': {
  483. 'url': 'http://ftp.nluug.nl/video/nluug/2014-11-20_nj14/zaal-2/5_Lennart_Poettering_-_Systemd.webm',
  484. 'id': '5_Lennart_Poettering_-_Systemd',
  485. 'ext': 'webm',
  486. 'title': '5_Lennart_Poettering_-_Systemd',
  487. 'upload_date': '20141120',
  488. },
  489. 'expected_warnings': [
  490. 'URL could be a direct video link, returning it as such.'
  491. ]
  492. },
  493. # Cinchcast embed
  494. {
  495. 'url': 'http://undergroundwellness.com/podcasts/306-5-steps-to-permanent-gut-healing/',
  496. 'info_dict': {
  497. 'id': '7141703',
  498. 'ext': 'mp3',
  499. 'upload_date': '20141126',
  500. 'title': 'Jack Tips: 5 Steps to Permanent Gut Healing',
  501. }
  502. },
  503. # Cinerama player
  504. {
  505. 'url': 'http://www.abc.net.au/7.30/content/2015/s4164797.htm',
  506. 'info_dict': {
  507. 'id': '730m_DandD_1901_512k',
  508. 'ext': 'mp4',
  509. 'uploader': 'www.abc.net.au',
  510. 'title': 'Game of Thrones with dice - Dungeons and Dragons fantasy role-playing game gets new life - 19/01/2015',
  511. }
  512. },
  513. # embedded viddler video
  514. {
  515. 'url': 'http://deadspin.com/i-cant-stop-watching-john-wall-chop-the-nuggets-with-th-1681801597',
  516. 'info_dict': {
  517. 'id': '4d03aad9',
  518. 'ext': 'mp4',
  519. 'uploader': 'deadspin',
  520. 'title': 'WALL-TO-GORTAT',
  521. 'timestamp': 1422285291,
  522. 'upload_date': '20150126',
  523. },
  524. 'add_ie': ['Viddler'],
  525. },
  526. # Libsyn embed
  527. {
  528. 'url': 'http://thedailyshow.cc.com/podcast/episodetwelve',
  529. 'info_dict': {
  530. 'id': '3377616',
  531. 'ext': 'mp3',
  532. 'title': "The Daily Show Podcast without Jon Stewart - Episode 12: Bassem Youssef: Egypt's Jon Stewart",
  533. 'description': 'md5:601cb790edd05908957dae8aaa866465',
  534. 'upload_date': '20150220',
  535. },
  536. },
  537. # jwplayer YouTube
  538. {
  539. 'url': 'http://media.nationalarchives.gov.uk/index.php/webinar-using-discovery-national-archives-online-catalogue/',
  540. 'info_dict': {
  541. 'id': 'Mrj4DVp2zeA',
  542. 'ext': 'mp4',
  543. 'upload_date': '20150212',
  544. 'uploader': 'The National Archives UK',
  545. 'description': 'md5:a236581cd2449dd2df4f93412f3f01c6',
  546. 'uploader_id': 'NationalArchives08',
  547. 'title': 'Webinar: Using Discovery, The National Archives’ online catalogue',
  548. },
  549. },
  550. # rtl.nl embed
  551. {
  552. 'url': 'http://www.rtlnieuws.nl/nieuws/buitenland/aanslagen-kopenhagen',
  553. 'playlist_mincount': 5,
  554. 'info_dict': {
  555. 'id': 'aanslagen-kopenhagen',
  556. 'title': 'Aanslagen Kopenhagen | RTL Nieuws',
  557. }
  558. },
  559. # Zapiks embed
  560. {
  561. 'url': 'http://www.skipass.com/news/116090-bon-appetit-s5ep3-baqueira-mi-cor.html',
  562. 'info_dict': {
  563. 'id': '118046',
  564. 'ext': 'mp4',
  565. 'title': 'EP3S5 - Bon Appétit - Baqueira Mi Corazon !',
  566. }
  567. },
  568. # Kaltura embed
  569. {
  570. 'url': 'http://www.monumentalnetwork.com/videos/john-carlson-postgame-2-25-15',
  571. 'info_dict': {
  572. 'id': '1_eergr3h1',
  573. 'ext': 'mp4',
  574. 'upload_date': '20150226',
  575. 'uploader_id': 'MonumentalSports-Kaltura@perfectsensedigital.com',
  576. 'timestamp': int,
  577. 'title': 'John Carlson Postgame 2/25/15',
  578. },
  579. },
  580. # Eagle.Platform embed (generic URL)
  581. {
  582. 'url': 'http://lenta.ru/news/2015/03/06/navalny/',
  583. 'info_dict': {
  584. 'id': '227304',
  585. 'ext': 'mp4',
  586. 'title': 'Навальный вышел на свободу',
  587. 'description': 'md5:d97861ac9ae77377f3f20eaf9d04b4f5',
  588. 'thumbnail': 're:^https?://.*\.jpg$',
  589. 'duration': 87,
  590. 'view_count': int,
  591. 'age_limit': 0,
  592. },
  593. },
  594. # ClipYou (Eagle.Platform) embed (custom URL)
  595. {
  596. 'url': 'http://muz-tv.ru/play/7129/',
  597. 'info_dict': {
  598. 'id': '12820',
  599. 'ext': 'mp4',
  600. 'title': "'O Sole Mio",
  601. 'thumbnail': 're:^https?://.*\.jpg$',
  602. 'duration': 216,
  603. 'view_count': int,
  604. },
  605. },
  606. # Pladform embed
  607. {
  608. 'url': 'http://muz-tv.ru/kinozal/view/7400/',
  609. 'info_dict': {
  610. 'id': '100183293',
  611. 'ext': 'mp4',
  612. 'title': 'Тайны перевала Дятлова • Тайна перевала Дятлова 1 серия 2 часть',
  613. 'description': 'Документальный сериал-расследование одной из самых жутких тайн ХХ века',
  614. 'thumbnail': 're:^https?://.*\.jpg$',
  615. 'duration': 694,
  616. 'age_limit': 0,
  617. },
  618. },
  619. # 5min embed
  620. {
  621. 'url': 'http://techcrunch.com/video/facebook-creates-on-this-day-crunch-report/518726732/',
  622. 'md5': '4c6f127a30736b59b3e2c19234ee2bf7',
  623. 'info_dict': {
  624. 'id': '518726732',
  625. 'ext': 'mp4',
  626. 'title': 'Facebook Creates "On This Day" | Crunch Report',
  627. },
  628. },
  629. # RSS feed with enclosure
  630. {
  631. 'url': 'http://podcastfeeds.nbcnews.com/audio/podcast/MSNBC-MADDOW-NETCAST-M4V.xml',
  632. 'info_dict': {
  633. 'id': 'pdv_maddow_netcast_m4v-02-27-2015-201624',
  634. 'ext': 'm4v',
  635. 'upload_date': '20150228',
  636. 'title': 'pdv_maddow_netcast_m4v-02-27-2015-201624',
  637. }
  638. },
  639. # NBC Sports vplayer embeds
  640. {
  641. 'url': 'http://bbs.clutchfans.net/showthread.php?t=244180',
  642. 'info_dict': {
  643. 'id': '_hqLjQ95yx8Z',
  644. 'ext': 'flv'
  645. },
  646. 'skip': 'This content expired on 9/17/14 12:23 PM',
  647. }
  648. ]
  649. def report_following_redirect(self, new_url):
  650. """Report information extraction."""
  651. self._downloader.to_screen('[redirect] Following redirect to %s' % new_url)
  652. def _extract_rss(self, url, video_id, doc):
  653. playlist_title = doc.find('./channel/title').text
  654. playlist_desc_el = doc.find('./channel/description')
  655. playlist_desc = None if playlist_desc_el is None else playlist_desc_el.text
  656. entries = []
  657. for it in doc.findall('./channel/item'):
  658. next_url = xpath_text(it, 'link', fatal=False)
  659. if not next_url:
  660. enclosure_nodes = it.findall('./enclosure')
  661. for e in enclosure_nodes:
  662. next_url = e.attrib.get('url')
  663. if next_url:
  664. break
  665. if not next_url:
  666. continue
  667. entries.append({
  668. '_type': 'url',
  669. 'url': next_url,
  670. 'title': it.find('title').text,
  671. })
  672. return {
  673. '_type': 'playlist',
  674. 'id': url,
  675. 'title': playlist_title,
  676. 'description': playlist_desc,
  677. 'entries': entries,
  678. }
  679. def _extract_camtasia(self, url, video_id, webpage):
  680. """ Returns None if no camtasia video can be found. """
  681. camtasia_cfg = self._search_regex(
  682. r'fo\.addVariable\(\s*"csConfigFile",\s*"([^"]+)"\s*\);',
  683. webpage, 'camtasia configuration file', default=None)
  684. if camtasia_cfg is None:
  685. return None
  686. title = self._html_search_meta('DC.title', webpage, fatal=True)
  687. camtasia_url = compat_urlparse.urljoin(url, camtasia_cfg)
  688. camtasia_cfg = self._download_xml(
  689. camtasia_url, video_id,
  690. note='Downloading camtasia configuration',
  691. errnote='Failed to download camtasia configuration')
  692. fileset_node = camtasia_cfg.find('./playlist/array/fileset')
  693. entries = []
  694. for n in fileset_node.getchildren():
  695. url_n = n.find('./uri')
  696. if url_n is None:
  697. continue
  698. entries.append({
  699. 'id': os.path.splitext(url_n.text.rpartition('/')[2])[0],
  700. 'title': '%s - %s' % (title, n.tag),
  701. 'url': compat_urlparse.urljoin(url, url_n.text),
  702. 'duration': float_or_none(n.find('./duration').text),
  703. })
  704. return {
  705. '_type': 'playlist',
  706. 'entries': entries,
  707. 'title': title,
  708. }
  709. def _real_extract(self, url):
  710. if url.startswith('//'):
  711. return {
  712. '_type': 'url',
  713. 'url': self.http_scheme() + url,
  714. }
  715. parsed_url = compat_urlparse.urlparse(url)
  716. if not parsed_url.scheme:
  717. default_search = self._downloader.params.get('default_search')
  718. if default_search is None:
  719. default_search = 'fixup_error'
  720. if default_search in ('auto', 'auto_warning', 'fixup_error'):
  721. if '/' in url:
  722. self._downloader.report_warning('The url doesn\'t specify the protocol, trying with http')
  723. return self.url_result('http://' + url)
  724. elif default_search != 'fixup_error':
  725. if default_search == 'auto_warning':
  726. if re.match(r'^(?:url|URL)$', url):
  727. raise ExtractorError(
  728. 'Invalid URL: %r . Call youtube-dl like this: youtube-dl -v "https://www.youtube.com/watch?v=BaW_jenozKc" ' % url,
  729. expected=True)
  730. else:
  731. self._downloader.report_warning(
  732. 'Falling back to youtube search for %s . Set --default-search "auto" to suppress this warning.' % url)
  733. return self.url_result('ytsearch:' + url)
  734. if default_search in ('error', 'fixup_error'):
  735. raise ExtractorError(
  736. '%r is not a valid URL. '
  737. 'Set --default-search "ytsearch" (or run youtube-dl "ytsearch:%s" ) to search YouTube'
  738. % (url, url), expected=True)
  739. else:
  740. if ':' not in default_search:
  741. default_search += ':'
  742. return self.url_result(default_search + url)
  743. url, smuggled_data = unsmuggle_url(url)
  744. force_videoid = None
  745. is_intentional = smuggled_data and smuggled_data.get('to_generic')
  746. if smuggled_data and 'force_videoid' in smuggled_data:
  747. force_videoid = smuggled_data['force_videoid']
  748. video_id = force_videoid
  749. else:
  750. video_id = os.path.splitext(url.rstrip('/').split('/')[-1])[0]
  751. self.to_screen('%s: Requesting header' % video_id)
  752. head_req = HEADRequest(url)
  753. head_response = self._request_webpage(
  754. head_req, video_id,
  755. note=False, errnote='Could not send HEAD request to %s' % url,
  756. fatal=False)
  757. if head_response is not False:
  758. # Check for redirect
  759. new_url = head_response.geturl()
  760. if url != new_url:
  761. self.report_following_redirect(new_url)
  762. if force_videoid:
  763. new_url = smuggle_url(
  764. new_url, {'force_videoid': force_videoid})
  765. return self.url_result(new_url)
  766. full_response = None
  767. if head_response is False:
  768. full_response = self._request_webpage(url, video_id)
  769. head_response = full_response
  770. # Check for direct link to a video
  771. content_type = head_response.headers.get('Content-Type', '')
  772. m = re.match(r'^(?P<type>audio|video|application(?=/ogg$))/(?P<format_id>.+)$', content_type)
  773. if m:
  774. upload_date = unified_strdate(
  775. head_response.headers.get('Last-Modified'))
  776. return {
  777. 'id': video_id,
  778. 'title': os.path.splitext(url_basename(url))[0],
  779. 'direct': True,
  780. 'formats': [{
  781. 'format_id': m.group('format_id'),
  782. 'url': url,
  783. 'vcodec': 'none' if m.group('type') == 'audio' else None
  784. }],
  785. 'upload_date': upload_date,
  786. }
  787. if not self._downloader.params.get('test', False) and not is_intentional:
  788. self._downloader.report_warning('Falling back on generic information extractor.')
  789. if not full_response:
  790. full_response = self._request_webpage(url, video_id)
  791. # Maybe it's a direct link to a video?
  792. # Be careful not to download the whole thing!
  793. first_bytes = full_response.read(512)
  794. if not is_html(first_bytes):
  795. self._downloader.report_warning(
  796. 'URL could be a direct video link, returning it as such.')
  797. upload_date = unified_strdate(
  798. head_response.headers.get('Last-Modified'))
  799. return {
  800. 'id': video_id,
  801. 'title': os.path.splitext(url_basename(url))[0],
  802. 'direct': True,
  803. 'url': url,
  804. 'upload_date': upload_date,
  805. }
  806. webpage = self._webpage_read_content(
  807. full_response, url, video_id, prefix=first_bytes)
  808. self.report_extraction(video_id)
  809. # Is it an RSS feed?
  810. try:
  811. doc = parse_xml(webpage)
  812. if doc.tag == 'rss':
  813. return self._extract_rss(url, video_id, doc)
  814. except compat_xml_parse_error:
  815. pass
  816. # Is it a Camtasia project?
  817. camtasia_res = self._extract_camtasia(url, video_id, webpage)
  818. if camtasia_res is not None:
  819. return camtasia_res
  820. # Sometimes embedded video player is hidden behind percent encoding
  821. # (e.g. https://github.com/rg3/youtube-dl/issues/2448)
  822. # Unescaping the whole page allows to handle those cases in a generic way
  823. webpage = compat_urllib_parse.unquote(webpage)
  824. # it's tempting to parse this further, but you would
  825. # have to take into account all the variations like
  826. # Video Title - Site Name
  827. # Site Name | Video Title
  828. # Video Title - Tagline | Site Name
  829. # and so on and so forth; it's just not practical
  830. video_title = self._html_search_regex(
  831. r'(?s)<title>(.*?)</title>', webpage, 'video title',
  832. default='video')
  833. # Try to detect age limit automatically
  834. age_limit = self._rta_search(webpage)
  835. # And then there are the jokers who advertise that they use RTA,
  836. # but actually don't.
  837. AGE_LIMIT_MARKERS = [
  838. r'Proudly Labeled <a href="http://www.rtalabel.org/" title="Restricted to Adults">RTA</a>',
  839. ]
  840. if any(re.search(marker, webpage) for marker in AGE_LIMIT_MARKERS):
  841. age_limit = 18
  842. # video uploader is domain name
  843. video_uploader = self._search_regex(
  844. r'^(?:https?://)?([^/]*)/.*', url, 'video uploader')
  845. # Helper method
  846. def _playlist_from_matches(matches, getter=None, ie=None):
  847. urlrs = orderedSet(
  848. self.url_result(self._proto_relative_url(getter(m) if getter else m), ie)
  849. for m in matches)
  850. return self.playlist_result(
  851. urlrs, playlist_id=video_id, playlist_title=video_title)
  852. # Look for BrightCove:
  853. bc_urls = BrightcoveIE._extract_brightcove_urls(webpage)
  854. if bc_urls:
  855. self.to_screen('Brightcove video detected.')
  856. entries = [{
  857. '_type': 'url',
  858. 'url': smuggle_url(bc_url, {'Referer': url}),
  859. 'ie_key': 'Brightcove'
  860. } for bc_url in bc_urls]
  861. return {
  862. '_type': 'playlist',
  863. 'title': video_title,
  864. 'id': video_id,
  865. 'entries': entries,
  866. }
  867. # Look for embedded rtl.nl player
  868. matches = re.findall(
  869. r'<iframe\s+(?:[a-zA-Z-]+="[^"]+"\s+)*?src="((?:https?:)?//(?:www\.)?rtl\.nl/system/videoplayer/[^"]+video_embed[^"]+)"',
  870. webpage)
  871. if matches:
  872. return _playlist_from_matches(matches, ie='RtlNl')
  873. # Look for embedded (iframe) Vimeo player
  874. mobj = re.search(
  875. r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.vimeo\.com/video/.+?)\1', webpage)
  876. if mobj:
  877. player_url = unescapeHTML(mobj.group('url'))
  878. surl = smuggle_url(player_url, {'Referer': url})
  879. return self.url_result(surl)
  880. # Look for embedded (swf embed) Vimeo player
  881. mobj = re.search(
  882. r'<embed[^>]+?src="((?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)"', webpage)
  883. if mobj:
  884. return self.url_result(mobj.group(1))
  885. # Look for embedded YouTube player
  886. matches = re.findall(r'''(?x)
  887. (?:
  888. <iframe[^>]+?src=|
  889. data-video-url=|
  890. <embed[^>]+?src=|
  891. embedSWF\(?:\s*|
  892. new\s+SWFObject\(
  893. )
  894. (["\'])
  895. (?P<url>(?:https?:)?//(?:www\.)?youtube(?:-nocookie)?\.com/
  896. (?:embed|v|p)/.+?)
  897. \1''', webpage)
  898. if matches:
  899. return _playlist_from_matches(
  900. matches, lambda m: unescapeHTML(m[1]))
  901. # Look for lazyYT YouTube embed
  902. matches = re.findall(
  903. r'class="lazyYT" data-youtube-id="([^"]+)"', webpage)
  904. if matches:
  905. return _playlist_from_matches(matches, lambda m: unescapeHTML(m))
  906. # Look for embedded Dailymotion player
  907. matches = re.findall(
  908. r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?dailymotion\.com/embed/video/.+?)\1', webpage)
  909. if matches:
  910. return _playlist_from_matches(
  911. matches, lambda m: unescapeHTML(m[1]))
  912. # Look for embedded Dailymotion playlist player (#3822)
  913. m = re.search(
  914. r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?dailymotion\.[a-z]{2,3}/widget/jukebox\?.+?)\1', webpage)
  915. if m:
  916. playlists = re.findall(
  917. r'list\[\]=/playlist/([^/]+)/', unescapeHTML(m.group('url')))
  918. if playlists:
  919. return _playlist_from_matches(
  920. playlists, lambda p: '//dailymotion.com/playlist/%s' % p)
  921. # Look for embedded Wistia player
  922. match = re.search(
  923. r'<(?:meta[^>]+?content|iframe[^>]+?src)=(["\'])(?P<url>(?:https?:)?//(?:fast\.)?wistia\.net/embed/iframe/.+?)\1', webpage)
  924. if match:
  925. embed_url = self._proto_relative_url(
  926. unescapeHTML(match.group('url')))
  927. return {
  928. '_type': 'url_transparent',
  929. 'url': embed_url,
  930. 'ie_key': 'Wistia',
  931. 'uploader': video_uploader,
  932. 'title': video_title,
  933. 'id': video_id,
  934. }
  935. match = re.search(r'(?:id=["\']wistia_|data-wistia-?id=["\']|Wistia\.embed\(["\'])(?P<id>[^"\']+)', webpage)
  936. if match:
  937. return {
  938. '_type': 'url_transparent',
  939. 'url': 'http://fast.wistia.net/embed/iframe/{0:}'.format(match.group('id')),
  940. 'ie_key': 'Wistia',
  941. 'uploader': video_uploader,
  942. 'title': video_title,
  943. 'id': match.group('id')
  944. }
  945. # Look for embedded blip.tv player
  946. mobj = re.search(r'<meta\s[^>]*https?://api\.blip\.tv/\w+/redirect/\w+/(\d+)', webpage)
  947. if mobj:
  948. return self.url_result('http://blip.tv/a/a-' + mobj.group(1), 'BlipTV')
  949. mobj = re.search(r'<(?:iframe|embed|object)\s[^>]*(https?://(?:\w+\.)?blip\.tv/(?:play/|api\.swf#)[a-zA-Z0-9_]+)', webpage)
  950. if mobj:
  951. return self.url_result(mobj.group(1), 'BlipTV')
  952. # Look for embedded condenast player
  953. matches = re.findall(
  954. r'<iframe\s+(?:[a-zA-Z-]+="[^"]+"\s+)*?src="(https?://player\.cnevids\.com/embed/[^"]+")',
  955. webpage)
  956. if matches:
  957. return {
  958. '_type': 'playlist',
  959. 'entries': [{
  960. '_type': 'url',
  961. 'ie_key': 'CondeNast',
  962. 'url': ma,
  963. } for ma in matches],
  964. 'title': video_title,
  965. 'id': video_id,
  966. }
  967. # Look for Bandcamp pages with custom domain
  968. mobj = re.search(r'<meta property="og:url"[^>]*?content="(.*?bandcamp\.com.*?)"', webpage)
  969. if mobj is not None:
  970. burl = unescapeHTML(mobj.group(1))
  971. # Don't set the extractor because it can be a track url or an album
  972. return self.url_result(burl)
  973. # Look for embedded Vevo player
  974. mobj = re.search(
  975. r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:cache\.)?vevo\.com/.+?)\1', webpage)
  976. if mobj is not None:
  977. return self.url_result(mobj.group('url'))
  978. # Look for embedded Viddler player
  979. mobj = re.search(
  980. r'<(?:iframe[^>]+?src|param[^>]+?value)=(["\'])(?P<url>(?:https?:)?//(?:www\.)?viddler\.com/(?:embed|player)/.+?)\1',
  981. webpage)
  982. if mobj is not None:
  983. return self.url_result(mobj.group('url'))
  984. # Look for NYTimes player
  985. mobj = re.search(
  986. r'<iframe[^>]+src=(["\'])(?P<url>(?:https?:)?//graphics8\.nytimes\.com/bcvideo/[^/]+/iframe/embed\.html.+?)\1>',
  987. webpage)
  988. if mobj is not None:
  989. return self.url_result(mobj.group('url'))
  990. # Look for Libsyn player
  991. mobj = re.search(
  992. r'<iframe[^>]+src=(["\'])(?P<url>(?:https?:)?//html5-player\.libsyn\.com/embed/.+?)\1', webpage)
  993. if mobj is not None:
  994. return self.url_result(mobj.group('url'))
  995. # Look for Ooyala videos
  996. mobj = (re.search(r'player\.ooyala\.com/[^"?]+\?[^"]*?(?:embedCode|ec)=(?P<ec>[^"&]+)', webpage) or
  997. re.search(r'OO\.Player\.create\([\'"].*?[\'"],\s*[\'"](?P<ec>.{32})[\'"]', webpage) or
  998. re.search(r'SBN\.VideoLinkset\.ooyala\([\'"](?P<ec>.{32})[\'"]\)', webpage))
  999. if mobj is not None:
  1000. return OoyalaIE._build_url_result(mobj.group('ec'))
  1001. # Look for multiple Ooyala embeds on SBN network websites
  1002. mobj = re.search(r'SBN\.VideoLinkset\.entryGroup\((\[.*?\])', webpage)
  1003. if mobj is not None:
  1004. embeds = self._parse_json(mobj.group(1), video_id, fatal=False)
  1005. if embeds:
  1006. return _playlist_from_matches(
  1007. embeds, getter=lambda v: OoyalaIE._url_for_embed_code(v['provider_video_id']), ie='Ooyala')
  1008. # Look for Aparat videos
  1009. mobj = re.search(r'<iframe .*?src="(http://www\.aparat\.com/video/[^"]+)"', webpage)
  1010. if mobj is not None:
  1011. return self.url_result(mobj.group(1), 'Aparat')
  1012. # Look for MPORA videos
  1013. mobj = re.search(r'<iframe .*?src="(http://mpora\.(?:com|de)/videos/[^"]+)"', webpage)
  1014. if mobj is not None:
  1015. return self.url_result(mobj.group(1), 'Mpora')
  1016. # Look for embedded NovaMov-based player
  1017. mobj = re.search(
  1018. r'''(?x)<(?:pagespeed_)?iframe[^>]+?src=(["\'])
  1019. (?P<url>http://(?:(?:embed|www)\.)?
  1020. (?:novamov\.com|
  1021. nowvideo\.(?:ch|sx|eu|at|ag|co)|
  1022. videoweed\.(?:es|com)|
  1023. movshare\.(?:net|sx|ag)|
  1024. divxstage\.(?:eu|net|ch|co|at|ag))
  1025. /embed\.php.+?)\1''', webpage)
  1026. if mobj is not None:
  1027. return self.url_result(mobj.group('url'))
  1028. # Look for embedded Facebook player
  1029. mobj = re.search(
  1030. r'<iframe[^>]+?src=(["\'])(?P<url>https://www\.facebook\.com/video/embed.+?)\1', webpage)
  1031. if mobj is not None:
  1032. return self.url_result(mobj.group('url'), 'Facebook')
  1033. # Look for embedded VK player
  1034. mobj = re.search(r'<iframe[^>]+?src=(["\'])(?P<url>https?://vk\.com/video_ext\.php.+?)\1', webpage)
  1035. if mobj is not None:
  1036. return self.url_result(mobj.group('url'), 'VK')
  1037. # Look for embedded ivi player
  1038. mobj = re.search(r'<embed[^>]+?src=(["\'])(?P<url>https?://(?:www\.)?ivi\.ru/video/player.+?)\1', webpage)
  1039. if mobj is not None:
  1040. return self.url_result(mobj.group('url'), 'Ivi')
  1041. # Look for embedded Huffington Post player
  1042. mobj = re.search(
  1043. r'<iframe[^>]+?src=(["\'])(?P<url>https?://embed\.live\.huffingtonpost\.com/.+?)\1', webpage)
  1044. if mobj is not None:
  1045. return self.url_result(mobj.group('url'), 'HuffPost')
  1046. # Look for embed.ly
  1047. mobj = re.search(r'class=["\']embedly-card["\'][^>]href=["\'](?P<url>[^"\']+)', webpage)
  1048. if mobj is not None:
  1049. return self.url_result(mobj.group('url'))
  1050. mobj = re.search(r'class=["\']embedly-embed["\'][^>]src=["\'][^"\']*url=(?P<url>[^&]+)', webpage)
  1051. if mobj is not None:
  1052. return self.url_result(compat_urllib_parse.unquote(mobj.group('url')))
  1053. # Look for funnyordie embed
  1054. matches = re.findall(r'<iframe[^>]+?src="(https?://(?:www\.)?funnyordie\.com/embed/[^"]+)"', webpage)
  1055. if matches:
  1056. return _playlist_from_matches(
  1057. matches, getter=unescapeHTML, ie='FunnyOrDie')
  1058. # Look for BBC iPlayer embed
  1059. matches = re.findall(r'setPlaylist\("(https?://www\.bbc\.co\.uk/iplayer/[^/]+/[\da-z]{8})"\)', webpage)
  1060. if matches:
  1061. return _playlist_from_matches(matches, ie='BBCCoUk')
  1062. # Look for embedded RUTV player
  1063. rutv_url = RUTVIE._extract_url(webpage)
  1064. if rutv_url:
  1065. return self.url_result(rutv_url, 'RUTV')
  1066. # Look for embedded TED player
  1067. mobj = re.search(
  1068. r'<iframe[^>]+?src=(["\'])(?P<url>https?://embed(?:-ssl)?\.ted\.com/.+?)\1', webpage)
  1069. if mobj is not None:
  1070. return self.url_result(mobj.group('url'), 'TED')
  1071. # Look for embedded Ustream videos
  1072. mobj = re.search(
  1073. r'<iframe[^>]+?src=(["\'])(?P<url>http://www\.ustream\.tv/embed/.+?)\1', webpage)
  1074. if mobj is not None:
  1075. return self.url_result(mobj.group('url'), 'Ustream')
  1076. # Look for embedded arte.tv player
  1077. mobj = re.search(
  1078. r'<script [^>]*?src="(?P<url>http://www\.arte\.tv/playerv2/embed[^"]+)"',
  1079. webpage)
  1080. if mobj is not None:
  1081. return self.url_result(mobj.group('url'), 'ArteTVEmbed')
  1082. # Look for embedded smotri.com player
  1083. smotri_url = SmotriIE._extract_url(webpage)
  1084. if smotri_url:
  1085. return self.url_result(smotri_url, 'Smotri')
  1086. # Look for embeded soundcloud player
  1087. mobj = re.search(
  1088. r'<iframe\s+(?:[a-zA-Z0-9_-]+="[^"]+"\s+)*src="(?P<url>https?://(?:w\.)?soundcloud\.com/player[^"]+)"',
  1089. webpage)
  1090. if mobj is not None:
  1091. url = unescapeHTML(mobj.group('url'))
  1092. return self.url_result(url)
  1093. # Look for embedded vulture.com player
  1094. mobj = re.search(
  1095. r'<iframe src="(?P<url>https?://video\.vulture\.com/[^"]+)"',
  1096. webpage)
  1097. if mobj is not None:
  1098. url = unescapeHTML(mobj.group('url'))
  1099. return self.url_result(url, ie='Vulture')
  1100. # Look for embedded mtvservices player
  1101. mobj = re.search(
  1102. r'<iframe src="(?P<url>https?://media\.mtvnservices\.com/embed/[^"]+)"',
  1103. webpage)
  1104. if mobj is not None:
  1105. url = unescapeHTML(mobj.group('url'))
  1106. return self.url_result(url, ie='MTVServicesEmbedded')
  1107. # Look for embedded yahoo player
  1108. mobj = re.search(
  1109. r'<iframe[^>]+?src=(["\'])(?P<url>https?://(?:screen|movies)\.yahoo\.com/.+?\.html\?format=embed)\1',
  1110. webpage)
  1111. if mobj is not None:
  1112. return self.url_result(mobj.group('url'), 'Yahoo')
  1113. # Look for embedded sbs.com.au player
  1114. mobj = re.search(
  1115. r'''(?x)
  1116. (?:
  1117. <meta\s+property="og:video"\s+content=|
  1118. <iframe[^>]+?src=
  1119. )
  1120. (["\'])(?P<url>https?://(?:www\.)?sbs\.com\.au/ondemand/video/.+?)\1''',
  1121. webpage)
  1122. if mobj is not None:
  1123. return self.url_result(mobj.group('url'), 'SBS')
  1124. # Look for embedded Cinchcast player
  1125. mobj = re.search(
  1126. r'<iframe[^>]+?src=(["\'])(?P<url>https?://player\.cinchcast\.com/.+?)\1',
  1127. webpage)
  1128. if mobj is not None:
  1129. return self.url_result(mobj.group('url'), 'Cinchcast')
  1130. mobj = re.search(
  1131. r'<iframe[^>]+?src=(["\'])(?P<url>https?://m(?:lb)?\.mlb\.com/shared/video/embed/embed\.html\?.+?)\1',
  1132. webpage)
  1133. if mobj is not None:
  1134. return self.url_result(mobj.group('url'), 'MLB')
  1135. mobj = re.search(
  1136. r'<iframe[^>]+?src=(["\'])(?P<url>%s)\1' % CondeNastIE.EMBED_URL,
  1137. webpage)
  1138. if mobj is not None:
  1139. return self.url_result(self._proto_relative_url(mobj.group('url'), scheme='http:'), 'CondeNast')
  1140. mobj = re.search(
  1141. r'<iframe[^>]+src="(?P<url>https?://new\.livestream\.com/[^"]+/player[^"]+)"',
  1142. webpage)
  1143. if mobj is not None:
  1144. return self.url_result(mobj.group('url'), 'Livestream')
  1145. # Look for Zapiks embed
  1146. mobj = re.search(
  1147. r'<iframe[^>]+src="(?P<url>https?://(?:www\.)?zapiks\.fr/index\.php\?.+?)"', webpage)
  1148. if mobj is not None:
  1149. return self.url_result(mobj.group('url'), 'Zapiks')
  1150. # Look for Kaltura embeds
  1151. mobj = re.search(
  1152. r"(?s)kWidget\.(?:thumb)?[Ee]mbed\(\{.*?'wid'\s*:\s*'_?(?P<partner_id>[^']+)',.*?'entry_id'\s*:\s*'(?P<id>[^']+)',", webpage)
  1153. if mobj is not None:
  1154. return self.url_result('kaltura:%(partner_id)s:%(id)s' % mobj.groupdict(), 'Kaltura')
  1155. # Look for Eagle.Platform embeds
  1156. mobj = re.search(
  1157. r'<iframe[^>]+src="(?P<url>https?://.+?\.media\.eagleplatform\.com/index/player\?.+?)"', webpage)
  1158. if mobj is not None:
  1159. return self.url_result(mobj.group('url'), 'EaglePlatform')
  1160. # Look for ClipYou (uses Eagle.Platform) embeds
  1161. mobj = re.search(
  1162. r'<iframe[^>]+src="https?://(?P<host>media\.clipyou\.ru)/index/player\?.*\brecord_id=(?P<id>\d+).*"', webpage)
  1163. if mobj is not None:
  1164. return self.url_result('eagleplatform:%(host)s:%(id)s' % mobj.groupdict(), 'EaglePlatform')
  1165. # Look for Pladform embeds
  1166. mobj = re.search(
  1167. r'<iframe[^>]+src="(?P<url>https?://out\.pladform\.ru/player\?.+?)"', webpage)
  1168. if mobj is not None:
  1169. return self.url_result(mobj.group('url'), 'Pladform')
  1170. # Look for 5min embeds
  1171. mobj = re.search(
  1172. r'<meta[^>]+property="og:video"[^>]+content="https?://embed\.5min\.com/(?P<id>[0-9]+)/?', webpage)
  1173. if mobj is not None:
  1174. return self.url_result('5min:%s' % mobj.group('id'), 'FiveMin')
  1175. # Look for NBC Sports VPlayer embeds
  1176. nbc_sports_url = NBCSportsVPlayerIE._extract_url(webpage)
  1177. if nbc_sports_url:
  1178. return self.url_result(nbc_sports_url, 'NBCSportsVPlayer')
  1179. def check_video(vurl):
  1180. if YoutubeIE.suitable(vurl):
  1181. return True
  1182. vpath = compat_urlparse.urlparse(vurl).path
  1183. vext = determine_ext(vpath)
  1184. return '.' in vpath and vext not in ('swf', 'png', 'jpg', 'srt', 'sbv', 'sub', 'vtt', 'ttml')
  1185. def filter_video(urls):
  1186. return list(filter(check_video, urls))
  1187. # Start with something easy: JW Player in SWFObject
  1188. found = filter_video(re.findall(r'flashvars: [\'"](?:.*&)?file=(http[^\'"&]*)', webpage))
  1189. if not found:
  1190. # Look for gorilla-vid style embedding
  1191. found = filter_video(re.findall(r'''(?sx)
  1192. (?:
  1193. jw_plugins|
  1194. JWPlayerOptions|
  1195. jwplayer\s*\(\s*["'][^'"]+["']\s*\)\s*\.setup
  1196. )
  1197. .*?
  1198. ['"]?file['"]?\s*:\s*["\'](.*?)["\']''', webpage))
  1199. if not found:
  1200. # Broaden the search a little bit
  1201. found = filter_video(re.findall(r'[^A-Za-z0-9]?(?:file|source)=(http[^\'"&]*)', webpage))
  1202. if not found:
  1203. # Broaden the findall a little bit: JWPlayer JS loader
  1204. found = filter_video(re.findall(
  1205. r'[^A-Za-z0-9]?file["\']?:\s*["\'](http(?![^\'"]+\.[0-9]+[\'"])[^\'"]+)["\']', webpage))
  1206. if not found:
  1207. # Flow player
  1208. found = filter_video(re.findall(r'''(?xs)
  1209. flowplayer\("[^"]+",\s*
  1210. \{[^}]+?\}\s*,
  1211. \s*\{[^}]+? ["']?clip["']?\s*:\s*\{\s*
  1212. ["']?url["']?\s*:\s*["']([^"']+)["']
  1213. ''', webpage))
  1214. if not found:
  1215. # Cinerama player
  1216. found = re.findall(
  1217. r"cinerama\.embedPlayer\(\s*\'[^']+\',\s*'([^']+)'", webpage)
  1218. if not found:
  1219. # Try to find twitter cards info
  1220. found = filter_video(re.findall(
  1221. r'<meta (?:property|name)="twitter:player:stream" (?:content|value)="(.+?)"', webpage))
  1222. if not found:
  1223. # We look for Open Graph info:
  1224. # We have to match any number spaces between elements, some sites try to align them (eg.: statigr.am)
  1225. m_video_type = re.findall(r'<meta.*?property="og:video:type".*?content="video/(.*?)"', webpage)
  1226. # We only look in og:video if the MIME type is a video, don't try if it's a Flash player:
  1227. if m_video_type is not None:
  1228. found = filter_video(re.findall(r'<meta.*?property="og:video".*?content="(.*?)"', webpage))
  1229. if not found:
  1230. # HTML5 video
  1231. found = re.findall(r'(?s)<video[^<]*(?:>.*?<source[^>]*)?\s+src=["\'](.*?)["\']', webpage)
  1232. if not found:
  1233. REDIRECT_REGEX = r'[0-9]{,2};\s*(?:URL|url)=\'?([^\'"]+)'
  1234. found = re.search(
  1235. r'(?i)<meta\s+(?=(?:[a-z-]+="[^"]+"\s+)*http-equiv="refresh")'
  1236. r'(?:[a-z-]+="[^"]+"\s+)*?content="%s' % REDIRECT_REGEX,
  1237. webpage)
  1238. if not found:
  1239. # Look also in Refresh HTTP header
  1240. refresh_header = head_response.headers.get('Refresh')
  1241. if refresh_header:
  1242. found = re.search(REDIRECT_REGEX, refresh_header)
  1243. if found:
  1244. new_url = found.group(1)
  1245. self.report_following_redirect(new_url)
  1246. return {
  1247. '_type': 'url',
  1248. 'url': new_url,
  1249. }
  1250. if not found:
  1251. raise UnsupportedError(url)
  1252. entries = []
  1253. for video_url in found:
  1254. video_url = compat_urlparse.urljoin(url, video_url)
  1255. video_id = compat_urllib_parse.unquote(os.path.basename(video_url))
  1256. # Sometimes, jwplayer extraction will result in a YouTube URL
  1257. if YoutubeIE.suitable(video_url):
  1258. entries.append(self.url_result(video_url, 'Youtube'))
  1259. continue
  1260. # here's a fun little line of code for you:
  1261. video_id = os.path.splitext(video_id)[0]
  1262. entries.append({
  1263. 'id': video_id,
  1264. 'url': video_url,
  1265. 'uploader': video_uploader,
  1266. 'title': video_title,
  1267. 'age_limit': age_limit,
  1268. })
  1269. if len(entries) == 1:
  1270. return entries[0]
  1271. else:
  1272. for num, e in enumerate(entries, start=1):
  1273. # 'url' results don't have a title
  1274. if e.get('title') is not None:
  1275. e['title'] = '%s (%d)' % (e['title'], num)
  1276. return {
  1277. '_type': 'playlist',
  1278. 'entries': entries,
  1279. }