InfoExtractors.py 106 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781
  1. import base64
  2. import datetime
  3. import itertools
  4. import netrc
  5. import os
  6. import re
  7. import socket
  8. import time
  9. import email.utils
  10. import xml.etree.ElementTree
  11. import random
  12. import math
  13. import operator
  14. import hashlib
  15. import binascii
  16. import urllib
  17. from .utils import *
  18. from .extractor.common import InfoExtractor, SearchInfoExtractor
  19. from .extractor.ard import ARDIE
  20. from .extractor.arte import ArteTvIE
  21. from .extractor.dailymotion import DailymotionIE
  22. from .extractor.gametrailers import GametrailersIE
  23. from .extractor.generic import GenericIE
  24. from .extractor.metacafe import MetacafeIE
  25. from .extractor.statigram import StatigramIE
  26. from .extractor.photobucket import PhotobucketIE
  27. from .extractor.vimeo import VimeoIE
  28. from .extractor.yahoo import YahooIE, YahooSearchIE
  29. from .extractor.youtube import YoutubeIE, YoutubePlaylistIE, YoutubeSearchIE, YoutubeUserIE, YoutubeChannelIE
  30. from .extractor.zdf import ZDFIE
  31. class BlipTVUserIE(InfoExtractor):
  32. """Information Extractor for blip.tv users."""
  33. _VALID_URL = r'(?:(?:(?:https?://)?(?:\w+\.)?blip\.tv/)|bliptvuser:)([^/]+)/*$'
  34. _PAGE_SIZE = 12
  35. IE_NAME = u'blip.tv:user'
  36. def _real_extract(self, url):
  37. # Extract username
  38. mobj = re.match(self._VALID_URL, url)
  39. if mobj is None:
  40. raise ExtractorError(u'Invalid URL: %s' % url)
  41. username = mobj.group(1)
  42. page_base = 'http://m.blip.tv/pr/show_get_full_episode_list?users_id=%s&lite=0&esi=1'
  43. page = self._download_webpage(url, username, u'Downloading user page')
  44. mobj = re.search(r'data-users-id="([^"]+)"', page)
  45. page_base = page_base % mobj.group(1)
  46. # Download video ids using BlipTV Ajax calls. Result size per
  47. # query is limited (currently to 12 videos) so we need to query
  48. # page by page until there are no video ids - it means we got
  49. # all of them.
  50. video_ids = []
  51. pagenum = 1
  52. while True:
  53. url = page_base + "&page=" + str(pagenum)
  54. page = self._download_webpage(url, username,
  55. u'Downloading video ids from page %d' % pagenum)
  56. # Extract video identifiers
  57. ids_in_page = []
  58. for mobj in re.finditer(r'href="/([^"]+)"', page):
  59. if mobj.group(1) not in ids_in_page:
  60. ids_in_page.append(unescapeHTML(mobj.group(1)))
  61. video_ids.extend(ids_in_page)
  62. # A little optimization - if current page is not
  63. # "full", ie. does not contain PAGE_SIZE video ids then
  64. # we can assume that this page is the last one - there
  65. # are no more ids on further pages - no need to query
  66. # again.
  67. if len(ids_in_page) < self._PAGE_SIZE:
  68. break
  69. pagenum += 1
  70. urls = [u'http://blip.tv/%s' % video_id for video_id in video_ids]
  71. url_entries = [self.url_result(url, 'BlipTV') for url in urls]
  72. return [self.playlist_result(url_entries, playlist_title = username)]
  73. class DepositFilesIE(InfoExtractor):
  74. """Information extractor for depositfiles.com"""
  75. _VALID_URL = r'(?:http://)?(?:\w+\.)?depositfiles\.com/(?:../(?#locale))?files/(.+)'
  76. def _real_extract(self, url):
  77. file_id = url.split('/')[-1]
  78. # Rebuild url in english locale
  79. url = 'http://depositfiles.com/en/files/' + file_id
  80. # Retrieve file webpage with 'Free download' button pressed
  81. free_download_indication = { 'gateway_result' : '1' }
  82. request = compat_urllib_request.Request(url, compat_urllib_parse.urlencode(free_download_indication))
  83. try:
  84. self.report_download_webpage(file_id)
  85. webpage = compat_urllib_request.urlopen(request).read()
  86. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  87. raise ExtractorError(u'Unable to retrieve file webpage: %s' % compat_str(err))
  88. # Search for the real file URL
  89. mobj = re.search(r'<form action="(http://fileshare.+?)"', webpage)
  90. if (mobj is None) or (mobj.group(1) is None):
  91. # Try to figure out reason of the error.
  92. mobj = re.search(r'<strong>(Attention.*?)</strong>', webpage, re.DOTALL)
  93. if (mobj is not None) and (mobj.group(1) is not None):
  94. restriction_message = re.sub('\s+', ' ', mobj.group(1)).strip()
  95. raise ExtractorError(u'%s' % restriction_message)
  96. else:
  97. raise ExtractorError(u'Unable to extract download URL from: %s' % url)
  98. file_url = mobj.group(1)
  99. file_extension = os.path.splitext(file_url)[1][1:]
  100. # Search for file title
  101. file_title = self._search_regex(r'<b title="(.*?)">', webpage, u'title')
  102. return [{
  103. 'id': file_id.decode('utf-8'),
  104. 'url': file_url.decode('utf-8'),
  105. 'uploader': None,
  106. 'upload_date': None,
  107. 'title': file_title,
  108. 'ext': file_extension.decode('utf-8'),
  109. }]
  110. class FacebookIE(InfoExtractor):
  111. """Information Extractor for Facebook"""
  112. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?facebook\.com/(?:video/video|photo)\.php\?(?:.*?)v=(?P<ID>\d+)(?:.*)'
  113. _LOGIN_URL = 'https://login.facebook.com/login.php?m&next=http%3A%2F%2Fm.facebook.com%2Fhome.php&'
  114. _NETRC_MACHINE = 'facebook'
  115. IE_NAME = u'facebook'
  116. def report_login(self):
  117. """Report attempt to log in."""
  118. self.to_screen(u'Logging in')
  119. def _real_initialize(self):
  120. if self._downloader is None:
  121. return
  122. useremail = None
  123. password = None
  124. downloader_params = self._downloader.params
  125. # Attempt to use provided username and password or .netrc data
  126. if downloader_params.get('username', None) is not None:
  127. useremail = downloader_params['username']
  128. password = downloader_params['password']
  129. elif downloader_params.get('usenetrc', False):
  130. try:
  131. info = netrc.netrc().authenticators(self._NETRC_MACHINE)
  132. if info is not None:
  133. useremail = info[0]
  134. password = info[2]
  135. else:
  136. raise netrc.NetrcParseError('No authenticators for %s' % self._NETRC_MACHINE)
  137. except (IOError, netrc.NetrcParseError) as err:
  138. self._downloader.report_warning(u'parsing .netrc: %s' % compat_str(err))
  139. return
  140. if useremail is None:
  141. return
  142. # Log in
  143. login_form = {
  144. 'email': useremail,
  145. 'pass': password,
  146. 'login': 'Log+In'
  147. }
  148. request = compat_urllib_request.Request(self._LOGIN_URL, compat_urllib_parse.urlencode(login_form))
  149. try:
  150. self.report_login()
  151. login_results = compat_urllib_request.urlopen(request).read()
  152. if re.search(r'<form(.*)name="login"(.*)</form>', login_results) is not None:
  153. self._downloader.report_warning(u'unable to log in: bad username/password, or exceded login rate limit (~3/min). Check credentials or wait.')
  154. return
  155. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  156. self._downloader.report_warning(u'unable to log in: %s' % compat_str(err))
  157. return
  158. def _real_extract(self, url):
  159. mobj = re.match(self._VALID_URL, url)
  160. if mobj is None:
  161. raise ExtractorError(u'Invalid URL: %s' % url)
  162. video_id = mobj.group('ID')
  163. url = 'https://www.facebook.com/video/video.php?v=%s' % video_id
  164. webpage = self._download_webpage(url, video_id)
  165. BEFORE = '{swf.addParam(param[0], param[1]);});\n'
  166. AFTER = '.forEach(function(variable) {swf.addVariable(variable[0], variable[1]);});'
  167. m = re.search(re.escape(BEFORE) + '(.*?)' + re.escape(AFTER), webpage)
  168. if not m:
  169. raise ExtractorError(u'Cannot parse data')
  170. data = dict(json.loads(m.group(1)))
  171. params_raw = compat_urllib_parse.unquote(data['params'])
  172. params = json.loads(params_raw)
  173. video_data = params['video_data'][0]
  174. video_url = video_data.get('hd_src')
  175. if not video_url:
  176. video_url = video_data['sd_src']
  177. if not video_url:
  178. raise ExtractorError(u'Cannot find video URL')
  179. video_duration = int(video_data['video_duration'])
  180. thumbnail = video_data['thumbnail_src']
  181. video_title = self._html_search_regex('<h2 class="uiHeaderTitle">([^<]+)</h2>',
  182. webpage, u'title')
  183. info = {
  184. 'id': video_id,
  185. 'title': video_title,
  186. 'url': video_url,
  187. 'ext': 'mp4',
  188. 'duration': video_duration,
  189. 'thumbnail': thumbnail,
  190. }
  191. return [info]
  192. class BlipTVIE(InfoExtractor):
  193. """Information extractor for blip.tv"""
  194. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?blip\.tv/((.+/)|(play/)|(api\.swf#))(.+)$'
  195. _URL_EXT = r'^.*\.([a-z0-9]+)$'
  196. IE_NAME = u'blip.tv'
  197. def report_direct_download(self, title):
  198. """Report information extraction."""
  199. self.to_screen(u'%s: Direct download detected' % title)
  200. def _real_extract(self, url):
  201. mobj = re.match(self._VALID_URL, url)
  202. if mobj is None:
  203. raise ExtractorError(u'Invalid URL: %s' % url)
  204. # See https://github.com/rg3/youtube-dl/issues/857
  205. api_mobj = re.match(r'http://a\.blip\.tv/api\.swf#(?P<video_id>[\d\w]+)', url)
  206. if api_mobj is not None:
  207. url = 'http://blip.tv/play/g_%s' % api_mobj.group('video_id')
  208. urlp = compat_urllib_parse_urlparse(url)
  209. if urlp.path.startswith('/play/'):
  210. request = compat_urllib_request.Request(url)
  211. response = compat_urllib_request.urlopen(request)
  212. redirecturl = response.geturl()
  213. rurlp = compat_urllib_parse_urlparse(redirecturl)
  214. file_id = compat_parse_qs(rurlp.fragment)['file'][0].rpartition('/')[2]
  215. url = 'http://blip.tv/a/a-' + file_id
  216. return self._real_extract(url)
  217. if '?' in url:
  218. cchar = '&'
  219. else:
  220. cchar = '?'
  221. json_url = url + cchar + 'skin=json&version=2&no_wrap=1'
  222. request = compat_urllib_request.Request(json_url)
  223. request.add_header('User-Agent', 'iTunes/10.6.1')
  224. self.report_extraction(mobj.group(1))
  225. info = None
  226. try:
  227. urlh = compat_urllib_request.urlopen(request)
  228. if urlh.headers.get('Content-Type', '').startswith('video/'): # Direct download
  229. basename = url.split('/')[-1]
  230. title,ext = os.path.splitext(basename)
  231. title = title.decode('UTF-8')
  232. ext = ext.replace('.', '')
  233. self.report_direct_download(title)
  234. info = {
  235. 'id': title,
  236. 'url': url,
  237. 'uploader': None,
  238. 'upload_date': None,
  239. 'title': title,
  240. 'ext': ext,
  241. 'urlhandle': urlh
  242. }
  243. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  244. raise ExtractorError(u'ERROR: unable to download video info webpage: %s' % compat_str(err))
  245. if info is None: # Regular URL
  246. try:
  247. json_code_bytes = urlh.read()
  248. json_code = json_code_bytes.decode('utf-8')
  249. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  250. raise ExtractorError(u'Unable to read video info webpage: %s' % compat_str(err))
  251. try:
  252. json_data = json.loads(json_code)
  253. if 'Post' in json_data:
  254. data = json_data['Post']
  255. else:
  256. data = json_data
  257. upload_date = datetime.datetime.strptime(data['datestamp'], '%m-%d-%y %H:%M%p').strftime('%Y%m%d')
  258. video_url = data['media']['url']
  259. umobj = re.match(self._URL_EXT, video_url)
  260. if umobj is None:
  261. raise ValueError('Can not determine filename extension')
  262. ext = umobj.group(1)
  263. info = {
  264. 'id': data['item_id'],
  265. 'url': video_url,
  266. 'uploader': data['display_name'],
  267. 'upload_date': upload_date,
  268. 'title': data['title'],
  269. 'ext': ext,
  270. 'format': data['media']['mimeType'],
  271. 'thumbnail': data['thumbnailUrl'],
  272. 'description': data['description'],
  273. 'player_url': data['embedUrl'],
  274. 'user_agent': 'iTunes/10.6.1',
  275. }
  276. except (ValueError,KeyError) as err:
  277. raise ExtractorError(u'Unable to parse video information: %s' % repr(err))
  278. return [info]
  279. class MyVideoIE(InfoExtractor):
  280. """Information Extractor for myvideo.de."""
  281. _VALID_URL = r'(?:http://)?(?:www\.)?myvideo\.de/watch/([0-9]+)/([^?/]+).*'
  282. IE_NAME = u'myvideo'
  283. # Original Code from: https://github.com/dersphere/plugin.video.myvideo_de.git
  284. # Released into the Public Domain by Tristan Fischer on 2013-05-19
  285. # https://github.com/rg3/youtube-dl/pull/842
  286. def __rc4crypt(self,data, key):
  287. x = 0
  288. box = list(range(256))
  289. for i in list(range(256)):
  290. x = (x + box[i] + compat_ord(key[i % len(key)])) % 256
  291. box[i], box[x] = box[x], box[i]
  292. x = 0
  293. y = 0
  294. out = ''
  295. for char in data:
  296. x = (x + 1) % 256
  297. y = (y + box[x]) % 256
  298. box[x], box[y] = box[y], box[x]
  299. out += chr(compat_ord(char) ^ box[(box[x] + box[y]) % 256])
  300. return out
  301. def __md5(self,s):
  302. return hashlib.md5(s).hexdigest().encode()
  303. def _real_extract(self,url):
  304. mobj = re.match(self._VALID_URL, url)
  305. if mobj is None:
  306. raise ExtractorError(u'invalid URL: %s' % url)
  307. video_id = mobj.group(1)
  308. GK = (
  309. b'WXpnME1EZGhNRGhpTTJNM01XVmhOREU0WldNNVpHTTJOakpt'
  310. b'TW1FMU5tVTBNR05pWkRaa05XRXhNVFJoWVRVd1ptSXhaVEV3'
  311. b'TnpsbA0KTVRkbU1tSTRNdz09'
  312. )
  313. # Get video webpage
  314. webpage_url = 'http://www.myvideo.de/watch/%s' % video_id
  315. webpage = self._download_webpage(webpage_url, video_id)
  316. mobj = re.search('source src=\'(.+?)[.]([^.]+)\'', webpage)
  317. if mobj is not None:
  318. self.report_extraction(video_id)
  319. video_url = mobj.group(1) + '.flv'
  320. video_title = self._html_search_regex('<title>([^<]+)</title>',
  321. webpage, u'title')
  322. video_ext = self._search_regex('[.](.+?)$', video_url, u'extension')
  323. return [{
  324. 'id': video_id,
  325. 'url': video_url,
  326. 'uploader': None,
  327. 'upload_date': None,
  328. 'title': video_title,
  329. 'ext': u'flv',
  330. }]
  331. # try encxml
  332. mobj = re.search('var flashvars={(.+?)}', webpage)
  333. if mobj is None:
  334. raise ExtractorError(u'Unable to extract video')
  335. params = {}
  336. encxml = ''
  337. sec = mobj.group(1)
  338. for (a, b) in re.findall('(.+?):\'(.+?)\',?', sec):
  339. if not a == '_encxml':
  340. params[a] = b
  341. else:
  342. encxml = compat_urllib_parse.unquote(b)
  343. if not params.get('domain'):
  344. params['domain'] = 'www.myvideo.de'
  345. xmldata_url = '%s?%s' % (encxml, compat_urllib_parse.urlencode(params))
  346. if 'flash_playertype=MTV' in xmldata_url:
  347. self._downloader.report_warning(u'avoiding MTV player')
  348. xmldata_url = (
  349. 'http://www.myvideo.de/dynamic/get_player_video_xml.php'
  350. '?flash_playertype=D&ID=%s&_countlimit=4&autorun=yes'
  351. ) % video_id
  352. # get enc data
  353. enc_data = self._download_webpage(xmldata_url, video_id).split('=')[1]
  354. enc_data_b = binascii.unhexlify(enc_data)
  355. sk = self.__md5(
  356. base64.b64decode(base64.b64decode(GK)) +
  357. self.__md5(
  358. str(video_id).encode('utf-8')
  359. )
  360. )
  361. dec_data = self.__rc4crypt(enc_data_b, sk)
  362. # extracting infos
  363. self.report_extraction(video_id)
  364. video_url = None
  365. mobj = re.search('connectionurl=\'(.*?)\'', dec_data)
  366. if mobj:
  367. video_url = compat_urllib_parse.unquote(mobj.group(1))
  368. if 'myvideo2flash' in video_url:
  369. self._downloader.report_warning(u'forcing RTMPT ...')
  370. video_url = video_url.replace('rtmpe://', 'rtmpt://')
  371. if not video_url:
  372. # extract non rtmp videos
  373. mobj = re.search('path=\'(http.*?)\' source=\'(.*?)\'', dec_data)
  374. if mobj is None:
  375. raise ExtractorError(u'unable to extract url')
  376. video_url = compat_urllib_parse.unquote(mobj.group(1)) + compat_urllib_parse.unquote(mobj.group(2))
  377. video_file = self._search_regex('source=\'(.*?)\'', dec_data, u'video file')
  378. video_file = compat_urllib_parse.unquote(video_file)
  379. if not video_file.endswith('f4m'):
  380. ppath, prefix = video_file.split('.')
  381. video_playpath = '%s:%s' % (prefix, ppath)
  382. video_hls_playlist = ''
  383. else:
  384. video_playpath = ''
  385. video_hls_playlist = (
  386. video_filepath + video_file
  387. ).replace('.f4m', '.m3u8')
  388. video_swfobj = self._search_regex('swfobject.embedSWF\(\'(.+?)\'', webpage, u'swfobj')
  389. video_swfobj = compat_urllib_parse.unquote(video_swfobj)
  390. video_title = self._html_search_regex("<h1(?: class='globalHd')?>(.*?)</h1>",
  391. webpage, u'title')
  392. return [{
  393. 'id': video_id,
  394. 'url': video_url,
  395. 'tc_url': video_url,
  396. 'uploader': None,
  397. 'upload_date': None,
  398. 'title': video_title,
  399. 'ext': u'flv',
  400. 'play_path': video_playpath,
  401. 'video_file': video_file,
  402. 'video_hls_playlist': video_hls_playlist,
  403. 'player_url': video_swfobj,
  404. }]
  405. class ComedyCentralIE(InfoExtractor):
  406. """Information extractor for The Daily Show and Colbert Report """
  407. # urls can be abbreviations like :thedailyshow or :colbert
  408. # urls for episodes like:
  409. # or urls for clips like: http://www.thedailyshow.com/watch/mon-december-10-2012/any-given-gun-day
  410. # or: http://www.colbertnation.com/the-colbert-report-videos/421667/november-29-2012/moon-shattering-news
  411. # or: http://www.colbertnation.com/the-colbert-report-collections/422008/festival-of-lights/79524
  412. _VALID_URL = r"""^(:(?P<shortname>tds|thedailyshow|cr|colbert|colbertnation|colbertreport)
  413. |(https?://)?(www\.)?
  414. (?P<showname>thedailyshow|colbertnation)\.com/
  415. (full-episodes/(?P<episode>.*)|
  416. (?P<clip>
  417. (the-colbert-report-(videos|collections)/(?P<clipID>[0-9]+)/[^/]*/(?P<cntitle>.*?))
  418. |(watch/(?P<date>[^/]*)/(?P<tdstitle>.*)))))
  419. $"""
  420. _available_formats = ['3500', '2200', '1700', '1200', '750', '400']
  421. _video_extensions = {
  422. '3500': 'mp4',
  423. '2200': 'mp4',
  424. '1700': 'mp4',
  425. '1200': 'mp4',
  426. '750': 'mp4',
  427. '400': 'mp4',
  428. }
  429. _video_dimensions = {
  430. '3500': '1280x720',
  431. '2200': '960x540',
  432. '1700': '768x432',
  433. '1200': '640x360',
  434. '750': '512x288',
  435. '400': '384x216',
  436. }
  437. @classmethod
  438. def suitable(cls, url):
  439. """Receives a URL and returns True if suitable for this IE."""
  440. return re.match(cls._VALID_URL, url, re.VERBOSE) is not None
  441. def _print_formats(self, formats):
  442. print('Available formats:')
  443. for x in formats:
  444. print('%s\t:\t%s\t[%s]' %(x, self._video_extensions.get(x, 'mp4'), self._video_dimensions.get(x, '???')))
  445. def _real_extract(self, url):
  446. mobj = re.match(self._VALID_URL, url, re.VERBOSE)
  447. if mobj is None:
  448. raise ExtractorError(u'Invalid URL: %s' % url)
  449. if mobj.group('shortname'):
  450. if mobj.group('shortname') in ('tds', 'thedailyshow'):
  451. url = u'http://www.thedailyshow.com/full-episodes/'
  452. else:
  453. url = u'http://www.colbertnation.com/full-episodes/'
  454. mobj = re.match(self._VALID_URL, url, re.VERBOSE)
  455. assert mobj is not None
  456. if mobj.group('clip'):
  457. if mobj.group('showname') == 'thedailyshow':
  458. epTitle = mobj.group('tdstitle')
  459. else:
  460. epTitle = mobj.group('cntitle')
  461. dlNewest = False
  462. else:
  463. dlNewest = not mobj.group('episode')
  464. if dlNewest:
  465. epTitle = mobj.group('showname')
  466. else:
  467. epTitle = mobj.group('episode')
  468. self.report_extraction(epTitle)
  469. webpage,htmlHandle = self._download_webpage_handle(url, epTitle)
  470. if dlNewest:
  471. url = htmlHandle.geturl()
  472. mobj = re.match(self._VALID_URL, url, re.VERBOSE)
  473. if mobj is None:
  474. raise ExtractorError(u'Invalid redirected URL: ' + url)
  475. if mobj.group('episode') == '':
  476. raise ExtractorError(u'Redirected URL is still not specific: ' + url)
  477. epTitle = mobj.group('episode')
  478. mMovieParams = re.findall('(?:<param name="movie" value="|var url = ")(http://media.mtvnservices.com/([^"]*(?:episode|video).*?:.*?))"', webpage)
  479. if len(mMovieParams) == 0:
  480. # The Colbert Report embeds the information in a without
  481. # a URL prefix; so extract the alternate reference
  482. # and then add the URL prefix manually.
  483. altMovieParams = re.findall('data-mgid="([^"]*(?:episode|video).*?:.*?)"', webpage)
  484. if len(altMovieParams) == 0:
  485. raise ExtractorError(u'unable to find Flash URL in webpage ' + url)
  486. else:
  487. mMovieParams = [("http://media.mtvnservices.com/" + altMovieParams[0], altMovieParams[0])]
  488. uri = mMovieParams[0][1]
  489. indexUrl = 'http://shadow.comedycentral.com/feeds/video_player/mrss/?' + compat_urllib_parse.urlencode({'uri': uri})
  490. indexXml = self._download_webpage(indexUrl, epTitle,
  491. u'Downloading show index',
  492. u'unable to download episode index')
  493. results = []
  494. idoc = xml.etree.ElementTree.fromstring(indexXml)
  495. itemEls = idoc.findall('.//item')
  496. for partNum,itemEl in enumerate(itemEls):
  497. mediaId = itemEl.findall('./guid')[0].text
  498. shortMediaId = mediaId.split(':')[-1]
  499. showId = mediaId.split(':')[-2].replace('.com', '')
  500. officialTitle = itemEl.findall('./title')[0].text
  501. officialDate = unified_strdate(itemEl.findall('./pubDate')[0].text)
  502. configUrl = ('http://www.comedycentral.com/global/feeds/entertainment/media/mediaGenEntertainment.jhtml?' +
  503. compat_urllib_parse.urlencode({'uri': mediaId}))
  504. configXml = self._download_webpage(configUrl, epTitle,
  505. u'Downloading configuration for %s' % shortMediaId)
  506. cdoc = xml.etree.ElementTree.fromstring(configXml)
  507. turls = []
  508. for rendition in cdoc.findall('.//rendition'):
  509. finfo = (rendition.attrib['bitrate'], rendition.findall('./src')[0].text)
  510. turls.append(finfo)
  511. if len(turls) == 0:
  512. self._downloader.report_error(u'unable to download ' + mediaId + ': No videos found')
  513. continue
  514. if self._downloader.params.get('listformats', None):
  515. self._print_formats([i[0] for i in turls])
  516. return
  517. # For now, just pick the highest bitrate
  518. format,rtmp_video_url = turls[-1]
  519. # Get the format arg from the arg stream
  520. req_format = self._downloader.params.get('format', None)
  521. # Select format if we can find one
  522. for f,v in turls:
  523. if f == req_format:
  524. format, rtmp_video_url = f, v
  525. break
  526. m = re.match(r'^rtmpe?://.*?/(?P<finalid>gsp.comedystor/.*)$', rtmp_video_url)
  527. if not m:
  528. raise ExtractorError(u'Cannot transform RTMP url')
  529. base = 'http://mtvnmobile.vo.llnwd.net/kip0/_pxn=1+_pxI0=Ripod-h264+_pxL0=undefined+_pxM0=+_pxK=18639+_pxE=mp4/44620/mtvnorigin/'
  530. video_url = base + m.group('finalid')
  531. effTitle = showId + u'-' + epTitle + u' part ' + compat_str(partNum+1)
  532. info = {
  533. 'id': shortMediaId,
  534. 'url': video_url,
  535. 'uploader': showId,
  536. 'upload_date': officialDate,
  537. 'title': effTitle,
  538. 'ext': 'mp4',
  539. 'format': format,
  540. 'thumbnail': None,
  541. 'description': officialTitle,
  542. }
  543. results.append(info)
  544. return results
  545. class EscapistIE(InfoExtractor):
  546. """Information extractor for The Escapist """
  547. _VALID_URL = r'^(https?://)?(www\.)?escapistmagazine\.com/videos/view/(?P<showname>[^/]+)/(?P<episode>[^/?]+)[/?]?.*$'
  548. IE_NAME = u'escapist'
  549. def _real_extract(self, url):
  550. mobj = re.match(self._VALID_URL, url)
  551. if mobj is None:
  552. raise ExtractorError(u'Invalid URL: %s' % url)
  553. showName = mobj.group('showname')
  554. videoId = mobj.group('episode')
  555. self.report_extraction(videoId)
  556. webpage = self._download_webpage(url, videoId)
  557. videoDesc = self._html_search_regex('<meta name="description" content="([^"]*)"',
  558. webpage, u'description', fatal=False)
  559. imgUrl = self._html_search_regex('<meta property="og:image" content="([^"]*)"',
  560. webpage, u'thumbnail', fatal=False)
  561. playerUrl = self._html_search_regex('<meta property="og:video" content="([^"]*)"',
  562. webpage, u'player url')
  563. title = self._html_search_regex('<meta name="title" content="([^"]*)"',
  564. webpage, u'player url').split(' : ')[-1]
  565. configUrl = self._search_regex('config=(.*)$', playerUrl, u'config url')
  566. configUrl = compat_urllib_parse.unquote(configUrl)
  567. configJSON = self._download_webpage(configUrl, videoId,
  568. u'Downloading configuration',
  569. u'unable to download configuration')
  570. # Technically, it's JavaScript, not JSON
  571. configJSON = configJSON.replace("'", '"')
  572. try:
  573. config = json.loads(configJSON)
  574. except (ValueError,) as err:
  575. raise ExtractorError(u'Invalid JSON in configuration file: ' + compat_str(err))
  576. playlist = config['playlist']
  577. videoUrl = playlist[1]['url']
  578. info = {
  579. 'id': videoId,
  580. 'url': videoUrl,
  581. 'uploader': showName,
  582. 'upload_date': None,
  583. 'title': title,
  584. 'ext': 'mp4',
  585. 'thumbnail': imgUrl,
  586. 'description': videoDesc,
  587. 'player_url': playerUrl,
  588. }
  589. return [info]
  590. class CollegeHumorIE(InfoExtractor):
  591. """Information extractor for collegehumor.com"""
  592. _WORKING = False
  593. _VALID_URL = r'^(?:https?://)?(?:www\.)?collegehumor\.com/video/(?P<videoid>[0-9]+)/(?P<shorttitle>.*)$'
  594. IE_NAME = u'collegehumor'
  595. def report_manifest(self, video_id):
  596. """Report information extraction."""
  597. self.to_screen(u'%s: Downloading XML manifest' % video_id)
  598. def _real_extract(self, url):
  599. mobj = re.match(self._VALID_URL, url)
  600. if mobj is None:
  601. raise ExtractorError(u'Invalid URL: %s' % url)
  602. video_id = mobj.group('videoid')
  603. info = {
  604. 'id': video_id,
  605. 'uploader': None,
  606. 'upload_date': None,
  607. }
  608. self.report_extraction(video_id)
  609. xmlUrl = 'http://www.collegehumor.com/moogaloop/video/' + video_id
  610. try:
  611. metaXml = compat_urllib_request.urlopen(xmlUrl).read()
  612. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  613. raise ExtractorError(u'Unable to download video info XML: %s' % compat_str(err))
  614. mdoc = xml.etree.ElementTree.fromstring(metaXml)
  615. try:
  616. videoNode = mdoc.findall('./video')[0]
  617. info['description'] = videoNode.findall('./description')[0].text
  618. info['title'] = videoNode.findall('./caption')[0].text
  619. info['thumbnail'] = videoNode.findall('./thumbnail')[0].text
  620. manifest_url = videoNode.findall('./file')[0].text
  621. except IndexError:
  622. raise ExtractorError(u'Invalid metadata XML file')
  623. manifest_url += '?hdcore=2.10.3'
  624. self.report_manifest(video_id)
  625. try:
  626. manifestXml = compat_urllib_request.urlopen(manifest_url).read()
  627. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  628. raise ExtractorError(u'Unable to download video info XML: %s' % compat_str(err))
  629. adoc = xml.etree.ElementTree.fromstring(manifestXml)
  630. try:
  631. media_node = adoc.findall('./{http://ns.adobe.com/f4m/1.0}media')[0]
  632. node_id = media_node.attrib['url']
  633. video_id = adoc.findall('./{http://ns.adobe.com/f4m/1.0}id')[0].text
  634. except IndexError as err:
  635. raise ExtractorError(u'Invalid manifest file')
  636. url_pr = compat_urllib_parse_urlparse(manifest_url)
  637. url = url_pr.scheme + '://' + url_pr.netloc + '/z' + video_id[:-2] + '/' + node_id + 'Seg1-Frag1'
  638. info['url'] = url
  639. info['ext'] = 'f4f'
  640. return [info]
  641. class XVideosIE(InfoExtractor):
  642. """Information extractor for xvideos.com"""
  643. _VALID_URL = r'^(?:https?://)?(?:www\.)?xvideos\.com/video([0-9]+)(?:.*)'
  644. IE_NAME = u'xvideos'
  645. def _real_extract(self, url):
  646. mobj = re.match(self._VALID_URL, url)
  647. if mobj is None:
  648. raise ExtractorError(u'Invalid URL: %s' % url)
  649. video_id = mobj.group(1)
  650. webpage = self._download_webpage(url, video_id)
  651. self.report_extraction(video_id)
  652. # Extract video URL
  653. video_url = compat_urllib_parse.unquote(self._search_regex(r'flv_url=(.+?)&',
  654. webpage, u'video URL'))
  655. # Extract title
  656. video_title = self._html_search_regex(r'<title>(.*?)\s+-\s+XVID',
  657. webpage, u'title')
  658. # Extract video thumbnail
  659. video_thumbnail = self._search_regex(r'http://(?:img.*?\.)xvideos.com/videos/thumbs/[a-fA-F0-9]+/[a-fA-F0-9]+/[a-fA-F0-9]+/[a-fA-F0-9]+/([a-fA-F0-9.]+jpg)',
  660. webpage, u'thumbnail', fatal=False)
  661. info = {
  662. 'id': video_id,
  663. 'url': video_url,
  664. 'uploader': None,
  665. 'upload_date': None,
  666. 'title': video_title,
  667. 'ext': 'flv',
  668. 'thumbnail': video_thumbnail,
  669. 'description': None,
  670. }
  671. return [info]
  672. class SoundcloudIE(InfoExtractor):
  673. """Information extractor for soundcloud.com
  674. To access the media, the uid of the song and a stream token
  675. must be extracted from the page source and the script must make
  676. a request to media.soundcloud.com/crossdomain.xml. Then
  677. the media can be grabbed by requesting from an url composed
  678. of the stream token and uid
  679. """
  680. _VALID_URL = r'^(?:https?://)?(?:www\.)?soundcloud\.com/([\w\d-]+)/([\w\d-]+)'
  681. IE_NAME = u'soundcloud'
  682. def report_resolve(self, video_id):
  683. """Report information extraction."""
  684. self.to_screen(u'%s: Resolving id' % video_id)
  685. def _real_extract(self, url):
  686. mobj = re.match(self._VALID_URL, url)
  687. if mobj is None:
  688. raise ExtractorError(u'Invalid URL: %s' % url)
  689. # extract uploader (which is in the url)
  690. uploader = mobj.group(1)
  691. # extract simple title (uploader + slug of song title)
  692. slug_title = mobj.group(2)
  693. simple_title = uploader + u'-' + slug_title
  694. full_title = '%s/%s' % (uploader, slug_title)
  695. self.report_resolve(full_title)
  696. url = 'http://soundcloud.com/%s/%s' % (uploader, slug_title)
  697. resolv_url = 'http://api.soundcloud.com/resolve.json?url=' + url + '&client_id=b45b1aa10f1ac2941910a7f0d10f8e28'
  698. info_json = self._download_webpage(resolv_url, full_title, u'Downloading info JSON')
  699. info = json.loads(info_json)
  700. video_id = info['id']
  701. self.report_extraction(full_title)
  702. streams_url = 'https://api.sndcdn.com/i1/tracks/' + str(video_id) + '/streams?client_id=b45b1aa10f1ac2941910a7f0d10f8e28'
  703. stream_json = self._download_webpage(streams_url, full_title,
  704. u'Downloading stream definitions',
  705. u'unable to download stream definitions')
  706. streams = json.loads(stream_json)
  707. mediaURL = streams['http_mp3_128_url']
  708. upload_date = unified_strdate(info['created_at'])
  709. return [{
  710. 'id': info['id'],
  711. 'url': mediaURL,
  712. 'uploader': info['user']['username'],
  713. 'upload_date': upload_date,
  714. 'title': info['title'],
  715. 'ext': u'mp3',
  716. 'description': info['description'],
  717. }]
  718. class SoundcloudSetIE(InfoExtractor):
  719. """Information extractor for soundcloud.com sets
  720. To access the media, the uid of the song and a stream token
  721. must be extracted from the page source and the script must make
  722. a request to media.soundcloud.com/crossdomain.xml. Then
  723. the media can be grabbed by requesting from an url composed
  724. of the stream token and uid
  725. """
  726. _VALID_URL = r'^(?:https?://)?(?:www\.)?soundcloud\.com/([\w\d-]+)/sets/([\w\d-]+)'
  727. IE_NAME = u'soundcloud:set'
  728. def report_resolve(self, video_id):
  729. """Report information extraction."""
  730. self.to_screen(u'%s: Resolving id' % video_id)
  731. def _real_extract(self, url):
  732. mobj = re.match(self._VALID_URL, url)
  733. if mobj is None:
  734. raise ExtractorError(u'Invalid URL: %s' % url)
  735. # extract uploader (which is in the url)
  736. uploader = mobj.group(1)
  737. # extract simple title (uploader + slug of song title)
  738. slug_title = mobj.group(2)
  739. simple_title = uploader + u'-' + slug_title
  740. full_title = '%s/sets/%s' % (uploader, slug_title)
  741. self.report_resolve(full_title)
  742. url = 'http://soundcloud.com/%s/sets/%s' % (uploader, slug_title)
  743. resolv_url = 'http://api.soundcloud.com/resolve.json?url=' + url + '&client_id=b45b1aa10f1ac2941910a7f0d10f8e28'
  744. info_json = self._download_webpage(resolv_url, full_title)
  745. videos = []
  746. info = json.loads(info_json)
  747. if 'errors' in info:
  748. for err in info['errors']:
  749. self._downloader.report_error(u'unable to download video webpage: %s' % compat_str(err['error_message']))
  750. return
  751. self.report_extraction(full_title)
  752. for track in info['tracks']:
  753. video_id = track['id']
  754. streams_url = 'https://api.sndcdn.com/i1/tracks/' + str(video_id) + '/streams?client_id=b45b1aa10f1ac2941910a7f0d10f8e28'
  755. stream_json = self._download_webpage(streams_url, video_id, u'Downloading track info JSON')
  756. self.report_extraction(video_id)
  757. streams = json.loads(stream_json)
  758. mediaURL = streams['http_mp3_128_url']
  759. videos.append({
  760. 'id': video_id,
  761. 'url': mediaURL,
  762. 'uploader': track['user']['username'],
  763. 'upload_date': unified_strdate(track['created_at']),
  764. 'title': track['title'],
  765. 'ext': u'mp3',
  766. 'description': track['description'],
  767. })
  768. return videos
  769. class InfoQIE(InfoExtractor):
  770. """Information extractor for infoq.com"""
  771. _VALID_URL = r'^(?:https?://)?(?:www\.)?infoq\.com/[^/]+/[^/]+$'
  772. def _real_extract(self, url):
  773. mobj = re.match(self._VALID_URL, url)
  774. if mobj is None:
  775. raise ExtractorError(u'Invalid URL: %s' % url)
  776. webpage = self._download_webpage(url, video_id=url)
  777. self.report_extraction(url)
  778. # Extract video URL
  779. mobj = re.search(r"jsclassref ?= ?'([^']*)'", webpage)
  780. if mobj is None:
  781. raise ExtractorError(u'Unable to extract video url')
  782. real_id = compat_urllib_parse.unquote(base64.b64decode(mobj.group(1).encode('ascii')).decode('utf-8'))
  783. video_url = 'rtmpe://video.infoq.com/cfx/st/' + real_id
  784. # Extract title
  785. video_title = self._search_regex(r'contentTitle = "(.*?)";',
  786. webpage, u'title')
  787. # Extract description
  788. video_description = self._html_search_regex(r'<meta name="description" content="(.*)"(?:\s*/)?>',
  789. webpage, u'description', fatal=False)
  790. video_filename = video_url.split('/')[-1]
  791. video_id, extension = video_filename.split('.')
  792. info = {
  793. 'id': video_id,
  794. 'url': video_url,
  795. 'uploader': None,
  796. 'upload_date': None,
  797. 'title': video_title,
  798. 'ext': extension, # Extension is always(?) mp4, but seems to be flv
  799. 'thumbnail': None,
  800. 'description': video_description,
  801. }
  802. return [info]
  803. class MixcloudIE(InfoExtractor):
  804. """Information extractor for www.mixcloud.com"""
  805. _WORKING = False # New API, but it seems good http://www.mixcloud.com/developers/documentation/
  806. _VALID_URL = r'^(?:https?://)?(?:www\.)?mixcloud\.com/([\w\d-]+)/([\w\d-]+)'
  807. IE_NAME = u'mixcloud'
  808. def report_download_json(self, file_id):
  809. """Report JSON download."""
  810. self.to_screen(u'Downloading json')
  811. def get_urls(self, jsonData, fmt, bitrate='best'):
  812. """Get urls from 'audio_formats' section in json"""
  813. file_url = None
  814. try:
  815. bitrate_list = jsonData[fmt]
  816. if bitrate is None or bitrate == 'best' or bitrate not in bitrate_list:
  817. bitrate = max(bitrate_list) # select highest
  818. url_list = jsonData[fmt][bitrate]
  819. except TypeError: # we have no bitrate info.
  820. url_list = jsonData[fmt]
  821. return url_list
  822. def check_urls(self, url_list):
  823. """Returns 1st active url from list"""
  824. for url in url_list:
  825. try:
  826. compat_urllib_request.urlopen(url)
  827. return url
  828. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  829. url = None
  830. return None
  831. def _print_formats(self, formats):
  832. print('Available formats:')
  833. for fmt in formats.keys():
  834. for b in formats[fmt]:
  835. try:
  836. ext = formats[fmt][b][0]
  837. print('%s\t%s\t[%s]' % (fmt, b, ext.split('.')[-1]))
  838. except TypeError: # we have no bitrate info
  839. ext = formats[fmt][0]
  840. print('%s\t%s\t[%s]' % (fmt, '??', ext.split('.')[-1]))
  841. break
  842. def _real_extract(self, url):
  843. mobj = re.match(self._VALID_URL, url)
  844. if mobj is None:
  845. raise ExtractorError(u'Invalid URL: %s' % url)
  846. # extract uploader & filename from url
  847. uploader = mobj.group(1).decode('utf-8')
  848. file_id = uploader + "-" + mobj.group(2).decode('utf-8')
  849. # construct API request
  850. file_url = 'http://www.mixcloud.com/api/1/cloudcast/' + '/'.join(url.split('/')[-3:-1]) + '.json'
  851. # retrieve .json file with links to files
  852. request = compat_urllib_request.Request(file_url)
  853. try:
  854. self.report_download_json(file_url)
  855. jsonData = compat_urllib_request.urlopen(request).read()
  856. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  857. raise ExtractorError(u'Unable to retrieve file: %s' % compat_str(err))
  858. # parse JSON
  859. json_data = json.loads(jsonData)
  860. player_url = json_data['player_swf_url']
  861. formats = dict(json_data['audio_formats'])
  862. req_format = self._downloader.params.get('format', None)
  863. bitrate = None
  864. if self._downloader.params.get('listformats', None):
  865. self._print_formats(formats)
  866. return
  867. if req_format is None or req_format == 'best':
  868. for format_param in formats.keys():
  869. url_list = self.get_urls(formats, format_param)
  870. # check urls
  871. file_url = self.check_urls(url_list)
  872. if file_url is not None:
  873. break # got it!
  874. else:
  875. if req_format not in formats:
  876. raise ExtractorError(u'Format is not available')
  877. url_list = self.get_urls(formats, req_format)
  878. file_url = self.check_urls(url_list)
  879. format_param = req_format
  880. return [{
  881. 'id': file_id.decode('utf-8'),
  882. 'url': file_url.decode('utf-8'),
  883. 'uploader': uploader.decode('utf-8'),
  884. 'upload_date': None,
  885. 'title': json_data['name'],
  886. 'ext': file_url.split('.')[-1].decode('utf-8'),
  887. 'format': (format_param is None and u'NA' or format_param.decode('utf-8')),
  888. 'thumbnail': json_data['thumbnail_url'],
  889. 'description': json_data['description'],
  890. 'player_url': player_url.decode('utf-8'),
  891. }]
  892. class StanfordOpenClassroomIE(InfoExtractor):
  893. """Information extractor for Stanford's Open ClassRoom"""
  894. _VALID_URL = r'^(?:https?://)?openclassroom.stanford.edu(?P<path>/?|(/MainFolder/(?:HomePage|CoursePage|VideoPage)\.php([?]course=(?P<course>[^&]+)(&video=(?P<video>[^&]+))?(&.*)?)?))$'
  895. IE_NAME = u'stanfordoc'
  896. def _real_extract(self, url):
  897. mobj = re.match(self._VALID_URL, url)
  898. if mobj is None:
  899. raise ExtractorError(u'Invalid URL: %s' % url)
  900. if mobj.group('course') and mobj.group('video'): # A specific video
  901. course = mobj.group('course')
  902. video = mobj.group('video')
  903. info = {
  904. 'id': course + '_' + video,
  905. 'uploader': None,
  906. 'upload_date': None,
  907. }
  908. self.report_extraction(info['id'])
  909. baseUrl = 'http://openclassroom.stanford.edu/MainFolder/courses/' + course + '/videos/'
  910. xmlUrl = baseUrl + video + '.xml'
  911. try:
  912. metaXml = compat_urllib_request.urlopen(xmlUrl).read()
  913. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  914. raise ExtractorError(u'Unable to download video info XML: %s' % compat_str(err))
  915. mdoc = xml.etree.ElementTree.fromstring(metaXml)
  916. try:
  917. info['title'] = mdoc.findall('./title')[0].text
  918. info['url'] = baseUrl + mdoc.findall('./videoFile')[0].text
  919. except IndexError:
  920. raise ExtractorError(u'Invalid metadata XML file')
  921. info['ext'] = info['url'].rpartition('.')[2]
  922. return [info]
  923. elif mobj.group('course'): # A course page
  924. course = mobj.group('course')
  925. info = {
  926. 'id': course,
  927. 'type': 'playlist',
  928. 'uploader': None,
  929. 'upload_date': None,
  930. }
  931. coursepage = self._download_webpage(url, info['id'],
  932. note='Downloading course info page',
  933. errnote='Unable to download course info page')
  934. info['title'] = self._html_search_regex('<h1>([^<]+)</h1>', coursepage, 'title', default=info['id'])
  935. info['description'] = self._html_search_regex('<description>([^<]+)</description>',
  936. coursepage, u'description', fatal=False)
  937. links = orderedSet(re.findall('<a href="(VideoPage.php\?[^"]+)">', coursepage))
  938. info['list'] = [
  939. {
  940. 'type': 'reference',
  941. 'url': 'http://openclassroom.stanford.edu/MainFolder/' + unescapeHTML(vpage),
  942. }
  943. for vpage in links]
  944. results = []
  945. for entry in info['list']:
  946. assert entry['type'] == 'reference'
  947. results += self.extract(entry['url'])
  948. return results
  949. else: # Root page
  950. info = {
  951. 'id': 'Stanford OpenClassroom',
  952. 'type': 'playlist',
  953. 'uploader': None,
  954. 'upload_date': None,
  955. }
  956. self.report_download_webpage(info['id'])
  957. rootURL = 'http://openclassroom.stanford.edu/MainFolder/HomePage.php'
  958. try:
  959. rootpage = compat_urllib_request.urlopen(rootURL).read()
  960. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  961. raise ExtractorError(u'Unable to download course info page: ' + compat_str(err))
  962. info['title'] = info['id']
  963. links = orderedSet(re.findall('<a href="(CoursePage.php\?[^"]+)">', rootpage))
  964. info['list'] = [
  965. {
  966. 'type': 'reference',
  967. 'url': 'http://openclassroom.stanford.edu/MainFolder/' + unescapeHTML(cpage),
  968. }
  969. for cpage in links]
  970. results = []
  971. for entry in info['list']:
  972. assert entry['type'] == 'reference'
  973. results += self.extract(entry['url'])
  974. return results
  975. class MTVIE(InfoExtractor):
  976. """Information extractor for MTV.com"""
  977. _VALID_URL = r'^(?P<proto>https?://)?(?:www\.)?mtv\.com/videos/[^/]+/(?P<videoid>[0-9]+)/[^/]+$'
  978. IE_NAME = u'mtv'
  979. def _real_extract(self, url):
  980. mobj = re.match(self._VALID_URL, url)
  981. if mobj is None:
  982. raise ExtractorError(u'Invalid URL: %s' % url)
  983. if not mobj.group('proto'):
  984. url = 'http://' + url
  985. video_id = mobj.group('videoid')
  986. webpage = self._download_webpage(url, video_id)
  987. song_name = self._html_search_regex(r'<meta name="mtv_vt" content="([^"]+)"/>',
  988. webpage, u'song name', fatal=False)
  989. video_title = self._html_search_regex(r'<meta name="mtv_an" content="([^"]+)"/>',
  990. webpage, u'title')
  991. mtvn_uri = self._html_search_regex(r'<meta name="mtvn_uri" content="([^"]+)"/>',
  992. webpage, u'mtvn_uri', fatal=False)
  993. content_id = self._search_regex(r'MTVN.Player.defaultPlaylistId = ([0-9]+);',
  994. webpage, u'content id', fatal=False)
  995. videogen_url = 'http://www.mtv.com/player/includes/mediaGen.jhtml?uri=' + mtvn_uri + '&id=' + content_id + '&vid=' + video_id + '&ref=www.mtvn.com&viewUri=' + mtvn_uri
  996. self.report_extraction(video_id)
  997. request = compat_urllib_request.Request(videogen_url)
  998. try:
  999. metadataXml = compat_urllib_request.urlopen(request).read()
  1000. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  1001. raise ExtractorError(u'Unable to download video metadata: %s' % compat_str(err))
  1002. mdoc = xml.etree.ElementTree.fromstring(metadataXml)
  1003. renditions = mdoc.findall('.//rendition')
  1004. # For now, always pick the highest quality.
  1005. rendition = renditions[-1]
  1006. try:
  1007. _,_,ext = rendition.attrib['type'].partition('/')
  1008. format = ext + '-' + rendition.attrib['width'] + 'x' + rendition.attrib['height'] + '_' + rendition.attrib['bitrate']
  1009. video_url = rendition.find('./src').text
  1010. except KeyError:
  1011. raise ExtractorError('Invalid rendition field.')
  1012. info = {
  1013. 'id': video_id,
  1014. 'url': video_url,
  1015. 'uploader': performer,
  1016. 'upload_date': None,
  1017. 'title': video_title,
  1018. 'ext': ext,
  1019. 'format': format,
  1020. }
  1021. return [info]
  1022. class YoukuIE(InfoExtractor):
  1023. _VALID_URL = r'(?:http://)?v\.youku\.com/v_show/id_(?P<ID>[A-Za-z0-9]+)\.html'
  1024. def _gen_sid(self):
  1025. nowTime = int(time.time() * 1000)
  1026. random1 = random.randint(1000,1998)
  1027. random2 = random.randint(1000,9999)
  1028. return "%d%d%d" %(nowTime,random1,random2)
  1029. def _get_file_ID_mix_string(self, seed):
  1030. mixed = []
  1031. source = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/\:._-1234567890")
  1032. seed = float(seed)
  1033. for i in range(len(source)):
  1034. seed = (seed * 211 + 30031 ) % 65536
  1035. index = math.floor(seed / 65536 * len(source) )
  1036. mixed.append(source[int(index)])
  1037. source.remove(source[int(index)])
  1038. #return ''.join(mixed)
  1039. return mixed
  1040. def _get_file_id(self, fileId, seed):
  1041. mixed = self._get_file_ID_mix_string(seed)
  1042. ids = fileId.split('*')
  1043. realId = []
  1044. for ch in ids:
  1045. if ch:
  1046. realId.append(mixed[int(ch)])
  1047. return ''.join(realId)
  1048. def _real_extract(self, url):
  1049. mobj = re.match(self._VALID_URL, url)
  1050. if mobj is None:
  1051. raise ExtractorError(u'Invalid URL: %s' % url)
  1052. video_id = mobj.group('ID')
  1053. info_url = 'http://v.youku.com/player/getPlayList/VideoIDS/' + video_id
  1054. jsondata = self._download_webpage(info_url, video_id)
  1055. self.report_extraction(video_id)
  1056. try:
  1057. config = json.loads(jsondata)
  1058. video_title = config['data'][0]['title']
  1059. seed = config['data'][0]['seed']
  1060. format = self._downloader.params.get('format', None)
  1061. supported_format = list(config['data'][0]['streamfileids'].keys())
  1062. if format is None or format == 'best':
  1063. if 'hd2' in supported_format:
  1064. format = 'hd2'
  1065. else:
  1066. format = 'flv'
  1067. ext = u'flv'
  1068. elif format == 'worst':
  1069. format = 'mp4'
  1070. ext = u'mp4'
  1071. else:
  1072. format = 'flv'
  1073. ext = u'flv'
  1074. fileid = config['data'][0]['streamfileids'][format]
  1075. keys = [s['k'] for s in config['data'][0]['segs'][format]]
  1076. except (UnicodeDecodeError, ValueError, KeyError):
  1077. raise ExtractorError(u'Unable to extract info section')
  1078. files_info=[]
  1079. sid = self._gen_sid()
  1080. fileid = self._get_file_id(fileid, seed)
  1081. #column 8,9 of fileid represent the segment number
  1082. #fileid[7:9] should be changed
  1083. for index, key in enumerate(keys):
  1084. temp_fileid = '%s%02X%s' % (fileid[0:8], index, fileid[10:])
  1085. download_url = 'http://f.youku.com/player/getFlvPath/sid/%s_%02X/st/flv/fileid/%s?k=%s' % (sid, index, temp_fileid, key)
  1086. info = {
  1087. 'id': '%s_part%02d' % (video_id, index),
  1088. 'url': download_url,
  1089. 'uploader': None,
  1090. 'upload_date': None,
  1091. 'title': video_title,
  1092. 'ext': ext,
  1093. }
  1094. files_info.append(info)
  1095. return files_info
  1096. class XNXXIE(InfoExtractor):
  1097. """Information extractor for xnxx.com"""
  1098. _VALID_URL = r'^(?:https?://)?video\.xnxx\.com/video([0-9]+)/(.*)'
  1099. IE_NAME = u'xnxx'
  1100. VIDEO_URL_RE = r'flv_url=(.*?)&amp;'
  1101. VIDEO_TITLE_RE = r'<title>(.*?)\s+-\s+XNXX.COM'
  1102. VIDEO_THUMB_RE = r'url_bigthumb=(.*?)&amp;'
  1103. def _real_extract(self, url):
  1104. mobj = re.match(self._VALID_URL, url)
  1105. if mobj is None:
  1106. raise ExtractorError(u'Invalid URL: %s' % url)
  1107. video_id = mobj.group(1)
  1108. # Get webpage content
  1109. webpage = self._download_webpage(url, video_id)
  1110. video_url = self._search_regex(self.VIDEO_URL_RE,
  1111. webpage, u'video URL')
  1112. video_url = compat_urllib_parse.unquote(video_url)
  1113. video_title = self._html_search_regex(self.VIDEO_TITLE_RE,
  1114. webpage, u'title')
  1115. video_thumbnail = self._search_regex(self.VIDEO_THUMB_RE,
  1116. webpage, u'thumbnail', fatal=False)
  1117. return [{
  1118. 'id': video_id,
  1119. 'url': video_url,
  1120. 'uploader': None,
  1121. 'upload_date': None,
  1122. 'title': video_title,
  1123. 'ext': 'flv',
  1124. 'thumbnail': video_thumbnail,
  1125. 'description': None,
  1126. }]
  1127. class GooglePlusIE(InfoExtractor):
  1128. """Information extractor for plus.google.com."""
  1129. _VALID_URL = r'(?:https://)?plus\.google\.com/(?:[^/]+/)*?posts/(\w+)'
  1130. IE_NAME = u'plus.google'
  1131. def _real_extract(self, url):
  1132. # Extract id from URL
  1133. mobj = re.match(self._VALID_URL, url)
  1134. if mobj is None:
  1135. raise ExtractorError(u'Invalid URL: %s' % url)
  1136. post_url = mobj.group(0)
  1137. video_id = mobj.group(1)
  1138. video_extension = 'flv'
  1139. # Step 1, Retrieve post webpage to extract further information
  1140. webpage = self._download_webpage(post_url, video_id, u'Downloading entry webpage')
  1141. self.report_extraction(video_id)
  1142. # Extract update date
  1143. upload_date = self._html_search_regex('title="Timestamp">(.*?)</a>',
  1144. webpage, u'upload date', fatal=False)
  1145. if upload_date:
  1146. # Convert timestring to a format suitable for filename
  1147. upload_date = datetime.datetime.strptime(upload_date, "%Y-%m-%d")
  1148. upload_date = upload_date.strftime('%Y%m%d')
  1149. # Extract uploader
  1150. uploader = self._html_search_regex(r'rel\="author".*?>(.*?)</a>',
  1151. webpage, u'uploader', fatal=False)
  1152. # Extract title
  1153. # Get the first line for title
  1154. video_title = self._html_search_regex(r'<meta name\=\"Description\" content\=\"(.*?)[\n<"]',
  1155. webpage, 'title', default=u'NA')
  1156. # Step 2, Stimulate clicking the image box to launch video
  1157. video_page = self._search_regex('"(https\://plus\.google\.com/photos/.*?)",,"image/jpeg","video"\]',
  1158. webpage, u'video page URL')
  1159. webpage = self._download_webpage(video_page, video_id, u'Downloading video page')
  1160. # Extract video links on video page
  1161. """Extract video links of all sizes"""
  1162. pattern = '\d+,\d+,(\d+),"(http\://redirector\.googlevideo\.com.*?)"'
  1163. mobj = re.findall(pattern, webpage)
  1164. if len(mobj) == 0:
  1165. raise ExtractorError(u'Unable to extract video links')
  1166. # Sort in resolution
  1167. links = sorted(mobj)
  1168. # Choose the lowest of the sort, i.e. highest resolution
  1169. video_url = links[-1]
  1170. # Only get the url. The resolution part in the tuple has no use anymore
  1171. video_url = video_url[-1]
  1172. # Treat escaped \u0026 style hex
  1173. try:
  1174. video_url = video_url.decode("unicode_escape")
  1175. except AttributeError: # Python 3
  1176. video_url = bytes(video_url, 'ascii').decode('unicode-escape')
  1177. return [{
  1178. 'id': video_id,
  1179. 'url': video_url,
  1180. 'uploader': uploader,
  1181. 'upload_date': upload_date,
  1182. 'title': video_title,
  1183. 'ext': video_extension,
  1184. }]
  1185. class NBAIE(InfoExtractor):
  1186. _VALID_URL = r'^(?:https?://)?(?:watch\.|www\.)?nba\.com/(?:nba/)?video(/[^?]*?)(?:/index\.html)?(?:\?.*)?$'
  1187. IE_NAME = u'nba'
  1188. def _real_extract(self, url):
  1189. mobj = re.match(self._VALID_URL, url)
  1190. if mobj is None:
  1191. raise ExtractorError(u'Invalid URL: %s' % url)
  1192. video_id = mobj.group(1)
  1193. webpage = self._download_webpage(url, video_id)
  1194. video_url = u'http://ht-mobile.cdn.turner.com/nba/big' + video_id + '_nba_1280x720.mp4'
  1195. shortened_video_id = video_id.rpartition('/')[2]
  1196. title = self._html_search_regex(r'<meta property="og:title" content="(.*?)"',
  1197. webpage, 'title', default=shortened_video_id).replace('NBA.com: ', '')
  1198. # It isn't there in the HTML it returns to us
  1199. # uploader_date = self._html_search_regex(r'<b>Date:</b> (.*?)</div>', webpage, 'upload_date', fatal=False)
  1200. description = self._html_search_regex(r'<meta name="description" (?:content|value)="(.*?)" />', webpage, 'description', fatal=False)
  1201. info = {
  1202. 'id': shortened_video_id,
  1203. 'url': video_url,
  1204. 'ext': 'mp4',
  1205. 'title': title,
  1206. # 'uploader_date': uploader_date,
  1207. 'description': description,
  1208. }
  1209. return [info]
  1210. class JustinTVIE(InfoExtractor):
  1211. """Information extractor for justin.tv and twitch.tv"""
  1212. # TODO: One broadcast may be split into multiple videos. The key
  1213. # 'broadcast_id' is the same for all parts, and 'broadcast_part'
  1214. # starts at 1 and increases. Can we treat all parts as one video?
  1215. _VALID_URL = r"""(?x)^(?:http://)?(?:www\.)?(?:twitch|justin)\.tv/
  1216. (?:
  1217. (?P<channelid>[^/]+)|
  1218. (?:(?:[^/]+)/b/(?P<videoid>[^/]+))|
  1219. (?:(?:[^/]+)/c/(?P<chapterid>[^/]+))
  1220. )
  1221. /?(?:\#.*)?$
  1222. """
  1223. _JUSTIN_PAGE_LIMIT = 100
  1224. IE_NAME = u'justin.tv'
  1225. def report_download_page(self, channel, offset):
  1226. """Report attempt to download a single page of videos."""
  1227. self.to_screen(u'%s: Downloading video information from %d to %d' %
  1228. (channel, offset, offset + self._JUSTIN_PAGE_LIMIT))
  1229. # Return count of items, list of *valid* items
  1230. def _parse_page(self, url, video_id):
  1231. webpage = self._download_webpage(url, video_id,
  1232. u'Downloading video info JSON',
  1233. u'unable to download video info JSON')
  1234. response = json.loads(webpage)
  1235. if type(response) != list:
  1236. error_text = response.get('error', 'unknown error')
  1237. raise ExtractorError(u'Justin.tv API: %s' % error_text)
  1238. info = []
  1239. for clip in response:
  1240. video_url = clip['video_file_url']
  1241. if video_url:
  1242. video_extension = os.path.splitext(video_url)[1][1:]
  1243. video_date = re.sub('-', '', clip['start_time'][:10])
  1244. video_uploader_id = clip.get('user_id', clip.get('channel_id'))
  1245. video_id = clip['id']
  1246. video_title = clip.get('title', video_id)
  1247. info.append({
  1248. 'id': video_id,
  1249. 'url': video_url,
  1250. 'title': video_title,
  1251. 'uploader': clip.get('channel_name', video_uploader_id),
  1252. 'uploader_id': video_uploader_id,
  1253. 'upload_date': video_date,
  1254. 'ext': video_extension,
  1255. })
  1256. return (len(response), info)
  1257. def _real_extract(self, url):
  1258. mobj = re.match(self._VALID_URL, url)
  1259. if mobj is None:
  1260. raise ExtractorError(u'invalid URL: %s' % url)
  1261. api_base = 'http://api.justin.tv'
  1262. paged = False
  1263. if mobj.group('channelid'):
  1264. paged = True
  1265. video_id = mobj.group('channelid')
  1266. api = api_base + '/channel/archives/%s.json' % video_id
  1267. elif mobj.group('chapterid'):
  1268. chapter_id = mobj.group('chapterid')
  1269. webpage = self._download_webpage(url, chapter_id)
  1270. m = re.search(r'PP\.archive_id = "([0-9]+)";', webpage)
  1271. if not m:
  1272. raise ExtractorError(u'Cannot find archive of a chapter')
  1273. archive_id = m.group(1)
  1274. api = api_base + '/broadcast/by_chapter/%s.xml' % chapter_id
  1275. chapter_info_xml = self._download_webpage(api, chapter_id,
  1276. note=u'Downloading chapter information',
  1277. errnote=u'Chapter information download failed')
  1278. doc = xml.etree.ElementTree.fromstring(chapter_info_xml)
  1279. for a in doc.findall('.//archive'):
  1280. if archive_id == a.find('./id').text:
  1281. break
  1282. else:
  1283. raise ExtractorError(u'Could not find chapter in chapter information')
  1284. video_url = a.find('./video_file_url').text
  1285. video_ext = video_url.rpartition('.')[2] or u'flv'
  1286. chapter_api_url = u'https://api.twitch.tv/kraken/videos/c' + chapter_id
  1287. chapter_info_json = self._download_webpage(chapter_api_url, u'c' + chapter_id,
  1288. note='Downloading chapter metadata',
  1289. errnote='Download of chapter metadata failed')
  1290. chapter_info = json.loads(chapter_info_json)
  1291. bracket_start = int(doc.find('.//bracket_start').text)
  1292. bracket_end = int(doc.find('.//bracket_end').text)
  1293. # TODO determine start (and probably fix up file)
  1294. # youtube-dl -v http://www.twitch.tv/firmbelief/c/1757457
  1295. #video_url += u'?start=' + TODO:start_timestamp
  1296. # bracket_start is 13290, but we want 51670615
  1297. self._downloader.report_warning(u'Chapter detected, but we can just download the whole file. '
  1298. u'Chapter starts at %s and ends at %s' % (formatSeconds(bracket_start), formatSeconds(bracket_end)))
  1299. info = {
  1300. 'id': u'c' + chapter_id,
  1301. 'url': video_url,
  1302. 'ext': video_ext,
  1303. 'title': chapter_info['title'],
  1304. 'thumbnail': chapter_info['preview'],
  1305. 'description': chapter_info['description'],
  1306. 'uploader': chapter_info['channel']['display_name'],
  1307. 'uploader_id': chapter_info['channel']['name'],
  1308. }
  1309. return [info]
  1310. else:
  1311. video_id = mobj.group('videoid')
  1312. api = api_base + '/broadcast/by_archive/%s.json' % video_id
  1313. self.report_extraction(video_id)
  1314. info = []
  1315. offset = 0
  1316. limit = self._JUSTIN_PAGE_LIMIT
  1317. while True:
  1318. if paged:
  1319. self.report_download_page(video_id, offset)
  1320. page_url = api + ('?offset=%d&limit=%d' % (offset, limit))
  1321. page_count, page_info = self._parse_page(page_url, video_id)
  1322. info.extend(page_info)
  1323. if not paged or page_count != limit:
  1324. break
  1325. offset += limit
  1326. return info
  1327. class FunnyOrDieIE(InfoExtractor):
  1328. _VALID_URL = r'^(?:https?://)?(?:www\.)?funnyordie\.com/videos/(?P<id>[0-9a-f]+)/.*$'
  1329. def _real_extract(self, url):
  1330. mobj = re.match(self._VALID_URL, url)
  1331. if mobj is None:
  1332. raise ExtractorError(u'invalid URL: %s' % url)
  1333. video_id = mobj.group('id')
  1334. webpage = self._download_webpage(url, video_id)
  1335. video_url = self._html_search_regex(r'<video[^>]*>\s*<source[^>]*>\s*<source src="(?P<url>[^"]+)"',
  1336. webpage, u'video URL', flags=re.DOTALL)
  1337. title = self._html_search_regex((r"<h1 class='player_page_h1'.*?>(?P<title>.*?)</h1>",
  1338. r'<title>(?P<title>[^<]+?)</title>'), webpage, 'title', flags=re.DOTALL)
  1339. video_description = self._html_search_regex(r'<meta property="og:description" content="(?P<desc>.*?)"',
  1340. webpage, u'description', fatal=False, flags=re.DOTALL)
  1341. info = {
  1342. 'id': video_id,
  1343. 'url': video_url,
  1344. 'ext': 'mp4',
  1345. 'title': title,
  1346. 'description': video_description,
  1347. }
  1348. return [info]
  1349. class SteamIE(InfoExtractor):
  1350. _VALID_URL = r"""http://store\.steampowered\.com/
  1351. (agecheck/)?
  1352. (?P<urltype>video|app)/ #If the page is only for videos or for a game
  1353. (?P<gameID>\d+)/?
  1354. (?P<videoID>\d*)(?P<extra>\??) #For urltype == video we sometimes get the videoID
  1355. """
  1356. _VIDEO_PAGE_TEMPLATE = 'http://store.steampowered.com/video/%s/'
  1357. _AGECHECK_TEMPLATE = 'http://store.steampowered.com/agecheck/video/%s/?snr=1_agecheck_agecheck__age-gate&ageDay=1&ageMonth=January&ageYear=1970'
  1358. @classmethod
  1359. def suitable(cls, url):
  1360. """Receives a URL and returns True if suitable for this IE."""
  1361. return re.match(cls._VALID_URL, url, re.VERBOSE) is not None
  1362. def _real_extract(self, url):
  1363. m = re.match(self._VALID_URL, url, re.VERBOSE)
  1364. gameID = m.group('gameID')
  1365. videourl = self._VIDEO_PAGE_TEMPLATE % gameID
  1366. webpage = self._download_webpage(videourl, gameID)
  1367. if re.search('<h2>Please enter your birth date to continue:</h2>', webpage) is not None:
  1368. videourl = self._AGECHECK_TEMPLATE % gameID
  1369. self.report_age_confirmation()
  1370. webpage = self._download_webpage(videourl, gameID)
  1371. self.report_extraction(gameID)
  1372. game_title = self._html_search_regex(r'<h2 class="pageheader">(.*?)</h2>',
  1373. webpage, 'game title')
  1374. urlRE = r"'movie_(?P<videoID>\d+)': \{\s*FILENAME: \"(?P<videoURL>[\w:/\.\?=]+)\"(,\s*MOVIE_NAME: \"(?P<videoName>[\w:/\.\?=\+-]+)\")?\s*\},"
  1375. mweb = re.finditer(urlRE, webpage)
  1376. namesRE = r'<span class="title">(?P<videoName>.+?)</span>'
  1377. titles = re.finditer(namesRE, webpage)
  1378. thumbsRE = r'<img class="movie_thumb" src="(?P<thumbnail>.+?)">'
  1379. thumbs = re.finditer(thumbsRE, webpage)
  1380. videos = []
  1381. for vid,vtitle,thumb in zip(mweb,titles,thumbs):
  1382. video_id = vid.group('videoID')
  1383. title = vtitle.group('videoName')
  1384. video_url = vid.group('videoURL')
  1385. video_thumb = thumb.group('thumbnail')
  1386. if not video_url:
  1387. raise ExtractorError(u'Cannot find video url for %s' % video_id)
  1388. info = {
  1389. 'id':video_id,
  1390. 'url':video_url,
  1391. 'ext': 'flv',
  1392. 'title': unescapeHTML(title),
  1393. 'thumbnail': video_thumb
  1394. }
  1395. videos.append(info)
  1396. return [self.playlist_result(videos, gameID, game_title)]
  1397. class UstreamIE(InfoExtractor):
  1398. _VALID_URL = r'https?://www\.ustream\.tv/recorded/(?P<videoID>\d+)'
  1399. IE_NAME = u'ustream'
  1400. def _real_extract(self, url):
  1401. m = re.match(self._VALID_URL, url)
  1402. video_id = m.group('videoID')
  1403. video_url = u'http://tcdn.ustream.tv/video/%s' % video_id
  1404. webpage = self._download_webpage(url, video_id)
  1405. self.report_extraction(video_id)
  1406. video_title = self._html_search_regex(r'data-title="(?P<title>.+)"',
  1407. webpage, u'title')
  1408. uploader = self._html_search_regex(r'data-content-type="channel".*?>(?P<uploader>.*?)</a>',
  1409. webpage, u'uploader', fatal=False, flags=re.DOTALL)
  1410. thumbnail = self._html_search_regex(r'<link rel="image_src" href="(?P<thumb>.*?)"',
  1411. webpage, u'thumbnail', fatal=False)
  1412. info = {
  1413. 'id': video_id,
  1414. 'url': video_url,
  1415. 'ext': 'flv',
  1416. 'title': video_title,
  1417. 'uploader': uploader,
  1418. 'thumbnail': thumbnail,
  1419. }
  1420. return info
  1421. class WorldStarHipHopIE(InfoExtractor):
  1422. _VALID_URL = r'https?://(?:www|m)\.worldstar(?:candy|hiphop)\.com/videos/video\.php\?v=(?P<id>.*)'
  1423. IE_NAME = u'WorldStarHipHop'
  1424. def _real_extract(self, url):
  1425. m = re.match(self._VALID_URL, url)
  1426. video_id = m.group('id')
  1427. webpage_src = self._download_webpage(url, video_id)
  1428. video_url = self._search_regex(r'so\.addVariable\("file","(.*?)"\)',
  1429. webpage_src, u'video URL')
  1430. if 'mp4' in video_url:
  1431. ext = 'mp4'
  1432. else:
  1433. ext = 'flv'
  1434. video_title = self._html_search_regex(r"<title>(.*)</title>",
  1435. webpage_src, u'title')
  1436. # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
  1437. thumbnail = self._html_search_regex(r'rel="image_src" href="(.*)" />',
  1438. webpage_src, u'thumbnail', fatal=False)
  1439. if not thumbnail:
  1440. _title = r"""candytitles.*>(.*)</span>"""
  1441. mobj = re.search(_title, webpage_src)
  1442. if mobj is not None:
  1443. video_title = mobj.group(1)
  1444. results = [{
  1445. 'id': video_id,
  1446. 'url' : video_url,
  1447. 'title' : video_title,
  1448. 'thumbnail' : thumbnail,
  1449. 'ext' : ext,
  1450. }]
  1451. return results
  1452. class RBMARadioIE(InfoExtractor):
  1453. _VALID_URL = r'https?://(?:www\.)?rbmaradio\.com/shows/(?P<videoID>[^/]+)$'
  1454. def _real_extract(self, url):
  1455. m = re.match(self._VALID_URL, url)
  1456. video_id = m.group('videoID')
  1457. webpage = self._download_webpage(url, video_id)
  1458. json_data = self._search_regex(r'window\.gon.*?gon\.show=(.+?);$',
  1459. webpage, u'json data', flags=re.MULTILINE)
  1460. try:
  1461. data = json.loads(json_data)
  1462. except ValueError as e:
  1463. raise ExtractorError(u'Invalid JSON: ' + str(e))
  1464. video_url = data['akamai_url'] + '&cbr=256'
  1465. url_parts = compat_urllib_parse_urlparse(video_url)
  1466. video_ext = url_parts.path.rpartition('.')[2]
  1467. info = {
  1468. 'id': video_id,
  1469. 'url': video_url,
  1470. 'ext': video_ext,
  1471. 'title': data['title'],
  1472. 'description': data.get('teaser_text'),
  1473. 'location': data.get('country_of_origin'),
  1474. 'uploader': data.get('host', {}).get('name'),
  1475. 'uploader_id': data.get('host', {}).get('slug'),
  1476. 'thumbnail': data.get('image', {}).get('large_url_2x'),
  1477. 'duration': data.get('duration'),
  1478. }
  1479. return [info]
  1480. class YouPornIE(InfoExtractor):
  1481. """Information extractor for youporn.com."""
  1482. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?youporn\.com/watch/(?P<videoid>[0-9]+)/(?P<title>[^/]+)'
  1483. def _print_formats(self, formats):
  1484. """Print all available formats"""
  1485. print(u'Available formats:')
  1486. print(u'ext\t\tformat')
  1487. print(u'---------------------------------')
  1488. for format in formats:
  1489. print(u'%s\t\t%s' % (format['ext'], format['format']))
  1490. def _specific(self, req_format, formats):
  1491. for x in formats:
  1492. if(x["format"]==req_format):
  1493. return x
  1494. return None
  1495. def _real_extract(self, url):
  1496. mobj = re.match(self._VALID_URL, url)
  1497. if mobj is None:
  1498. raise ExtractorError(u'Invalid URL: %s' % url)
  1499. video_id = mobj.group('videoid')
  1500. req = compat_urllib_request.Request(url)
  1501. req.add_header('Cookie', 'age_verified=1')
  1502. webpage = self._download_webpage(req, video_id)
  1503. # Get JSON parameters
  1504. json_params = self._search_regex(r'var currentVideo = new Video\((.*)\);', webpage, u'JSON parameters')
  1505. try:
  1506. params = json.loads(json_params)
  1507. except:
  1508. raise ExtractorError(u'Invalid JSON')
  1509. self.report_extraction(video_id)
  1510. try:
  1511. video_title = params['title']
  1512. upload_date = unified_strdate(params['release_date_f'])
  1513. video_description = params['description']
  1514. video_uploader = params['submitted_by']
  1515. thumbnail = params['thumbnails'][0]['image']
  1516. except KeyError:
  1517. raise ExtractorError('Missing JSON parameter: ' + sys.exc_info()[1])
  1518. # Get all of the formats available
  1519. DOWNLOAD_LIST_RE = r'(?s)<ul class="downloadList">(?P<download_list>.*?)</ul>'
  1520. download_list_html = self._search_regex(DOWNLOAD_LIST_RE,
  1521. webpage, u'download list').strip()
  1522. # Get all of the links from the page
  1523. LINK_RE = r'(?s)<a href="(?P<url>[^"]+)">'
  1524. links = re.findall(LINK_RE, download_list_html)
  1525. if(len(links) == 0):
  1526. raise ExtractorError(u'ERROR: no known formats available for video')
  1527. self.to_screen(u'Links found: %d' % len(links))
  1528. formats = []
  1529. for link in links:
  1530. # A link looks like this:
  1531. # http://cdn1.download.youporn.phncdn.com/201210/31/8004515/480p_370k_8004515/YouPorn%20-%20Nubile%20Films%20The%20Pillow%20Fight.mp4?nvb=20121113051249&nva=20121114051249&ir=1200&sr=1200&hash=014b882080310e95fb6a0
  1532. # A path looks like this:
  1533. # /201210/31/8004515/480p_370k_8004515/YouPorn%20-%20Nubile%20Films%20The%20Pillow%20Fight.mp4
  1534. video_url = unescapeHTML( link )
  1535. path = compat_urllib_parse_urlparse( video_url ).path
  1536. extension = os.path.splitext( path )[1][1:]
  1537. format = path.split('/')[4].split('_')[:2]
  1538. size = format[0]
  1539. bitrate = format[1]
  1540. format = "-".join( format )
  1541. # title = u'%s-%s-%s' % (video_title, size, bitrate)
  1542. formats.append({
  1543. 'id': video_id,
  1544. 'url': video_url,
  1545. 'uploader': video_uploader,
  1546. 'upload_date': upload_date,
  1547. 'title': video_title,
  1548. 'ext': extension,
  1549. 'format': format,
  1550. 'thumbnail': thumbnail,
  1551. 'description': video_description
  1552. })
  1553. if self._downloader.params.get('listformats', None):
  1554. self._print_formats(formats)
  1555. return
  1556. req_format = self._downloader.params.get('format', None)
  1557. self.to_screen(u'Format: %s' % req_format)
  1558. if req_format is None or req_format == 'best':
  1559. return [formats[0]]
  1560. elif req_format == 'worst':
  1561. return [formats[-1]]
  1562. elif req_format in ('-1', 'all'):
  1563. return formats
  1564. else:
  1565. format = self._specific( req_format, formats )
  1566. if result is None:
  1567. raise ExtractorError(u'Requested format not available')
  1568. return [format]
  1569. class PornotubeIE(InfoExtractor):
  1570. """Information extractor for pornotube.com."""
  1571. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?pornotube\.com(/c/(?P<channel>[0-9]+))?(/m/(?P<videoid>[0-9]+))(/(?P<title>.+))$'
  1572. def _real_extract(self, url):
  1573. mobj = re.match(self._VALID_URL, url)
  1574. if mobj is None:
  1575. raise ExtractorError(u'Invalid URL: %s' % url)
  1576. video_id = mobj.group('videoid')
  1577. video_title = mobj.group('title')
  1578. # Get webpage content
  1579. webpage = self._download_webpage(url, video_id)
  1580. # Get the video URL
  1581. VIDEO_URL_RE = r'url: "(?P<url>http://video[0-9].pornotube.com/.+\.flv)",'
  1582. video_url = self._search_regex(VIDEO_URL_RE, webpage, u'video url')
  1583. video_url = compat_urllib_parse.unquote(video_url)
  1584. #Get the uploaded date
  1585. VIDEO_UPLOADED_RE = r'<div class="video_added_by">Added (?P<date>[0-9\/]+) by'
  1586. upload_date = self._html_search_regex(VIDEO_UPLOADED_RE, webpage, u'upload date', fatal=False)
  1587. if upload_date: upload_date = unified_strdate(upload_date)
  1588. info = {'id': video_id,
  1589. 'url': video_url,
  1590. 'uploader': None,
  1591. 'upload_date': upload_date,
  1592. 'title': video_title,
  1593. 'ext': 'flv',
  1594. 'format': 'flv'}
  1595. return [info]
  1596. class YouJizzIE(InfoExtractor):
  1597. """Information extractor for youjizz.com."""
  1598. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?youjizz\.com/videos/(?P<videoid>[^.]+).html$'
  1599. def _real_extract(self, url):
  1600. mobj = re.match(self._VALID_URL, url)
  1601. if mobj is None:
  1602. raise ExtractorError(u'Invalid URL: %s' % url)
  1603. video_id = mobj.group('videoid')
  1604. # Get webpage content
  1605. webpage = self._download_webpage(url, video_id)
  1606. # Get the video title
  1607. video_title = self._html_search_regex(r'<title>(?P<title>.*)</title>',
  1608. webpage, u'title').strip()
  1609. # Get the embed page
  1610. result = re.search(r'https?://www.youjizz.com/videos/embed/(?P<videoid>[0-9]+)', webpage)
  1611. if result is None:
  1612. raise ExtractorError(u'ERROR: unable to extract embed page')
  1613. embed_page_url = result.group(0).strip()
  1614. video_id = result.group('videoid')
  1615. webpage = self._download_webpage(embed_page_url, video_id)
  1616. # Get the video URL
  1617. video_url = self._search_regex(r'so.addVariable\("file",encodeURIComponent\("(?P<source>[^"]+)"\)\);',
  1618. webpage, u'video URL')
  1619. info = {'id': video_id,
  1620. 'url': video_url,
  1621. 'title': video_title,
  1622. 'ext': 'flv',
  1623. 'format': 'flv',
  1624. 'player_url': embed_page_url}
  1625. return [info]
  1626. class EightTracksIE(InfoExtractor):
  1627. IE_NAME = '8tracks'
  1628. _VALID_URL = r'https?://8tracks.com/(?P<user>[^/]+)/(?P<id>[^/#]+)(?:#.*)?$'
  1629. def _real_extract(self, url):
  1630. mobj = re.match(self._VALID_URL, url)
  1631. if mobj is None:
  1632. raise ExtractorError(u'Invalid URL: %s' % url)
  1633. playlist_id = mobj.group('id')
  1634. webpage = self._download_webpage(url, playlist_id)
  1635. json_like = self._search_regex(r"PAGE.mix = (.*?);\n", webpage, u'trax information', flags=re.DOTALL)
  1636. data = json.loads(json_like)
  1637. session = str(random.randint(0, 1000000000))
  1638. mix_id = data['id']
  1639. track_count = data['tracks_count']
  1640. first_url = 'http://8tracks.com/sets/%s/play?player=sm&mix_id=%s&format=jsonh' % (session, mix_id)
  1641. next_url = first_url
  1642. res = []
  1643. for i in itertools.count():
  1644. api_json = self._download_webpage(next_url, playlist_id,
  1645. note=u'Downloading song information %s/%s' % (str(i+1), track_count),
  1646. errnote=u'Failed to download song information')
  1647. api_data = json.loads(api_json)
  1648. track_data = api_data[u'set']['track']
  1649. info = {
  1650. 'id': track_data['id'],
  1651. 'url': track_data['track_file_stream_url'],
  1652. 'title': track_data['performer'] + u' - ' + track_data['name'],
  1653. 'raw_title': track_data['name'],
  1654. 'uploader_id': data['user']['login'],
  1655. 'ext': 'm4a',
  1656. }
  1657. res.append(info)
  1658. if api_data['set']['at_last_track']:
  1659. break
  1660. next_url = 'http://8tracks.com/sets/%s/next?player=sm&mix_id=%s&format=jsonh&track_id=%s' % (session, mix_id, track_data['id'])
  1661. return res
  1662. class KeekIE(InfoExtractor):
  1663. _VALID_URL = r'http://(?:www\.)?keek\.com/(?:!|\w+/keeks/)(?P<videoID>\w+)'
  1664. IE_NAME = u'keek'
  1665. def _real_extract(self, url):
  1666. m = re.match(self._VALID_URL, url)
  1667. video_id = m.group('videoID')
  1668. video_url = u'http://cdn.keek.com/keek/video/%s' % video_id
  1669. thumbnail = u'http://cdn.keek.com/keek/thumbnail/%s/w100/h75' % video_id
  1670. webpage = self._download_webpage(url, video_id)
  1671. video_title = self._html_search_regex(r'<meta property="og:title" content="(?P<title>.*?)"',
  1672. webpage, u'title')
  1673. uploader = self._html_search_regex(r'<div class="user-name-and-bio">[\S\s]+?<h2>(?P<uploader>.+?)</h2>',
  1674. webpage, u'uploader', fatal=False)
  1675. info = {
  1676. 'id': video_id,
  1677. 'url': video_url,
  1678. 'ext': 'mp4',
  1679. 'title': video_title,
  1680. 'thumbnail': thumbnail,
  1681. 'uploader': uploader
  1682. }
  1683. return [info]
  1684. class TEDIE(InfoExtractor):
  1685. _VALID_URL=r'''http://www\.ted\.com/
  1686. (
  1687. ((?P<type_playlist>playlists)/(?P<playlist_id>\d+)) # We have a playlist
  1688. |
  1689. ((?P<type_talk>talks)) # We have a simple talk
  1690. )
  1691. (/lang/(.*?))? # The url may contain the language
  1692. /(?P<name>\w+) # Here goes the name and then ".html"
  1693. '''
  1694. @classmethod
  1695. def suitable(cls, url):
  1696. """Receives a URL and returns True if suitable for this IE."""
  1697. return re.match(cls._VALID_URL, url, re.VERBOSE) is not None
  1698. def _real_extract(self, url):
  1699. m=re.match(self._VALID_URL, url, re.VERBOSE)
  1700. if m.group('type_talk'):
  1701. return [self._talk_info(url)]
  1702. else :
  1703. playlist_id=m.group('playlist_id')
  1704. name=m.group('name')
  1705. self.to_screen(u'Getting info of playlist %s: "%s"' % (playlist_id,name))
  1706. return [self._playlist_videos_info(url,name,playlist_id)]
  1707. def _playlist_videos_info(self,url,name,playlist_id=0):
  1708. '''Returns the videos of the playlist'''
  1709. video_RE=r'''
  1710. <li\ id="talk_(\d+)"([.\s]*?)data-id="(?P<video_id>\d+)"
  1711. ([.\s]*?)data-playlist_item_id="(\d+)"
  1712. ([.\s]*?)data-mediaslug="(?P<mediaSlug>.+?)"
  1713. '''
  1714. video_name_RE=r'<p\ class="talk-title"><a href="(?P<talk_url>/talks/(.+).html)">(?P<fullname>.+?)</a></p>'
  1715. webpage=self._download_webpage(url, playlist_id, 'Downloading playlist webpage')
  1716. m_videos=re.finditer(video_RE,webpage,re.VERBOSE)
  1717. m_names=re.finditer(video_name_RE,webpage)
  1718. playlist_title = self._html_search_regex(r'div class="headline">\s*?<h1>\s*?<span>(.*?)</span>',
  1719. webpage, 'playlist title')
  1720. playlist_entries = []
  1721. for m_video, m_name in zip(m_videos,m_names):
  1722. video_id=m_video.group('video_id')
  1723. talk_url='http://www.ted.com%s' % m_name.group('talk_url')
  1724. playlist_entries.append(self.url_result(talk_url, 'TED'))
  1725. return self.playlist_result(playlist_entries, playlist_id = playlist_id, playlist_title = playlist_title)
  1726. def _talk_info(self, url, video_id=0):
  1727. """Return the video for the talk in the url"""
  1728. m = re.match(self._VALID_URL, url,re.VERBOSE)
  1729. video_name = m.group('name')
  1730. webpage = self._download_webpage(url, video_id, 'Downloading \"%s\" page' % video_name)
  1731. self.report_extraction(video_name)
  1732. # If the url includes the language we get the title translated
  1733. title = self._html_search_regex(r'<span id="altHeadline" >(?P<title>.*)</span>',
  1734. webpage, 'title')
  1735. json_data = self._search_regex(r'<script.*?>var talkDetails = ({.*?})</script>',
  1736. webpage, 'json data')
  1737. info = json.loads(json_data)
  1738. desc = self._html_search_regex(r'<div class="talk-intro">.*?<p.*?>(.*?)</p>',
  1739. webpage, 'description', flags = re.DOTALL)
  1740. thumbnail = self._search_regex(r'</span>[\s.]*</div>[\s.]*<img src="(.*?)"',
  1741. webpage, 'thumbnail')
  1742. info = {
  1743. 'id': info['id'],
  1744. 'url': info['htmlStreams'][-1]['file'],
  1745. 'ext': 'mp4',
  1746. 'title': title,
  1747. 'thumbnail': thumbnail,
  1748. 'description': desc,
  1749. }
  1750. return info
  1751. class MySpassIE(InfoExtractor):
  1752. _VALID_URL = r'http://www.myspass.de/.*'
  1753. def _real_extract(self, url):
  1754. META_DATA_URL_TEMPLATE = 'http://www.myspass.de/myspass/includes/apps/video/getvideometadataxml.php?id=%s'
  1755. # video id is the last path element of the URL
  1756. # usually there is a trailing slash, so also try the second but last
  1757. url_path = compat_urllib_parse_urlparse(url).path
  1758. url_parent_path, video_id = os.path.split(url_path)
  1759. if not video_id:
  1760. _, video_id = os.path.split(url_parent_path)
  1761. # get metadata
  1762. metadata_url = META_DATA_URL_TEMPLATE % video_id
  1763. metadata_text = self._download_webpage(metadata_url, video_id)
  1764. metadata = xml.etree.ElementTree.fromstring(metadata_text.encode('utf-8'))
  1765. # extract values from metadata
  1766. url_flv_el = metadata.find('url_flv')
  1767. if url_flv_el is None:
  1768. raise ExtractorError(u'Unable to extract download url')
  1769. video_url = url_flv_el.text
  1770. extension = os.path.splitext(video_url)[1][1:]
  1771. title_el = metadata.find('title')
  1772. if title_el is None:
  1773. raise ExtractorError(u'Unable to extract title')
  1774. title = title_el.text
  1775. format_id_el = metadata.find('format_id')
  1776. if format_id_el is None:
  1777. format = ext
  1778. else:
  1779. format = format_id_el.text
  1780. description_el = metadata.find('description')
  1781. if description_el is not None:
  1782. description = description_el.text
  1783. else:
  1784. description = None
  1785. imagePreview_el = metadata.find('imagePreview')
  1786. if imagePreview_el is not None:
  1787. thumbnail = imagePreview_el.text
  1788. else:
  1789. thumbnail = None
  1790. info = {
  1791. 'id': video_id,
  1792. 'url': video_url,
  1793. 'title': title,
  1794. 'ext': extension,
  1795. 'format': format,
  1796. 'thumbnail': thumbnail,
  1797. 'description': description
  1798. }
  1799. return [info]
  1800. class SpiegelIE(InfoExtractor):
  1801. _VALID_URL = r'https?://(?:www\.)?spiegel\.de/video/[^/]*-(?P<videoID>[0-9]+)(?:\.html)?(?:#.*)?$'
  1802. def _real_extract(self, url):
  1803. m = re.match(self._VALID_URL, url)
  1804. video_id = m.group('videoID')
  1805. webpage = self._download_webpage(url, video_id)
  1806. video_title = self._html_search_regex(r'<div class="module-title">(.*?)</div>',
  1807. webpage, u'title')
  1808. xml_url = u'http://video2.spiegel.de/flash/' + video_id + u'.xml'
  1809. xml_code = self._download_webpage(xml_url, video_id,
  1810. note=u'Downloading XML', errnote=u'Failed to download XML')
  1811. idoc = xml.etree.ElementTree.fromstring(xml_code)
  1812. last_type = idoc[-1]
  1813. filename = last_type.findall('./filename')[0].text
  1814. duration = float(last_type.findall('./duration')[0].text)
  1815. video_url = 'http://video2.spiegel.de/flash/' + filename
  1816. video_ext = filename.rpartition('.')[2]
  1817. info = {
  1818. 'id': video_id,
  1819. 'url': video_url,
  1820. 'ext': video_ext,
  1821. 'title': video_title,
  1822. 'duration': duration,
  1823. }
  1824. return [info]
  1825. class LiveLeakIE(InfoExtractor):
  1826. _VALID_URL = r'^(?:http?://)?(?:\w+\.)?liveleak\.com/view\?(?:.*?)i=(?P<video_id>[\w_]+)(?:.*)'
  1827. IE_NAME = u'liveleak'
  1828. def _real_extract(self, url):
  1829. mobj = re.match(self._VALID_URL, url)
  1830. if mobj is None:
  1831. raise ExtractorError(u'Invalid URL: %s' % url)
  1832. video_id = mobj.group('video_id')
  1833. webpage = self._download_webpage(url, video_id)
  1834. video_url = self._search_regex(r'file: "(.*?)",',
  1835. webpage, u'video URL')
  1836. video_title = self._html_search_regex(r'<meta property="og:title" content="(?P<title>.*?)"',
  1837. webpage, u'title').replace('LiveLeak.com -', '').strip()
  1838. video_description = self._html_search_regex(r'<meta property="og:description" content="(?P<desc>.*?)"',
  1839. webpage, u'description', fatal=False)
  1840. video_uploader = self._html_search_regex(r'By:.*?(\w+)</a>',
  1841. webpage, u'uploader', fatal=False)
  1842. info = {
  1843. 'id': video_id,
  1844. 'url': video_url,
  1845. 'ext': 'mp4',
  1846. 'title': video_title,
  1847. 'description': video_description,
  1848. 'uploader': video_uploader
  1849. }
  1850. return [info]
  1851. class TumblrIE(InfoExtractor):
  1852. _VALID_URL = r'http://(?P<blog_name>.*?)\.tumblr\.com/((post)|(video))/(?P<id>\d*)/(.*?)'
  1853. def _real_extract(self, url):
  1854. m_url = re.match(self._VALID_URL, url)
  1855. video_id = m_url.group('id')
  1856. blog = m_url.group('blog_name')
  1857. url = 'http://%s.tumblr.com/post/%s/' % (blog, video_id)
  1858. webpage = self._download_webpage(url, video_id)
  1859. re_video = r'src=\\x22(?P<video_url>http://%s\.tumblr\.com/video_file/%s/(.*?))\\x22 type=\\x22video/(?P<ext>.*?)\\x22' % (blog, video_id)
  1860. video = re.search(re_video, webpage)
  1861. if video is None:
  1862. raise ExtractorError(u'Unable to extract video')
  1863. video_url = video.group('video_url')
  1864. ext = video.group('ext')
  1865. video_thumbnail = self._search_regex(r'posters(.*?)\[\\x22(?P<thumb>.*?)\\x22',
  1866. webpage, u'thumbnail', fatal=False) # We pick the first poster
  1867. if video_thumbnail: video_thumbnail = video_thumbnail.replace('\\', '')
  1868. # The only place where you can get a title, it's not complete,
  1869. # but searching in other places doesn't work for all videos
  1870. video_title = self._html_search_regex(r'<title>(?P<title>.*?)</title>',
  1871. webpage, u'title', flags=re.DOTALL)
  1872. return [{'id': video_id,
  1873. 'url': video_url,
  1874. 'title': video_title,
  1875. 'thumbnail': video_thumbnail,
  1876. 'ext': ext
  1877. }]
  1878. class BandcampIE(InfoExtractor):
  1879. _VALID_URL = r'http://.*?\.bandcamp\.com/track/(?P<title>.*)'
  1880. def _real_extract(self, url):
  1881. mobj = re.match(self._VALID_URL, url)
  1882. title = mobj.group('title')
  1883. webpage = self._download_webpage(url, title)
  1884. # We get the link to the free download page
  1885. m_download = re.search(r'freeDownloadPage: "(.*?)"', webpage)
  1886. if m_download is None:
  1887. raise ExtractorError(u'No free songs found')
  1888. download_link = m_download.group(1)
  1889. id = re.search(r'var TralbumData = {(.*?)id: (?P<id>\d*?)$',
  1890. webpage, re.MULTILINE|re.DOTALL).group('id')
  1891. download_webpage = self._download_webpage(download_link, id,
  1892. 'Downloading free downloads page')
  1893. # We get the dictionary of the track from some javascrip code
  1894. info = re.search(r'items: (.*?),$',
  1895. download_webpage, re.MULTILINE).group(1)
  1896. info = json.loads(info)[0]
  1897. # We pick mp3-320 for now, until format selection can be easily implemented.
  1898. mp3_info = info[u'downloads'][u'mp3-320']
  1899. # If we try to use this url it says the link has expired
  1900. initial_url = mp3_info[u'url']
  1901. re_url = r'(?P<server>http://(.*?)\.bandcamp\.com)/download/track\?enc=mp3-320&fsig=(?P<fsig>.*?)&id=(?P<id>.*?)&ts=(?P<ts>.*)$'
  1902. m_url = re.match(re_url, initial_url)
  1903. #We build the url we will use to get the final track url
  1904. # This url is build in Bandcamp in the script download_bunde_*.js
  1905. request_url = '%s/statdownload/track?enc=mp3-320&fsig=%s&id=%s&ts=%s&.rand=665028774616&.vrs=1' % (m_url.group('server'), m_url.group('fsig'), id, m_url.group('ts'))
  1906. final_url_webpage = self._download_webpage(request_url, id, 'Requesting download url')
  1907. # If we could correctly generate the .rand field the url would be
  1908. #in the "download_url" key
  1909. final_url = re.search(r'"retry_url":"(.*?)"', final_url_webpage).group(1)
  1910. track_info = {'id':id,
  1911. 'title' : info[u'title'],
  1912. 'ext' : 'mp3',
  1913. 'url' : final_url,
  1914. 'thumbnail' : info[u'thumb_url'],
  1915. 'uploader' : info[u'artist']
  1916. }
  1917. return [track_info]
  1918. class RedTubeIE(InfoExtractor):
  1919. """Information Extractor for redtube"""
  1920. _VALID_URL = r'(?:http://)?(?:www\.)?redtube\.com/(?P<id>[0-9]+)'
  1921. def _real_extract(self,url):
  1922. mobj = re.match(self._VALID_URL, url)
  1923. if mobj is None:
  1924. raise ExtractorError(u'Invalid URL: %s' % url)
  1925. video_id = mobj.group('id')
  1926. video_extension = 'mp4'
  1927. webpage = self._download_webpage(url, video_id)
  1928. self.report_extraction(video_id)
  1929. video_url = self._html_search_regex(r'<source src="(.+?)" type="video/mp4">',
  1930. webpage, u'video URL')
  1931. video_title = self._html_search_regex('<h1 class="videoTitle slidePanelMovable">(.+?)</h1>',
  1932. webpage, u'title')
  1933. return [{
  1934. 'id': video_id,
  1935. 'url': video_url,
  1936. 'ext': video_extension,
  1937. 'title': video_title,
  1938. }]
  1939. class InaIE(InfoExtractor):
  1940. """Information Extractor for Ina.fr"""
  1941. _VALID_URL = r'(?:http://)?(?:www\.)?ina\.fr/video/(?P<id>I[0-9]+)/.*'
  1942. def _real_extract(self,url):
  1943. mobj = re.match(self._VALID_URL, url)
  1944. video_id = mobj.group('id')
  1945. mrss_url='http://player.ina.fr/notices/%s.mrss' % video_id
  1946. video_extension = 'mp4'
  1947. webpage = self._download_webpage(mrss_url, video_id)
  1948. self.report_extraction(video_id)
  1949. video_url = self._html_search_regex(r'<media:player url="(?P<mp4url>http://mp4.ina.fr/[^"]+\.mp4)',
  1950. webpage, u'video URL')
  1951. video_title = self._search_regex(r'<title><!\[CDATA\[(?P<titre>.*?)]]></title>',
  1952. webpage, u'title')
  1953. return [{
  1954. 'id': video_id,
  1955. 'url': video_url,
  1956. 'ext': video_extension,
  1957. 'title': video_title,
  1958. }]
  1959. class HowcastIE(InfoExtractor):
  1960. """Information Extractor for Howcast.com"""
  1961. _VALID_URL = r'(?:https?://)?(?:www\.)?howcast\.com/videos/(?P<id>\d+)'
  1962. def _real_extract(self, url):
  1963. mobj = re.match(self._VALID_URL, url)
  1964. video_id = mobj.group('id')
  1965. webpage_url = 'http://www.howcast.com/videos/' + video_id
  1966. webpage = self._download_webpage(webpage_url, video_id)
  1967. self.report_extraction(video_id)
  1968. video_url = self._search_regex(r'\'?file\'?: "(http://mobile-media\.howcast\.com/[0-9]+\.mp4)',
  1969. webpage, u'video URL')
  1970. video_title = self._html_search_regex(r'<meta content=(?:"([^"]+)"|\'([^\']+)\') property=\'og:title\'',
  1971. webpage, u'title')
  1972. video_description = self._html_search_regex(r'<meta content=(?:"([^"]+)"|\'([^\']+)\') name=\'description\'',
  1973. webpage, u'description', fatal=False)
  1974. thumbnail = self._html_search_regex(r'<meta content=\'(.+?)\' property=\'og:image\'',
  1975. webpage, u'thumbnail', fatal=False)
  1976. return [{
  1977. 'id': video_id,
  1978. 'url': video_url,
  1979. 'ext': 'mp4',
  1980. 'title': video_title,
  1981. 'description': video_description,
  1982. 'thumbnail': thumbnail,
  1983. }]
  1984. class VineIE(InfoExtractor):
  1985. """Information Extractor for Vine.co"""
  1986. _VALID_URL = r'(?:https?://)?(?:www\.)?vine\.co/v/(?P<id>\w+)'
  1987. def _real_extract(self, url):
  1988. mobj = re.match(self._VALID_URL, url)
  1989. video_id = mobj.group('id')
  1990. webpage_url = 'https://vine.co/v/' + video_id
  1991. webpage = self._download_webpage(webpage_url, video_id)
  1992. self.report_extraction(video_id)
  1993. video_url = self._html_search_regex(r'<meta property="twitter:player:stream" content="(.+?)"',
  1994. webpage, u'video URL')
  1995. video_title = self._html_search_regex(r'<meta property="og:title" content="(.+?)"',
  1996. webpage, u'title')
  1997. thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.+?)(\?.*?)?"',
  1998. webpage, u'thumbnail', fatal=False)
  1999. uploader = self._html_search_regex(r'<div class="user">.*?<h2>(.+?)</h2>',
  2000. webpage, u'uploader', fatal=False, flags=re.DOTALL)
  2001. return [{
  2002. 'id': video_id,
  2003. 'url': video_url,
  2004. 'ext': 'mp4',
  2005. 'title': video_title,
  2006. 'thumbnail': thumbnail,
  2007. 'uploader': uploader,
  2008. }]
  2009. class FlickrIE(InfoExtractor):
  2010. """Information Extractor for Flickr videos"""
  2011. _VALID_URL = r'(?:https?://)?(?:www\.)?flickr\.com/photos/(?P<uploader_id>[\w\-_@]+)/(?P<id>\d+).*'
  2012. def _real_extract(self, url):
  2013. mobj = re.match(self._VALID_URL, url)
  2014. video_id = mobj.group('id')
  2015. video_uploader_id = mobj.group('uploader_id')
  2016. webpage_url = 'http://www.flickr.com/photos/' + video_uploader_id + '/' + video_id
  2017. webpage = self._download_webpage(webpage_url, video_id)
  2018. secret = self._search_regex(r"photo_secret: '(\w+)'", webpage, u'secret')
  2019. first_url = 'https://secure.flickr.com/apps/video/video_mtl_xml.gne?v=x&photo_id=' + video_id + '&secret=' + secret + '&bitrate=700&target=_self'
  2020. first_xml = self._download_webpage(first_url, video_id, 'Downloading first data webpage')
  2021. node_id = self._html_search_regex(r'<Item id="id">(\d+-\d+)</Item>',
  2022. first_xml, u'node_id')
  2023. second_url = 'https://secure.flickr.com/video_playlist.gne?node_id=' + node_id + '&tech=flash&mode=playlist&bitrate=700&secret=' + secret + '&rd=video.yahoo.com&noad=1'
  2024. second_xml = self._download_webpage(second_url, video_id, 'Downloading second data webpage')
  2025. self.report_extraction(video_id)
  2026. mobj = re.search(r'<STREAM APP="(.+?)" FULLPATH="(.+?)"', second_xml)
  2027. if mobj is None:
  2028. raise ExtractorError(u'Unable to extract video url')
  2029. video_url = mobj.group(1) + unescapeHTML(mobj.group(2))
  2030. video_title = self._html_search_regex(r'<meta property="og:title" content=(?:"([^"]+)"|\'([^\']+)\')',
  2031. webpage, u'video title')
  2032. video_description = self._html_search_regex(r'<meta property="og:description" content=(?:"([^"]+)"|\'([^\']+)\')',
  2033. webpage, u'description', fatal=False)
  2034. thumbnail = self._html_search_regex(r'<meta property="og:image" content=(?:"([^"]+)"|\'([^\']+)\')',
  2035. webpage, u'thumbnail', fatal=False)
  2036. return [{
  2037. 'id': video_id,
  2038. 'url': video_url,
  2039. 'ext': 'mp4',
  2040. 'title': video_title,
  2041. 'description': video_description,
  2042. 'thumbnail': thumbnail,
  2043. 'uploader_id': video_uploader_id,
  2044. }]
  2045. class TeamcocoIE(InfoExtractor):
  2046. _VALID_URL = r'http://teamcoco\.com/video/(?P<url_title>.*)'
  2047. def _real_extract(self, url):
  2048. mobj = re.match(self._VALID_URL, url)
  2049. if mobj is None:
  2050. raise ExtractorError(u'Invalid URL: %s' % url)
  2051. url_title = mobj.group('url_title')
  2052. webpage = self._download_webpage(url, url_title)
  2053. video_id = self._html_search_regex(r'<article class="video" data-id="(\d+?)"',
  2054. webpage, u'video id')
  2055. self.report_extraction(video_id)
  2056. video_title = self._html_search_regex(r'<meta property="og:title" content="(.+?)"',
  2057. webpage, u'title')
  2058. thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.+?)"',
  2059. webpage, u'thumbnail', fatal=False)
  2060. video_description = self._html_search_regex(r'<meta property="og:description" content="(.*?)"',
  2061. webpage, u'description', fatal=False)
  2062. data_url = 'http://teamcoco.com/cvp/2.0/%s.xml' % video_id
  2063. data = self._download_webpage(data_url, video_id, 'Downloading data webpage')
  2064. video_url = self._html_search_regex(r'<file type="high".*?>(.*?)</file>',
  2065. data, u'video URL')
  2066. return [{
  2067. 'id': video_id,
  2068. 'url': video_url,
  2069. 'ext': 'mp4',
  2070. 'title': video_title,
  2071. 'thumbnail': thumbnail,
  2072. 'description': video_description,
  2073. }]
  2074. class XHamsterIE(InfoExtractor):
  2075. """Information Extractor for xHamster"""
  2076. _VALID_URL = r'(?:http://)?(?:www.)?xhamster\.com/movies/(?P<id>[0-9]+)/.*\.html'
  2077. def _real_extract(self,url):
  2078. mobj = re.match(self._VALID_URL, url)
  2079. video_id = mobj.group('id')
  2080. mrss_url = 'http://xhamster.com/movies/%s/.html' % video_id
  2081. webpage = self._download_webpage(mrss_url, video_id)
  2082. mobj = re.search(r'\'srv\': \'(?P<server>[^\']*)\',\s*\'file\': \'(?P<file>[^\']+)\',', webpage)
  2083. if mobj is None:
  2084. raise ExtractorError(u'Unable to extract media URL')
  2085. if len(mobj.group('server')) == 0:
  2086. video_url = compat_urllib_parse.unquote(mobj.group('file'))
  2087. else:
  2088. video_url = mobj.group('server')+'/key='+mobj.group('file')
  2089. video_extension = video_url.split('.')[-1]
  2090. video_title = self._html_search_regex(r'<title>(?P<title>.+?) - xHamster\.com</title>',
  2091. webpage, u'title')
  2092. # Can't see the description anywhere in the UI
  2093. # video_description = self._html_search_regex(r'<span>Description: </span>(?P<description>[^<]+)',
  2094. # webpage, u'description', fatal=False)
  2095. # if video_description: video_description = unescapeHTML(video_description)
  2096. mobj = re.search(r'hint=\'(?P<upload_date_Y>[0-9]{4})-(?P<upload_date_m>[0-9]{2})-(?P<upload_date_d>[0-9]{2}) [0-9]{2}:[0-9]{2}:[0-9]{2} [A-Z]{3,4}\'', webpage)
  2097. if mobj:
  2098. video_upload_date = mobj.group('upload_date_Y')+mobj.group('upload_date_m')+mobj.group('upload_date_d')
  2099. else:
  2100. video_upload_date = None
  2101. self._downloader.report_warning(u'Unable to extract upload date')
  2102. video_uploader_id = self._html_search_regex(r'<a href=\'/user/[^>]+>(?P<uploader_id>[^<]+)',
  2103. webpage, u'uploader id', default=u'anonymous')
  2104. video_thumbnail = self._search_regex(r'\'image\':\'(?P<thumbnail>[^\']+)\'',
  2105. webpage, u'thumbnail', fatal=False)
  2106. return [{
  2107. 'id': video_id,
  2108. 'url': video_url,
  2109. 'ext': video_extension,
  2110. 'title': video_title,
  2111. # 'description': video_description,
  2112. 'upload_date': video_upload_date,
  2113. 'uploader_id': video_uploader_id,
  2114. 'thumbnail': video_thumbnail
  2115. }]
  2116. class HypemIE(InfoExtractor):
  2117. """Information Extractor for hypem"""
  2118. _VALID_URL = r'(?:http://)?(?:www\.)?hypem\.com/track/([^/]+)/([^/]+)'
  2119. def _real_extract(self, url):
  2120. mobj = re.match(self._VALID_URL, url)
  2121. if mobj is None:
  2122. raise ExtractorError(u'Invalid URL: %s' % url)
  2123. track_id = mobj.group(1)
  2124. data = { 'ax': 1, 'ts': time.time() }
  2125. data_encoded = compat_urllib_parse.urlencode(data)
  2126. complete_url = url + "?" + data_encoded
  2127. request = compat_urllib_request.Request(complete_url)
  2128. response, urlh = self._download_webpage_handle(request, track_id, u'Downloading webpage with the url')
  2129. cookie = urlh.headers.get('Set-Cookie', '')
  2130. self.report_extraction(track_id)
  2131. html_tracks = self._html_search_regex(r'<script type="application/json" id="displayList-data">(.*?)</script>',
  2132. response, u'tracks', flags=re.MULTILINE|re.DOTALL).strip()
  2133. try:
  2134. track_list = json.loads(html_tracks)
  2135. track = track_list[u'tracks'][0]
  2136. except ValueError:
  2137. raise ExtractorError(u'Hypemachine contained invalid JSON.')
  2138. key = track[u"key"]
  2139. track_id = track[u"id"]
  2140. artist = track[u"artist"]
  2141. title = track[u"song"]
  2142. serve_url = "http://hypem.com/serve/source/%s/%s" % (compat_str(track_id), compat_str(key))
  2143. request = compat_urllib_request.Request(serve_url, "" , {'Content-Type': 'application/json'})
  2144. request.add_header('cookie', cookie)
  2145. song_data_json = self._download_webpage(request, track_id, u'Downloading metadata')
  2146. try:
  2147. song_data = json.loads(song_data_json)
  2148. except ValueError:
  2149. raise ExtractorError(u'Hypemachine contained invalid JSON.')
  2150. final_url = song_data[u"url"]
  2151. return [{
  2152. 'id': track_id,
  2153. 'url': final_url,
  2154. 'ext': "mp3",
  2155. 'title': title,
  2156. 'artist': artist,
  2157. }]
  2158. class Vbox7IE(InfoExtractor):
  2159. """Information Extractor for Vbox7"""
  2160. _VALID_URL = r'(?:http://)?(?:www\.)?vbox7\.com/play:([^/]+)'
  2161. def _real_extract(self,url):
  2162. mobj = re.match(self._VALID_URL, url)
  2163. if mobj is None:
  2164. raise ExtractorError(u'Invalid URL: %s' % url)
  2165. video_id = mobj.group(1)
  2166. redirect_page, urlh = self._download_webpage_handle(url, video_id)
  2167. new_location = self._search_regex(r'window\.location = \'(.*)\';', redirect_page, u'redirect location')
  2168. redirect_url = urlh.geturl() + new_location
  2169. webpage = self._download_webpage(redirect_url, video_id, u'Downloading redirect page')
  2170. title = self._html_search_regex(r'<title>(.*)</title>',
  2171. webpage, u'title').split('/')[0].strip()
  2172. ext = "flv"
  2173. info_url = "http://vbox7.com/play/magare.do"
  2174. data = compat_urllib_parse.urlencode({'as3':'1','vid':video_id})
  2175. info_request = compat_urllib_request.Request(info_url, data)
  2176. info_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
  2177. info_response = self._download_webpage(info_request, video_id, u'Downloading info webpage')
  2178. if info_response is None:
  2179. raise ExtractorError(u'Unable to extract the media url')
  2180. (final_url, thumbnail_url) = map(lambda x: x.split('=')[1], info_response.split('&'))
  2181. return [{
  2182. 'id': video_id,
  2183. 'url': final_url,
  2184. 'ext': ext,
  2185. 'title': title,
  2186. 'thumbnail': thumbnail_url,
  2187. }]
  2188. def gen_extractors():
  2189. """ Return a list of an instance of every supported extractor.
  2190. The order does matter; the first extractor matched is the one handling the URL.
  2191. """
  2192. return [
  2193. YoutubePlaylistIE(),
  2194. YoutubeChannelIE(),
  2195. YoutubeUserIE(),
  2196. YoutubeSearchIE(),
  2197. YoutubeIE(),
  2198. MetacafeIE(),
  2199. DailymotionIE(),
  2200. GoogleSearchIE(),
  2201. PhotobucketIE(),
  2202. YahooIE(),
  2203. YahooSearchIE(),
  2204. DepositFilesIE(),
  2205. FacebookIE(),
  2206. BlipTVIE(),
  2207. BlipTVUserIE(),
  2208. VimeoIE(),
  2209. MyVideoIE(),
  2210. ComedyCentralIE(),
  2211. EscapistIE(),
  2212. CollegeHumorIE(),
  2213. XVideosIE(),
  2214. SoundcloudSetIE(),
  2215. SoundcloudIE(),
  2216. InfoQIE(),
  2217. MixcloudIE(),
  2218. StanfordOpenClassroomIE(),
  2219. MTVIE(),
  2220. YoukuIE(),
  2221. XNXXIE(),
  2222. YouJizzIE(),
  2223. PornotubeIE(),
  2224. YouPornIE(),
  2225. GooglePlusIE(),
  2226. ArteTvIE(),
  2227. NBAIE(),
  2228. WorldStarHipHopIE(),
  2229. JustinTVIE(),
  2230. FunnyOrDieIE(),
  2231. SteamIE(),
  2232. UstreamIE(),
  2233. RBMARadioIE(),
  2234. EightTracksIE(),
  2235. KeekIE(),
  2236. TEDIE(),
  2237. MySpassIE(),
  2238. SpiegelIE(),
  2239. LiveLeakIE(),
  2240. ARDIE(),
  2241. ZDFIE(),
  2242. TumblrIE(),
  2243. BandcampIE(),
  2244. RedTubeIE(),
  2245. InaIE(),
  2246. HowcastIE(),
  2247. VineIE(),
  2248. FlickrIE(),
  2249. TeamcocoIE(),
  2250. XHamsterIE(),
  2251. HypemIE(),
  2252. Vbox7IE(),
  2253. GametrailersIE(),
  2254. StatigramIE(),
  2255. GenericIE()
  2256. ]
  2257. def get_info_extractor(ie_name):
  2258. """Returns the info extractor class with the given ie_name"""
  2259. return globals()[ie_name+'IE']