generic.py 59 KB

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