generic.py 72 KB

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