generic.py 53 KB

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