generic.py 62 KB

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