InfoExtractors.py 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243
  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.bliptv import BlipTVIE, BlipTVUserIE
  22. from .extractor.comedycentral import ComedyCentralIE
  23. from .extractor.dailymotion import DailymotionIE
  24. from .extractor.gametrailers import GametrailersIE
  25. from .extractor.generic import GenericIE
  26. from .extractor.googleplus import GooglePlusIE
  27. from .extractor.googlesearch import GoogleSearchIE
  28. from .extractor.metacafe import MetacafeIE
  29. from .extractor.myvideo import MyVideoIE
  30. from .extractor.statigram import StatigramIE
  31. from .extractor.photobucket import PhotobucketIE
  32. from .extractor.vimeo import VimeoIE
  33. from .extractor.yahoo import YahooIE, YahooSearchIE
  34. from .extractor.youtube import YoutubeIE, YoutubePlaylistIE, YoutubeSearchIE, YoutubeUserIE, YoutubeChannelIE
  35. from .extractor.zdf import ZDFIE
  36. class DepositFilesIE(InfoExtractor):
  37. """Information extractor for depositfiles.com"""
  38. _VALID_URL = r'(?:http://)?(?:\w+\.)?depositfiles\.com/(?:../(?#locale))?files/(.+)'
  39. def _real_extract(self, url):
  40. file_id = url.split('/')[-1]
  41. # Rebuild url in english locale
  42. url = 'http://depositfiles.com/en/files/' + file_id
  43. # Retrieve file webpage with 'Free download' button pressed
  44. free_download_indication = { 'gateway_result' : '1' }
  45. request = compat_urllib_request.Request(url, compat_urllib_parse.urlencode(free_download_indication))
  46. try:
  47. self.report_download_webpage(file_id)
  48. webpage = compat_urllib_request.urlopen(request).read()
  49. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  50. raise ExtractorError(u'Unable to retrieve file webpage: %s' % compat_str(err))
  51. # Search for the real file URL
  52. mobj = re.search(r'<form action="(http://fileshare.+?)"', webpage)
  53. if (mobj is None) or (mobj.group(1) is None):
  54. # Try to figure out reason of the error.
  55. mobj = re.search(r'<strong>(Attention.*?)</strong>', webpage, re.DOTALL)
  56. if (mobj is not None) and (mobj.group(1) is not None):
  57. restriction_message = re.sub('\s+', ' ', mobj.group(1)).strip()
  58. raise ExtractorError(u'%s' % restriction_message)
  59. else:
  60. raise ExtractorError(u'Unable to extract download URL from: %s' % url)
  61. file_url = mobj.group(1)
  62. file_extension = os.path.splitext(file_url)[1][1:]
  63. # Search for file title
  64. file_title = self._search_regex(r'<b title="(.*?)">', webpage, u'title')
  65. return [{
  66. 'id': file_id.decode('utf-8'),
  67. 'url': file_url.decode('utf-8'),
  68. 'uploader': None,
  69. 'upload_date': None,
  70. 'title': file_title,
  71. 'ext': file_extension.decode('utf-8'),
  72. }]
  73. class FacebookIE(InfoExtractor):
  74. """Information Extractor for Facebook"""
  75. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?facebook\.com/(?:video/video|photo)\.php\?(?:.*?)v=(?P<ID>\d+)(?:.*)'
  76. _LOGIN_URL = 'https://login.facebook.com/login.php?m&next=http%3A%2F%2Fm.facebook.com%2Fhome.php&'
  77. _NETRC_MACHINE = 'facebook'
  78. IE_NAME = u'facebook'
  79. def report_login(self):
  80. """Report attempt to log in."""
  81. self.to_screen(u'Logging in')
  82. def _real_initialize(self):
  83. if self._downloader is None:
  84. return
  85. useremail = None
  86. password = None
  87. downloader_params = self._downloader.params
  88. # Attempt to use provided username and password or .netrc data
  89. if downloader_params.get('username', None) is not None:
  90. useremail = downloader_params['username']
  91. password = downloader_params['password']
  92. elif downloader_params.get('usenetrc', False):
  93. try:
  94. info = netrc.netrc().authenticators(self._NETRC_MACHINE)
  95. if info is not None:
  96. useremail = info[0]
  97. password = info[2]
  98. else:
  99. raise netrc.NetrcParseError('No authenticators for %s' % self._NETRC_MACHINE)
  100. except (IOError, netrc.NetrcParseError) as err:
  101. self._downloader.report_warning(u'parsing .netrc: %s' % compat_str(err))
  102. return
  103. if useremail is None:
  104. return
  105. # Log in
  106. login_form = {
  107. 'email': useremail,
  108. 'pass': password,
  109. 'login': 'Log+In'
  110. }
  111. request = compat_urllib_request.Request(self._LOGIN_URL, compat_urllib_parse.urlencode(login_form))
  112. try:
  113. self.report_login()
  114. login_results = compat_urllib_request.urlopen(request).read()
  115. if re.search(r'<form(.*)name="login"(.*)</form>', login_results) is not None:
  116. self._downloader.report_warning(u'unable to log in: bad username/password, or exceded login rate limit (~3/min). Check credentials or wait.')
  117. return
  118. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  119. self._downloader.report_warning(u'unable to log in: %s' % compat_str(err))
  120. return
  121. def _real_extract(self, url):
  122. mobj = re.match(self._VALID_URL, url)
  123. if mobj is None:
  124. raise ExtractorError(u'Invalid URL: %s' % url)
  125. video_id = mobj.group('ID')
  126. url = 'https://www.facebook.com/video/video.php?v=%s' % video_id
  127. webpage = self._download_webpage(url, video_id)
  128. BEFORE = '{swf.addParam(param[0], param[1]);});\n'
  129. AFTER = '.forEach(function(variable) {swf.addVariable(variable[0], variable[1]);});'
  130. m = re.search(re.escape(BEFORE) + '(.*?)' + re.escape(AFTER), webpage)
  131. if not m:
  132. raise ExtractorError(u'Cannot parse data')
  133. data = dict(json.loads(m.group(1)))
  134. params_raw = compat_urllib_parse.unquote(data['params'])
  135. params = json.loads(params_raw)
  136. video_data = params['video_data'][0]
  137. video_url = video_data.get('hd_src')
  138. if not video_url:
  139. video_url = video_data['sd_src']
  140. if not video_url:
  141. raise ExtractorError(u'Cannot find video URL')
  142. video_duration = int(video_data['video_duration'])
  143. thumbnail = video_data['thumbnail_src']
  144. video_title = self._html_search_regex('<h2 class="uiHeaderTitle">([^<]+)</h2>',
  145. webpage, u'title')
  146. info = {
  147. 'id': video_id,
  148. 'title': video_title,
  149. 'url': video_url,
  150. 'ext': 'mp4',
  151. 'duration': video_duration,
  152. 'thumbnail': thumbnail,
  153. }
  154. return [info]
  155. class EscapistIE(InfoExtractor):
  156. """Information extractor for The Escapist """
  157. _VALID_URL = r'^(https?://)?(www\.)?escapistmagazine\.com/videos/view/(?P<showname>[^/]+)/(?P<episode>[^/?]+)[/?]?.*$'
  158. IE_NAME = u'escapist'
  159. def _real_extract(self, url):
  160. mobj = re.match(self._VALID_URL, url)
  161. if mobj is None:
  162. raise ExtractorError(u'Invalid URL: %s' % url)
  163. showName = mobj.group('showname')
  164. videoId = mobj.group('episode')
  165. self.report_extraction(videoId)
  166. webpage = self._download_webpage(url, videoId)
  167. videoDesc = self._html_search_regex('<meta name="description" content="([^"]*)"',
  168. webpage, u'description', fatal=False)
  169. imgUrl = self._html_search_regex('<meta property="og:image" content="([^"]*)"',
  170. webpage, u'thumbnail', fatal=False)
  171. playerUrl = self._html_search_regex('<meta property="og:video" content="([^"]*)"',
  172. webpage, u'player url')
  173. title = self._html_search_regex('<meta name="title" content="([^"]*)"',
  174. webpage, u'player url').split(' : ')[-1]
  175. configUrl = self._search_regex('config=(.*)$', playerUrl, u'config url')
  176. configUrl = compat_urllib_parse.unquote(configUrl)
  177. configJSON = self._download_webpage(configUrl, videoId,
  178. u'Downloading configuration',
  179. u'unable to download configuration')
  180. # Technically, it's JavaScript, not JSON
  181. configJSON = configJSON.replace("'", '"')
  182. try:
  183. config = json.loads(configJSON)
  184. except (ValueError,) as err:
  185. raise ExtractorError(u'Invalid JSON in configuration file: ' + compat_str(err))
  186. playlist = config['playlist']
  187. videoUrl = playlist[1]['url']
  188. info = {
  189. 'id': videoId,
  190. 'url': videoUrl,
  191. 'uploader': showName,
  192. 'upload_date': None,
  193. 'title': title,
  194. 'ext': 'mp4',
  195. 'thumbnail': imgUrl,
  196. 'description': videoDesc,
  197. 'player_url': playerUrl,
  198. }
  199. return [info]
  200. class CollegeHumorIE(InfoExtractor):
  201. """Information extractor for collegehumor.com"""
  202. _WORKING = False
  203. _VALID_URL = r'^(?:https?://)?(?:www\.)?collegehumor\.com/video/(?P<videoid>[0-9]+)/(?P<shorttitle>.*)$'
  204. IE_NAME = u'collegehumor'
  205. def report_manifest(self, video_id):
  206. """Report information extraction."""
  207. self.to_screen(u'%s: Downloading XML manifest' % video_id)
  208. def _real_extract(self, url):
  209. mobj = re.match(self._VALID_URL, url)
  210. if mobj is None:
  211. raise ExtractorError(u'Invalid URL: %s' % url)
  212. video_id = mobj.group('videoid')
  213. info = {
  214. 'id': video_id,
  215. 'uploader': None,
  216. 'upload_date': None,
  217. }
  218. self.report_extraction(video_id)
  219. xmlUrl = 'http://www.collegehumor.com/moogaloop/video/' + video_id
  220. try:
  221. metaXml = compat_urllib_request.urlopen(xmlUrl).read()
  222. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  223. raise ExtractorError(u'Unable to download video info XML: %s' % compat_str(err))
  224. mdoc = xml.etree.ElementTree.fromstring(metaXml)
  225. try:
  226. videoNode = mdoc.findall('./video')[0]
  227. info['description'] = videoNode.findall('./description')[0].text
  228. info['title'] = videoNode.findall('./caption')[0].text
  229. info['thumbnail'] = videoNode.findall('./thumbnail')[0].text
  230. manifest_url = videoNode.findall('./file')[0].text
  231. except IndexError:
  232. raise ExtractorError(u'Invalid metadata XML file')
  233. manifest_url += '?hdcore=2.10.3'
  234. self.report_manifest(video_id)
  235. try:
  236. manifestXml = compat_urllib_request.urlopen(manifest_url).read()
  237. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  238. raise ExtractorError(u'Unable to download video info XML: %s' % compat_str(err))
  239. adoc = xml.etree.ElementTree.fromstring(manifestXml)
  240. try:
  241. media_node = adoc.findall('./{http://ns.adobe.com/f4m/1.0}media')[0]
  242. node_id = media_node.attrib['url']
  243. video_id = adoc.findall('./{http://ns.adobe.com/f4m/1.0}id')[0].text
  244. except IndexError as err:
  245. raise ExtractorError(u'Invalid manifest file')
  246. url_pr = compat_urllib_parse_urlparse(manifest_url)
  247. url = url_pr.scheme + '://' + url_pr.netloc + '/z' + video_id[:-2] + '/' + node_id + 'Seg1-Frag1'
  248. info['url'] = url
  249. info['ext'] = 'f4f'
  250. return [info]
  251. class XVideosIE(InfoExtractor):
  252. """Information extractor for xvideos.com"""
  253. _VALID_URL = r'^(?:https?://)?(?:www\.)?xvideos\.com/video([0-9]+)(?:.*)'
  254. IE_NAME = u'xvideos'
  255. def _real_extract(self, url):
  256. mobj = re.match(self._VALID_URL, url)
  257. if mobj is None:
  258. raise ExtractorError(u'Invalid URL: %s' % url)
  259. video_id = mobj.group(1)
  260. webpage = self._download_webpage(url, video_id)
  261. self.report_extraction(video_id)
  262. # Extract video URL
  263. video_url = compat_urllib_parse.unquote(self._search_regex(r'flv_url=(.+?)&',
  264. webpage, u'video URL'))
  265. # Extract title
  266. video_title = self._html_search_regex(r'<title>(.*?)\s+-\s+XVID',
  267. webpage, u'title')
  268. # Extract video thumbnail
  269. 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)',
  270. webpage, u'thumbnail', fatal=False)
  271. info = {
  272. 'id': video_id,
  273. 'url': video_url,
  274. 'uploader': None,
  275. 'upload_date': None,
  276. 'title': video_title,
  277. 'ext': 'flv',
  278. 'thumbnail': video_thumbnail,
  279. 'description': None,
  280. }
  281. return [info]
  282. class SoundcloudIE(InfoExtractor):
  283. """Information extractor for soundcloud.com
  284. To access the media, the uid of the song and a stream token
  285. must be extracted from the page source and the script must make
  286. a request to media.soundcloud.com/crossdomain.xml. Then
  287. the media can be grabbed by requesting from an url composed
  288. of the stream token and uid
  289. """
  290. _VALID_URL = r'^(?:https?://)?(?:www\.)?soundcloud\.com/([\w\d-]+)/([\w\d-]+)'
  291. IE_NAME = u'soundcloud'
  292. def report_resolve(self, video_id):
  293. """Report information extraction."""
  294. self.to_screen(u'%s: Resolving id' % video_id)
  295. def _real_extract(self, url):
  296. mobj = re.match(self._VALID_URL, url)
  297. if mobj is None:
  298. raise ExtractorError(u'Invalid URL: %s' % url)
  299. # extract uploader (which is in the url)
  300. uploader = mobj.group(1)
  301. # extract simple title (uploader + slug of song title)
  302. slug_title = mobj.group(2)
  303. simple_title = uploader + u'-' + slug_title
  304. full_title = '%s/%s' % (uploader, slug_title)
  305. self.report_resolve(full_title)
  306. url = 'http://soundcloud.com/%s/%s' % (uploader, slug_title)
  307. resolv_url = 'http://api.soundcloud.com/resolve.json?url=' + url + '&client_id=b45b1aa10f1ac2941910a7f0d10f8e28'
  308. info_json = self._download_webpage(resolv_url, full_title, u'Downloading info JSON')
  309. info = json.loads(info_json)
  310. video_id = info['id']
  311. self.report_extraction(full_title)
  312. streams_url = 'https://api.sndcdn.com/i1/tracks/' + str(video_id) + '/streams?client_id=b45b1aa10f1ac2941910a7f0d10f8e28'
  313. stream_json = self._download_webpage(streams_url, full_title,
  314. u'Downloading stream definitions',
  315. u'unable to download stream definitions')
  316. streams = json.loads(stream_json)
  317. mediaURL = streams['http_mp3_128_url']
  318. upload_date = unified_strdate(info['created_at'])
  319. return [{
  320. 'id': info['id'],
  321. 'url': mediaURL,
  322. 'uploader': info['user']['username'],
  323. 'upload_date': upload_date,
  324. 'title': info['title'],
  325. 'ext': u'mp3',
  326. 'description': info['description'],
  327. }]
  328. class SoundcloudSetIE(InfoExtractor):
  329. """Information extractor for soundcloud.com sets
  330. To access the media, the uid of the song and a stream token
  331. must be extracted from the page source and the script must make
  332. a request to media.soundcloud.com/crossdomain.xml. Then
  333. the media can be grabbed by requesting from an url composed
  334. of the stream token and uid
  335. """
  336. _VALID_URL = r'^(?:https?://)?(?:www\.)?soundcloud\.com/([\w\d-]+)/sets/([\w\d-]+)'
  337. IE_NAME = u'soundcloud:set'
  338. def report_resolve(self, video_id):
  339. """Report information extraction."""
  340. self.to_screen(u'%s: Resolving id' % video_id)
  341. def _real_extract(self, url):
  342. mobj = re.match(self._VALID_URL, url)
  343. if mobj is None:
  344. raise ExtractorError(u'Invalid URL: %s' % url)
  345. # extract uploader (which is in the url)
  346. uploader = mobj.group(1)
  347. # extract simple title (uploader + slug of song title)
  348. slug_title = mobj.group(2)
  349. simple_title = uploader + u'-' + slug_title
  350. full_title = '%s/sets/%s' % (uploader, slug_title)
  351. self.report_resolve(full_title)
  352. url = 'http://soundcloud.com/%s/sets/%s' % (uploader, slug_title)
  353. resolv_url = 'http://api.soundcloud.com/resolve.json?url=' + url + '&client_id=b45b1aa10f1ac2941910a7f0d10f8e28'
  354. info_json = self._download_webpage(resolv_url, full_title)
  355. videos = []
  356. info = json.loads(info_json)
  357. if 'errors' in info:
  358. for err in info['errors']:
  359. self._downloader.report_error(u'unable to download video webpage: %s' % compat_str(err['error_message']))
  360. return
  361. self.report_extraction(full_title)
  362. for track in info['tracks']:
  363. video_id = track['id']
  364. streams_url = 'https://api.sndcdn.com/i1/tracks/' + str(video_id) + '/streams?client_id=b45b1aa10f1ac2941910a7f0d10f8e28'
  365. stream_json = self._download_webpage(streams_url, video_id, u'Downloading track info JSON')
  366. self.report_extraction(video_id)
  367. streams = json.loads(stream_json)
  368. mediaURL = streams['http_mp3_128_url']
  369. videos.append({
  370. 'id': video_id,
  371. 'url': mediaURL,
  372. 'uploader': track['user']['username'],
  373. 'upload_date': unified_strdate(track['created_at']),
  374. 'title': track['title'],
  375. 'ext': u'mp3',
  376. 'description': track['description'],
  377. })
  378. return videos
  379. class InfoQIE(InfoExtractor):
  380. """Information extractor for infoq.com"""
  381. _VALID_URL = r'^(?:https?://)?(?:www\.)?infoq\.com/[^/]+/[^/]+$'
  382. def _real_extract(self, url):
  383. mobj = re.match(self._VALID_URL, url)
  384. if mobj is None:
  385. raise ExtractorError(u'Invalid URL: %s' % url)
  386. webpage = self._download_webpage(url, video_id=url)
  387. self.report_extraction(url)
  388. # Extract video URL
  389. mobj = re.search(r"jsclassref ?= ?'([^']*)'", webpage)
  390. if mobj is None:
  391. raise ExtractorError(u'Unable to extract video url')
  392. real_id = compat_urllib_parse.unquote(base64.b64decode(mobj.group(1).encode('ascii')).decode('utf-8'))
  393. video_url = 'rtmpe://video.infoq.com/cfx/st/' + real_id
  394. # Extract title
  395. video_title = self._search_regex(r'contentTitle = "(.*?)";',
  396. webpage, u'title')
  397. # Extract description
  398. video_description = self._html_search_regex(r'<meta name="description" content="(.*)"(?:\s*/)?>',
  399. webpage, u'description', fatal=False)
  400. video_filename = video_url.split('/')[-1]
  401. video_id, extension = video_filename.split('.')
  402. info = {
  403. 'id': video_id,
  404. 'url': video_url,
  405. 'uploader': None,
  406. 'upload_date': None,
  407. 'title': video_title,
  408. 'ext': extension, # Extension is always(?) mp4, but seems to be flv
  409. 'thumbnail': None,
  410. 'description': video_description,
  411. }
  412. return [info]
  413. class MixcloudIE(InfoExtractor):
  414. """Information extractor for www.mixcloud.com"""
  415. _WORKING = False # New API, but it seems good http://www.mixcloud.com/developers/documentation/
  416. _VALID_URL = r'^(?:https?://)?(?:www\.)?mixcloud\.com/([\w\d-]+)/([\w\d-]+)'
  417. IE_NAME = u'mixcloud'
  418. def report_download_json(self, file_id):
  419. """Report JSON download."""
  420. self.to_screen(u'Downloading json')
  421. def get_urls(self, jsonData, fmt, bitrate='best'):
  422. """Get urls from 'audio_formats' section in json"""
  423. file_url = None
  424. try:
  425. bitrate_list = jsonData[fmt]
  426. if bitrate is None or bitrate == 'best' or bitrate not in bitrate_list:
  427. bitrate = max(bitrate_list) # select highest
  428. url_list = jsonData[fmt][bitrate]
  429. except TypeError: # we have no bitrate info.
  430. url_list = jsonData[fmt]
  431. return url_list
  432. def check_urls(self, url_list):
  433. """Returns 1st active url from list"""
  434. for url in url_list:
  435. try:
  436. compat_urllib_request.urlopen(url)
  437. return url
  438. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  439. url = None
  440. return None
  441. def _print_formats(self, formats):
  442. print('Available formats:')
  443. for fmt in formats.keys():
  444. for b in formats[fmt]:
  445. try:
  446. ext = formats[fmt][b][0]
  447. print('%s\t%s\t[%s]' % (fmt, b, ext.split('.')[-1]))
  448. except TypeError: # we have no bitrate info
  449. ext = formats[fmt][0]
  450. print('%s\t%s\t[%s]' % (fmt, '??', ext.split('.')[-1]))
  451. break
  452. def _real_extract(self, url):
  453. mobj = re.match(self._VALID_URL, url)
  454. if mobj is None:
  455. raise ExtractorError(u'Invalid URL: %s' % url)
  456. # extract uploader & filename from url
  457. uploader = mobj.group(1).decode('utf-8')
  458. file_id = uploader + "-" + mobj.group(2).decode('utf-8')
  459. # construct API request
  460. file_url = 'http://www.mixcloud.com/api/1/cloudcast/' + '/'.join(url.split('/')[-3:-1]) + '.json'
  461. # retrieve .json file with links to files
  462. request = compat_urllib_request.Request(file_url)
  463. try:
  464. self.report_download_json(file_url)
  465. jsonData = compat_urllib_request.urlopen(request).read()
  466. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  467. raise ExtractorError(u'Unable to retrieve file: %s' % compat_str(err))
  468. # parse JSON
  469. json_data = json.loads(jsonData)
  470. player_url = json_data['player_swf_url']
  471. formats = dict(json_data['audio_formats'])
  472. req_format = self._downloader.params.get('format', None)
  473. bitrate = None
  474. if self._downloader.params.get('listformats', None):
  475. self._print_formats(formats)
  476. return
  477. if req_format is None or req_format == 'best':
  478. for format_param in formats.keys():
  479. url_list = self.get_urls(formats, format_param)
  480. # check urls
  481. file_url = self.check_urls(url_list)
  482. if file_url is not None:
  483. break # got it!
  484. else:
  485. if req_format not in formats:
  486. raise ExtractorError(u'Format is not available')
  487. url_list = self.get_urls(formats, req_format)
  488. file_url = self.check_urls(url_list)
  489. format_param = req_format
  490. return [{
  491. 'id': file_id.decode('utf-8'),
  492. 'url': file_url.decode('utf-8'),
  493. 'uploader': uploader.decode('utf-8'),
  494. 'upload_date': None,
  495. 'title': json_data['name'],
  496. 'ext': file_url.split('.')[-1].decode('utf-8'),
  497. 'format': (format_param is None and u'NA' or format_param.decode('utf-8')),
  498. 'thumbnail': json_data['thumbnail_url'],
  499. 'description': json_data['description'],
  500. 'player_url': player_url.decode('utf-8'),
  501. }]
  502. class StanfordOpenClassroomIE(InfoExtractor):
  503. """Information extractor for Stanford's Open ClassRoom"""
  504. _VALID_URL = r'^(?:https?://)?openclassroom.stanford.edu(?P<path>/?|(/MainFolder/(?:HomePage|CoursePage|VideoPage)\.php([?]course=(?P<course>[^&]+)(&video=(?P<video>[^&]+))?(&.*)?)?))$'
  505. IE_NAME = u'stanfordoc'
  506. def _real_extract(self, url):
  507. mobj = re.match(self._VALID_URL, url)
  508. if mobj is None:
  509. raise ExtractorError(u'Invalid URL: %s' % url)
  510. if mobj.group('course') and mobj.group('video'): # A specific video
  511. course = mobj.group('course')
  512. video = mobj.group('video')
  513. info = {
  514. 'id': course + '_' + video,
  515. 'uploader': None,
  516. 'upload_date': None,
  517. }
  518. self.report_extraction(info['id'])
  519. baseUrl = 'http://openclassroom.stanford.edu/MainFolder/courses/' + course + '/videos/'
  520. xmlUrl = baseUrl + video + '.xml'
  521. try:
  522. metaXml = compat_urllib_request.urlopen(xmlUrl).read()
  523. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  524. raise ExtractorError(u'Unable to download video info XML: %s' % compat_str(err))
  525. mdoc = xml.etree.ElementTree.fromstring(metaXml)
  526. try:
  527. info['title'] = mdoc.findall('./title')[0].text
  528. info['url'] = baseUrl + mdoc.findall('./videoFile')[0].text
  529. except IndexError:
  530. raise ExtractorError(u'Invalid metadata XML file')
  531. info['ext'] = info['url'].rpartition('.')[2]
  532. return [info]
  533. elif mobj.group('course'): # A course page
  534. course = mobj.group('course')
  535. info = {
  536. 'id': course,
  537. 'type': 'playlist',
  538. 'uploader': None,
  539. 'upload_date': None,
  540. }
  541. coursepage = self._download_webpage(url, info['id'],
  542. note='Downloading course info page',
  543. errnote='Unable to download course info page')
  544. info['title'] = self._html_search_regex('<h1>([^<]+)</h1>', coursepage, 'title', default=info['id'])
  545. info['description'] = self._html_search_regex('<description>([^<]+)</description>',
  546. coursepage, u'description', fatal=False)
  547. links = orderedSet(re.findall('<a href="(VideoPage.php\?[^"]+)">', coursepage))
  548. info['list'] = [
  549. {
  550. 'type': 'reference',
  551. 'url': 'http://openclassroom.stanford.edu/MainFolder/' + unescapeHTML(vpage),
  552. }
  553. for vpage in links]
  554. results = []
  555. for entry in info['list']:
  556. assert entry['type'] == 'reference'
  557. results += self.extract(entry['url'])
  558. return results
  559. else: # Root page
  560. info = {
  561. 'id': 'Stanford OpenClassroom',
  562. 'type': 'playlist',
  563. 'uploader': None,
  564. 'upload_date': None,
  565. }
  566. self.report_download_webpage(info['id'])
  567. rootURL = 'http://openclassroom.stanford.edu/MainFolder/HomePage.php'
  568. try:
  569. rootpage = compat_urllib_request.urlopen(rootURL).read()
  570. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  571. raise ExtractorError(u'Unable to download course info page: ' + compat_str(err))
  572. info['title'] = info['id']
  573. links = orderedSet(re.findall('<a href="(CoursePage.php\?[^"]+)">', rootpage))
  574. info['list'] = [
  575. {
  576. 'type': 'reference',
  577. 'url': 'http://openclassroom.stanford.edu/MainFolder/' + unescapeHTML(cpage),
  578. }
  579. for cpage in links]
  580. results = []
  581. for entry in info['list']:
  582. assert entry['type'] == 'reference'
  583. results += self.extract(entry['url'])
  584. return results
  585. class MTVIE(InfoExtractor):
  586. """Information extractor for MTV.com"""
  587. _VALID_URL = r'^(?P<proto>https?://)?(?:www\.)?mtv\.com/videos/[^/]+/(?P<videoid>[0-9]+)/[^/]+$'
  588. IE_NAME = u'mtv'
  589. def _real_extract(self, url):
  590. mobj = re.match(self._VALID_URL, url)
  591. if mobj is None:
  592. raise ExtractorError(u'Invalid URL: %s' % url)
  593. if not mobj.group('proto'):
  594. url = 'http://' + url
  595. video_id = mobj.group('videoid')
  596. webpage = self._download_webpage(url, video_id)
  597. song_name = self._html_search_regex(r'<meta name="mtv_vt" content="([^"]+)"/>',
  598. webpage, u'song name', fatal=False)
  599. video_title = self._html_search_regex(r'<meta name="mtv_an" content="([^"]+)"/>',
  600. webpage, u'title')
  601. mtvn_uri = self._html_search_regex(r'<meta name="mtvn_uri" content="([^"]+)"/>',
  602. webpage, u'mtvn_uri', fatal=False)
  603. content_id = self._search_regex(r'MTVN.Player.defaultPlaylistId = ([0-9]+);',
  604. webpage, u'content id', fatal=False)
  605. 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
  606. self.report_extraction(video_id)
  607. request = compat_urllib_request.Request(videogen_url)
  608. try:
  609. metadataXml = compat_urllib_request.urlopen(request).read()
  610. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  611. raise ExtractorError(u'Unable to download video metadata: %s' % compat_str(err))
  612. mdoc = xml.etree.ElementTree.fromstring(metadataXml)
  613. renditions = mdoc.findall('.//rendition')
  614. # For now, always pick the highest quality.
  615. rendition = renditions[-1]
  616. try:
  617. _,_,ext = rendition.attrib['type'].partition('/')
  618. format = ext + '-' + rendition.attrib['width'] + 'x' + rendition.attrib['height'] + '_' + rendition.attrib['bitrate']
  619. video_url = rendition.find('./src').text
  620. except KeyError:
  621. raise ExtractorError('Invalid rendition field.')
  622. info = {
  623. 'id': video_id,
  624. 'url': video_url,
  625. 'uploader': performer,
  626. 'upload_date': None,
  627. 'title': video_title,
  628. 'ext': ext,
  629. 'format': format,
  630. }
  631. return [info]
  632. class YoukuIE(InfoExtractor):
  633. _VALID_URL = r'(?:http://)?v\.youku\.com/v_show/id_(?P<ID>[A-Za-z0-9]+)\.html'
  634. def _gen_sid(self):
  635. nowTime = int(time.time() * 1000)
  636. random1 = random.randint(1000,1998)
  637. random2 = random.randint(1000,9999)
  638. return "%d%d%d" %(nowTime,random1,random2)
  639. def _get_file_ID_mix_string(self, seed):
  640. mixed = []
  641. source = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/\:._-1234567890")
  642. seed = float(seed)
  643. for i in range(len(source)):
  644. seed = (seed * 211 + 30031 ) % 65536
  645. index = math.floor(seed / 65536 * len(source) )
  646. mixed.append(source[int(index)])
  647. source.remove(source[int(index)])
  648. #return ''.join(mixed)
  649. return mixed
  650. def _get_file_id(self, fileId, seed):
  651. mixed = self._get_file_ID_mix_string(seed)
  652. ids = fileId.split('*')
  653. realId = []
  654. for ch in ids:
  655. if ch:
  656. realId.append(mixed[int(ch)])
  657. return ''.join(realId)
  658. def _real_extract(self, url):
  659. mobj = re.match(self._VALID_URL, url)
  660. if mobj is None:
  661. raise ExtractorError(u'Invalid URL: %s' % url)
  662. video_id = mobj.group('ID')
  663. info_url = 'http://v.youku.com/player/getPlayList/VideoIDS/' + video_id
  664. jsondata = self._download_webpage(info_url, video_id)
  665. self.report_extraction(video_id)
  666. try:
  667. config = json.loads(jsondata)
  668. video_title = config['data'][0]['title']
  669. seed = config['data'][0]['seed']
  670. format = self._downloader.params.get('format', None)
  671. supported_format = list(config['data'][0]['streamfileids'].keys())
  672. if format is None or format == 'best':
  673. if 'hd2' in supported_format:
  674. format = 'hd2'
  675. else:
  676. format = 'flv'
  677. ext = u'flv'
  678. elif format == 'worst':
  679. format = 'mp4'
  680. ext = u'mp4'
  681. else:
  682. format = 'flv'
  683. ext = u'flv'
  684. fileid = config['data'][0]['streamfileids'][format]
  685. keys = [s['k'] for s in config['data'][0]['segs'][format]]
  686. except (UnicodeDecodeError, ValueError, KeyError):
  687. raise ExtractorError(u'Unable to extract info section')
  688. files_info=[]
  689. sid = self._gen_sid()
  690. fileid = self._get_file_id(fileid, seed)
  691. #column 8,9 of fileid represent the segment number
  692. #fileid[7:9] should be changed
  693. for index, key in enumerate(keys):
  694. temp_fileid = '%s%02X%s' % (fileid[0:8], index, fileid[10:])
  695. download_url = 'http://f.youku.com/player/getFlvPath/sid/%s_%02X/st/flv/fileid/%s?k=%s' % (sid, index, temp_fileid, key)
  696. info = {
  697. 'id': '%s_part%02d' % (video_id, index),
  698. 'url': download_url,
  699. 'uploader': None,
  700. 'upload_date': None,
  701. 'title': video_title,
  702. 'ext': ext,
  703. }
  704. files_info.append(info)
  705. return files_info
  706. class XNXXIE(InfoExtractor):
  707. """Information extractor for xnxx.com"""
  708. _VALID_URL = r'^(?:https?://)?video\.xnxx\.com/video([0-9]+)/(.*)'
  709. IE_NAME = u'xnxx'
  710. VIDEO_URL_RE = r'flv_url=(.*?)&amp;'
  711. VIDEO_TITLE_RE = r'<title>(.*?)\s+-\s+XNXX.COM'
  712. VIDEO_THUMB_RE = r'url_bigthumb=(.*?)&amp;'
  713. def _real_extract(self, url):
  714. mobj = re.match(self._VALID_URL, url)
  715. if mobj is None:
  716. raise ExtractorError(u'Invalid URL: %s' % url)
  717. video_id = mobj.group(1)
  718. # Get webpage content
  719. webpage = self._download_webpage(url, video_id)
  720. video_url = self._search_regex(self.VIDEO_URL_RE,
  721. webpage, u'video URL')
  722. video_url = compat_urllib_parse.unquote(video_url)
  723. video_title = self._html_search_regex(self.VIDEO_TITLE_RE,
  724. webpage, u'title')
  725. video_thumbnail = self._search_regex(self.VIDEO_THUMB_RE,
  726. webpage, u'thumbnail', fatal=False)
  727. return [{
  728. 'id': video_id,
  729. 'url': video_url,
  730. 'uploader': None,
  731. 'upload_date': None,
  732. 'title': video_title,
  733. 'ext': 'flv',
  734. 'thumbnail': video_thumbnail,
  735. 'description': None,
  736. }]
  737. class NBAIE(InfoExtractor):
  738. _VALID_URL = r'^(?:https?://)?(?:watch\.|www\.)?nba\.com/(?:nba/)?video(/[^?]*?)(?:/index\.html)?(?:\?.*)?$'
  739. IE_NAME = u'nba'
  740. def _real_extract(self, url):
  741. mobj = re.match(self._VALID_URL, url)
  742. if mobj is None:
  743. raise ExtractorError(u'Invalid URL: %s' % url)
  744. video_id = mobj.group(1)
  745. webpage = self._download_webpage(url, video_id)
  746. video_url = u'http://ht-mobile.cdn.turner.com/nba/big' + video_id + '_nba_1280x720.mp4'
  747. shortened_video_id = video_id.rpartition('/')[2]
  748. title = self._html_search_regex(r'<meta property="og:title" content="(.*?)"',
  749. webpage, 'title', default=shortened_video_id).replace('NBA.com: ', '')
  750. # It isn't there in the HTML it returns to us
  751. # uploader_date = self._html_search_regex(r'<b>Date:</b> (.*?)</div>', webpage, 'upload_date', fatal=False)
  752. description = self._html_search_regex(r'<meta name="description" (?:content|value)="(.*?)" />', webpage, 'description', fatal=False)
  753. info = {
  754. 'id': shortened_video_id,
  755. 'url': video_url,
  756. 'ext': 'mp4',
  757. 'title': title,
  758. # 'uploader_date': uploader_date,
  759. 'description': description,
  760. }
  761. return [info]
  762. class JustinTVIE(InfoExtractor):
  763. """Information extractor for justin.tv and twitch.tv"""
  764. # TODO: One broadcast may be split into multiple videos. The key
  765. # 'broadcast_id' is the same for all parts, and 'broadcast_part'
  766. # starts at 1 and increases. Can we treat all parts as one video?
  767. _VALID_URL = r"""(?x)^(?:http://)?(?:www\.)?(?:twitch|justin)\.tv/
  768. (?:
  769. (?P<channelid>[^/]+)|
  770. (?:(?:[^/]+)/b/(?P<videoid>[^/]+))|
  771. (?:(?:[^/]+)/c/(?P<chapterid>[^/]+))
  772. )
  773. /?(?:\#.*)?$
  774. """
  775. _JUSTIN_PAGE_LIMIT = 100
  776. IE_NAME = u'justin.tv'
  777. def report_download_page(self, channel, offset):
  778. """Report attempt to download a single page of videos."""
  779. self.to_screen(u'%s: Downloading video information from %d to %d' %
  780. (channel, offset, offset + self._JUSTIN_PAGE_LIMIT))
  781. # Return count of items, list of *valid* items
  782. def _parse_page(self, url, video_id):
  783. webpage = self._download_webpage(url, video_id,
  784. u'Downloading video info JSON',
  785. u'unable to download video info JSON')
  786. response = json.loads(webpage)
  787. if type(response) != list:
  788. error_text = response.get('error', 'unknown error')
  789. raise ExtractorError(u'Justin.tv API: %s' % error_text)
  790. info = []
  791. for clip in response:
  792. video_url = clip['video_file_url']
  793. if video_url:
  794. video_extension = os.path.splitext(video_url)[1][1:]
  795. video_date = re.sub('-', '', clip['start_time'][:10])
  796. video_uploader_id = clip.get('user_id', clip.get('channel_id'))
  797. video_id = clip['id']
  798. video_title = clip.get('title', video_id)
  799. info.append({
  800. 'id': video_id,
  801. 'url': video_url,
  802. 'title': video_title,
  803. 'uploader': clip.get('channel_name', video_uploader_id),
  804. 'uploader_id': video_uploader_id,
  805. 'upload_date': video_date,
  806. 'ext': video_extension,
  807. })
  808. return (len(response), info)
  809. def _real_extract(self, url):
  810. mobj = re.match(self._VALID_URL, url)
  811. if mobj is None:
  812. raise ExtractorError(u'invalid URL: %s' % url)
  813. api_base = 'http://api.justin.tv'
  814. paged = False
  815. if mobj.group('channelid'):
  816. paged = True
  817. video_id = mobj.group('channelid')
  818. api = api_base + '/channel/archives/%s.json' % video_id
  819. elif mobj.group('chapterid'):
  820. chapter_id = mobj.group('chapterid')
  821. webpage = self._download_webpage(url, chapter_id)
  822. m = re.search(r'PP\.archive_id = "([0-9]+)";', webpage)
  823. if not m:
  824. raise ExtractorError(u'Cannot find archive of a chapter')
  825. archive_id = m.group(1)
  826. api = api_base + '/broadcast/by_chapter/%s.xml' % chapter_id
  827. chapter_info_xml = self._download_webpage(api, chapter_id,
  828. note=u'Downloading chapter information',
  829. errnote=u'Chapter information download failed')
  830. doc = xml.etree.ElementTree.fromstring(chapter_info_xml)
  831. for a in doc.findall('.//archive'):
  832. if archive_id == a.find('./id').text:
  833. break
  834. else:
  835. raise ExtractorError(u'Could not find chapter in chapter information')
  836. video_url = a.find('./video_file_url').text
  837. video_ext = video_url.rpartition('.')[2] or u'flv'
  838. chapter_api_url = u'https://api.twitch.tv/kraken/videos/c' + chapter_id
  839. chapter_info_json = self._download_webpage(chapter_api_url, u'c' + chapter_id,
  840. note='Downloading chapter metadata',
  841. errnote='Download of chapter metadata failed')
  842. chapter_info = json.loads(chapter_info_json)
  843. bracket_start = int(doc.find('.//bracket_start').text)
  844. bracket_end = int(doc.find('.//bracket_end').text)
  845. # TODO determine start (and probably fix up file)
  846. # youtube-dl -v http://www.twitch.tv/firmbelief/c/1757457
  847. #video_url += u'?start=' + TODO:start_timestamp
  848. # bracket_start is 13290, but we want 51670615
  849. self._downloader.report_warning(u'Chapter detected, but we can just download the whole file. '
  850. u'Chapter starts at %s and ends at %s' % (formatSeconds(bracket_start), formatSeconds(bracket_end)))
  851. info = {
  852. 'id': u'c' + chapter_id,
  853. 'url': video_url,
  854. 'ext': video_ext,
  855. 'title': chapter_info['title'],
  856. 'thumbnail': chapter_info['preview'],
  857. 'description': chapter_info['description'],
  858. 'uploader': chapter_info['channel']['display_name'],
  859. 'uploader_id': chapter_info['channel']['name'],
  860. }
  861. return [info]
  862. else:
  863. video_id = mobj.group('videoid')
  864. api = api_base + '/broadcast/by_archive/%s.json' % video_id
  865. self.report_extraction(video_id)
  866. info = []
  867. offset = 0
  868. limit = self._JUSTIN_PAGE_LIMIT
  869. while True:
  870. if paged:
  871. self.report_download_page(video_id, offset)
  872. page_url = api + ('?offset=%d&limit=%d' % (offset, limit))
  873. page_count, page_info = self._parse_page(page_url, video_id)
  874. info.extend(page_info)
  875. if not paged or page_count != limit:
  876. break
  877. offset += limit
  878. return info
  879. class FunnyOrDieIE(InfoExtractor):
  880. _VALID_URL = r'^(?:https?://)?(?:www\.)?funnyordie\.com/videos/(?P<id>[0-9a-f]+)/.*$'
  881. def _real_extract(self, url):
  882. mobj = re.match(self._VALID_URL, url)
  883. if mobj is None:
  884. raise ExtractorError(u'invalid URL: %s' % url)
  885. video_id = mobj.group('id')
  886. webpage = self._download_webpage(url, video_id)
  887. video_url = self._html_search_regex(r'<video[^>]*>\s*<source[^>]*>\s*<source src="(?P<url>[^"]+)"',
  888. webpage, u'video URL', flags=re.DOTALL)
  889. title = self._html_search_regex((r"<h1 class='player_page_h1'.*?>(?P<title>.*?)</h1>",
  890. r'<title>(?P<title>[^<]+?)</title>'), webpage, 'title', flags=re.DOTALL)
  891. video_description = self._html_search_regex(r'<meta property="og:description" content="(?P<desc>.*?)"',
  892. webpage, u'description', fatal=False, flags=re.DOTALL)
  893. info = {
  894. 'id': video_id,
  895. 'url': video_url,
  896. 'ext': 'mp4',
  897. 'title': title,
  898. 'description': video_description,
  899. }
  900. return [info]
  901. class SteamIE(InfoExtractor):
  902. _VALID_URL = r"""http://store\.steampowered\.com/
  903. (agecheck/)?
  904. (?P<urltype>video|app)/ #If the page is only for videos or for a game
  905. (?P<gameID>\d+)/?
  906. (?P<videoID>\d*)(?P<extra>\??) #For urltype == video we sometimes get the videoID
  907. """
  908. _VIDEO_PAGE_TEMPLATE = 'http://store.steampowered.com/video/%s/'
  909. _AGECHECK_TEMPLATE = 'http://store.steampowered.com/agecheck/video/%s/?snr=1_agecheck_agecheck__age-gate&ageDay=1&ageMonth=January&ageYear=1970'
  910. @classmethod
  911. def suitable(cls, url):
  912. """Receives a URL and returns True if suitable for this IE."""
  913. return re.match(cls._VALID_URL, url, re.VERBOSE) is not None
  914. def _real_extract(self, url):
  915. m = re.match(self._VALID_URL, url, re.VERBOSE)
  916. gameID = m.group('gameID')
  917. videourl = self._VIDEO_PAGE_TEMPLATE % gameID
  918. webpage = self._download_webpage(videourl, gameID)
  919. if re.search('<h2>Please enter your birth date to continue:</h2>', webpage) is not None:
  920. videourl = self._AGECHECK_TEMPLATE % gameID
  921. self.report_age_confirmation()
  922. webpage = self._download_webpage(videourl, gameID)
  923. self.report_extraction(gameID)
  924. game_title = self._html_search_regex(r'<h2 class="pageheader">(.*?)</h2>',
  925. webpage, 'game title')
  926. urlRE = r"'movie_(?P<videoID>\d+)': \{\s*FILENAME: \"(?P<videoURL>[\w:/\.\?=]+)\"(,\s*MOVIE_NAME: \"(?P<videoName>[\w:/\.\?=\+-]+)\")?\s*\},"
  927. mweb = re.finditer(urlRE, webpage)
  928. namesRE = r'<span class="title">(?P<videoName>.+?)</span>'
  929. titles = re.finditer(namesRE, webpage)
  930. thumbsRE = r'<img class="movie_thumb" src="(?P<thumbnail>.+?)">'
  931. thumbs = re.finditer(thumbsRE, webpage)
  932. videos = []
  933. for vid,vtitle,thumb in zip(mweb,titles,thumbs):
  934. video_id = vid.group('videoID')
  935. title = vtitle.group('videoName')
  936. video_url = vid.group('videoURL')
  937. video_thumb = thumb.group('thumbnail')
  938. if not video_url:
  939. raise ExtractorError(u'Cannot find video url for %s' % video_id)
  940. info = {
  941. 'id':video_id,
  942. 'url':video_url,
  943. 'ext': 'flv',
  944. 'title': unescapeHTML(title),
  945. 'thumbnail': video_thumb
  946. }
  947. videos.append(info)
  948. return [self.playlist_result(videos, gameID, game_title)]
  949. class UstreamIE(InfoExtractor):
  950. _VALID_URL = r'https?://www\.ustream\.tv/recorded/(?P<videoID>\d+)'
  951. IE_NAME = u'ustream'
  952. def _real_extract(self, url):
  953. m = re.match(self._VALID_URL, url)
  954. video_id = m.group('videoID')
  955. video_url = u'http://tcdn.ustream.tv/video/%s' % video_id
  956. webpage = self._download_webpage(url, video_id)
  957. self.report_extraction(video_id)
  958. video_title = self._html_search_regex(r'data-title="(?P<title>.+)"',
  959. webpage, u'title')
  960. uploader = self._html_search_regex(r'data-content-type="channel".*?>(?P<uploader>.*?)</a>',
  961. webpage, u'uploader', fatal=False, flags=re.DOTALL)
  962. thumbnail = self._html_search_regex(r'<link rel="image_src" href="(?P<thumb>.*?)"',
  963. webpage, u'thumbnail', fatal=False)
  964. info = {
  965. 'id': video_id,
  966. 'url': video_url,
  967. 'ext': 'flv',
  968. 'title': video_title,
  969. 'uploader': uploader,
  970. 'thumbnail': thumbnail,
  971. }
  972. return info
  973. class WorldStarHipHopIE(InfoExtractor):
  974. _VALID_URL = r'https?://(?:www|m)\.worldstar(?:candy|hiphop)\.com/videos/video\.php\?v=(?P<id>.*)'
  975. IE_NAME = u'WorldStarHipHop'
  976. def _real_extract(self, url):
  977. m = re.match(self._VALID_URL, url)
  978. video_id = m.group('id')
  979. webpage_src = self._download_webpage(url, video_id)
  980. video_url = self._search_regex(r'so\.addVariable\("file","(.*?)"\)',
  981. webpage_src, u'video URL')
  982. if 'mp4' in video_url:
  983. ext = 'mp4'
  984. else:
  985. ext = 'flv'
  986. video_title = self._html_search_regex(r"<title>(.*)</title>",
  987. webpage_src, u'title')
  988. # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
  989. thumbnail = self._html_search_regex(r'rel="image_src" href="(.*)" />',
  990. webpage_src, u'thumbnail', fatal=False)
  991. if not thumbnail:
  992. _title = r"""candytitles.*>(.*)</span>"""
  993. mobj = re.search(_title, webpage_src)
  994. if mobj is not None:
  995. video_title = mobj.group(1)
  996. results = [{
  997. 'id': video_id,
  998. 'url' : video_url,
  999. 'title' : video_title,
  1000. 'thumbnail' : thumbnail,
  1001. 'ext' : ext,
  1002. }]
  1003. return results
  1004. class RBMARadioIE(InfoExtractor):
  1005. _VALID_URL = r'https?://(?:www\.)?rbmaradio\.com/shows/(?P<videoID>[^/]+)$'
  1006. def _real_extract(self, url):
  1007. m = re.match(self._VALID_URL, url)
  1008. video_id = m.group('videoID')
  1009. webpage = self._download_webpage(url, video_id)
  1010. json_data = self._search_regex(r'window\.gon.*?gon\.show=(.+?);$',
  1011. webpage, u'json data', flags=re.MULTILINE)
  1012. try:
  1013. data = json.loads(json_data)
  1014. except ValueError as e:
  1015. raise ExtractorError(u'Invalid JSON: ' + str(e))
  1016. video_url = data['akamai_url'] + '&cbr=256'
  1017. url_parts = compat_urllib_parse_urlparse(video_url)
  1018. video_ext = url_parts.path.rpartition('.')[2]
  1019. info = {
  1020. 'id': video_id,
  1021. 'url': video_url,
  1022. 'ext': video_ext,
  1023. 'title': data['title'],
  1024. 'description': data.get('teaser_text'),
  1025. 'location': data.get('country_of_origin'),
  1026. 'uploader': data.get('host', {}).get('name'),
  1027. 'uploader_id': data.get('host', {}).get('slug'),
  1028. 'thumbnail': data.get('image', {}).get('large_url_2x'),
  1029. 'duration': data.get('duration'),
  1030. }
  1031. return [info]
  1032. class YouPornIE(InfoExtractor):
  1033. """Information extractor for youporn.com."""
  1034. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?youporn\.com/watch/(?P<videoid>[0-9]+)/(?P<title>[^/]+)'
  1035. def _print_formats(self, formats):
  1036. """Print all available formats"""
  1037. print(u'Available formats:')
  1038. print(u'ext\t\tformat')
  1039. print(u'---------------------------------')
  1040. for format in formats:
  1041. print(u'%s\t\t%s' % (format['ext'], format['format']))
  1042. def _specific(self, req_format, formats):
  1043. for x in formats:
  1044. if(x["format"]==req_format):
  1045. return x
  1046. return None
  1047. def _real_extract(self, url):
  1048. mobj = re.match(self._VALID_URL, url)
  1049. if mobj is None:
  1050. raise ExtractorError(u'Invalid URL: %s' % url)
  1051. video_id = mobj.group('videoid')
  1052. req = compat_urllib_request.Request(url)
  1053. req.add_header('Cookie', 'age_verified=1')
  1054. webpage = self._download_webpage(req, video_id)
  1055. # Get JSON parameters
  1056. json_params = self._search_regex(r'var currentVideo = new Video\((.*)\);', webpage, u'JSON parameters')
  1057. try:
  1058. params = json.loads(json_params)
  1059. except:
  1060. raise ExtractorError(u'Invalid JSON')
  1061. self.report_extraction(video_id)
  1062. try:
  1063. video_title = params['title']
  1064. upload_date = unified_strdate(params['release_date_f'])
  1065. video_description = params['description']
  1066. video_uploader = params['submitted_by']
  1067. thumbnail = params['thumbnails'][0]['image']
  1068. except KeyError:
  1069. raise ExtractorError('Missing JSON parameter: ' + sys.exc_info()[1])
  1070. # Get all of the formats available
  1071. DOWNLOAD_LIST_RE = r'(?s)<ul class="downloadList">(?P<download_list>.*?)</ul>'
  1072. download_list_html = self._search_regex(DOWNLOAD_LIST_RE,
  1073. webpage, u'download list').strip()
  1074. # Get all of the links from the page
  1075. LINK_RE = r'(?s)<a href="(?P<url>[^"]+)">'
  1076. links = re.findall(LINK_RE, download_list_html)
  1077. if(len(links) == 0):
  1078. raise ExtractorError(u'ERROR: no known formats available for video')
  1079. self.to_screen(u'Links found: %d' % len(links))
  1080. formats = []
  1081. for link in links:
  1082. # A link looks like this:
  1083. # 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
  1084. # A path looks like this:
  1085. # /201210/31/8004515/480p_370k_8004515/YouPorn%20-%20Nubile%20Films%20The%20Pillow%20Fight.mp4
  1086. video_url = unescapeHTML( link )
  1087. path = compat_urllib_parse_urlparse( video_url ).path
  1088. extension = os.path.splitext( path )[1][1:]
  1089. format = path.split('/')[4].split('_')[:2]
  1090. size = format[0]
  1091. bitrate = format[1]
  1092. format = "-".join( format )
  1093. # title = u'%s-%s-%s' % (video_title, size, bitrate)
  1094. formats.append({
  1095. 'id': video_id,
  1096. 'url': video_url,
  1097. 'uploader': video_uploader,
  1098. 'upload_date': upload_date,
  1099. 'title': video_title,
  1100. 'ext': extension,
  1101. 'format': format,
  1102. 'thumbnail': thumbnail,
  1103. 'description': video_description
  1104. })
  1105. if self._downloader.params.get('listformats', None):
  1106. self._print_formats(formats)
  1107. return
  1108. req_format = self._downloader.params.get('format', None)
  1109. self.to_screen(u'Format: %s' % req_format)
  1110. if req_format is None or req_format == 'best':
  1111. return [formats[0]]
  1112. elif req_format == 'worst':
  1113. return [formats[-1]]
  1114. elif req_format in ('-1', 'all'):
  1115. return formats
  1116. else:
  1117. format = self._specific( req_format, formats )
  1118. if result is None:
  1119. raise ExtractorError(u'Requested format not available')
  1120. return [format]
  1121. class PornotubeIE(InfoExtractor):
  1122. """Information extractor for pornotube.com."""
  1123. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?pornotube\.com(/c/(?P<channel>[0-9]+))?(/m/(?P<videoid>[0-9]+))(/(?P<title>.+))$'
  1124. def _real_extract(self, url):
  1125. mobj = re.match(self._VALID_URL, url)
  1126. if mobj is None:
  1127. raise ExtractorError(u'Invalid URL: %s' % url)
  1128. video_id = mobj.group('videoid')
  1129. video_title = mobj.group('title')
  1130. # Get webpage content
  1131. webpage = self._download_webpage(url, video_id)
  1132. # Get the video URL
  1133. VIDEO_URL_RE = r'url: "(?P<url>http://video[0-9].pornotube.com/.+\.flv)",'
  1134. video_url = self._search_regex(VIDEO_URL_RE, webpage, u'video url')
  1135. video_url = compat_urllib_parse.unquote(video_url)
  1136. #Get the uploaded date
  1137. VIDEO_UPLOADED_RE = r'<div class="video_added_by">Added (?P<date>[0-9\/]+) by'
  1138. upload_date = self._html_search_regex(VIDEO_UPLOADED_RE, webpage, u'upload date', fatal=False)
  1139. if upload_date: upload_date = unified_strdate(upload_date)
  1140. info = {'id': video_id,
  1141. 'url': video_url,
  1142. 'uploader': None,
  1143. 'upload_date': upload_date,
  1144. 'title': video_title,
  1145. 'ext': 'flv',
  1146. 'format': 'flv'}
  1147. return [info]
  1148. class YouJizzIE(InfoExtractor):
  1149. """Information extractor for youjizz.com."""
  1150. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?youjizz\.com/videos/(?P<videoid>[^.]+).html$'
  1151. def _real_extract(self, url):
  1152. mobj = re.match(self._VALID_URL, url)
  1153. if mobj is None:
  1154. raise ExtractorError(u'Invalid URL: %s' % url)
  1155. video_id = mobj.group('videoid')
  1156. # Get webpage content
  1157. webpage = self._download_webpage(url, video_id)
  1158. # Get the video title
  1159. video_title = self._html_search_regex(r'<title>(?P<title>.*)</title>',
  1160. webpage, u'title').strip()
  1161. # Get the embed page
  1162. result = re.search(r'https?://www.youjizz.com/videos/embed/(?P<videoid>[0-9]+)', webpage)
  1163. if result is None:
  1164. raise ExtractorError(u'ERROR: unable to extract embed page')
  1165. embed_page_url = result.group(0).strip()
  1166. video_id = result.group('videoid')
  1167. webpage = self._download_webpage(embed_page_url, video_id)
  1168. # Get the video URL
  1169. video_url = self._search_regex(r'so.addVariable\("file",encodeURIComponent\("(?P<source>[^"]+)"\)\);',
  1170. webpage, u'video URL')
  1171. info = {'id': video_id,
  1172. 'url': video_url,
  1173. 'title': video_title,
  1174. 'ext': 'flv',
  1175. 'format': 'flv',
  1176. 'player_url': embed_page_url}
  1177. return [info]
  1178. class EightTracksIE(InfoExtractor):
  1179. IE_NAME = '8tracks'
  1180. _VALID_URL = r'https?://8tracks.com/(?P<user>[^/]+)/(?P<id>[^/#]+)(?:#.*)?$'
  1181. def _real_extract(self, url):
  1182. mobj = re.match(self._VALID_URL, url)
  1183. if mobj is None:
  1184. raise ExtractorError(u'Invalid URL: %s' % url)
  1185. playlist_id = mobj.group('id')
  1186. webpage = self._download_webpage(url, playlist_id)
  1187. json_like = self._search_regex(r"PAGE.mix = (.*?);\n", webpage, u'trax information', flags=re.DOTALL)
  1188. data = json.loads(json_like)
  1189. session = str(random.randint(0, 1000000000))
  1190. mix_id = data['id']
  1191. track_count = data['tracks_count']
  1192. first_url = 'http://8tracks.com/sets/%s/play?player=sm&mix_id=%s&format=jsonh' % (session, mix_id)
  1193. next_url = first_url
  1194. res = []
  1195. for i in itertools.count():
  1196. api_json = self._download_webpage(next_url, playlist_id,
  1197. note=u'Downloading song information %s/%s' % (str(i+1), track_count),
  1198. errnote=u'Failed to download song information')
  1199. api_data = json.loads(api_json)
  1200. track_data = api_data[u'set']['track']
  1201. info = {
  1202. 'id': track_data['id'],
  1203. 'url': track_data['track_file_stream_url'],
  1204. 'title': track_data['performer'] + u' - ' + track_data['name'],
  1205. 'raw_title': track_data['name'],
  1206. 'uploader_id': data['user']['login'],
  1207. 'ext': 'm4a',
  1208. }
  1209. res.append(info)
  1210. if api_data['set']['at_last_track']:
  1211. break
  1212. next_url = 'http://8tracks.com/sets/%s/next?player=sm&mix_id=%s&format=jsonh&track_id=%s' % (session, mix_id, track_data['id'])
  1213. return res
  1214. class KeekIE(InfoExtractor):
  1215. _VALID_URL = r'http://(?:www\.)?keek\.com/(?:!|\w+/keeks/)(?P<videoID>\w+)'
  1216. IE_NAME = u'keek'
  1217. def _real_extract(self, url):
  1218. m = re.match(self._VALID_URL, url)
  1219. video_id = m.group('videoID')
  1220. video_url = u'http://cdn.keek.com/keek/video/%s' % video_id
  1221. thumbnail = u'http://cdn.keek.com/keek/thumbnail/%s/w100/h75' % video_id
  1222. webpage = self._download_webpage(url, video_id)
  1223. video_title = self._html_search_regex(r'<meta property="og:title" content="(?P<title>.*?)"',
  1224. webpage, u'title')
  1225. uploader = self._html_search_regex(r'<div class="user-name-and-bio">[\S\s]+?<h2>(?P<uploader>.+?)</h2>',
  1226. webpage, u'uploader', fatal=False)
  1227. info = {
  1228. 'id': video_id,
  1229. 'url': video_url,
  1230. 'ext': 'mp4',
  1231. 'title': video_title,
  1232. 'thumbnail': thumbnail,
  1233. 'uploader': uploader
  1234. }
  1235. return [info]
  1236. class TEDIE(InfoExtractor):
  1237. _VALID_URL=r'''http://www\.ted\.com/
  1238. (
  1239. ((?P<type_playlist>playlists)/(?P<playlist_id>\d+)) # We have a playlist
  1240. |
  1241. ((?P<type_talk>talks)) # We have a simple talk
  1242. )
  1243. (/lang/(.*?))? # The url may contain the language
  1244. /(?P<name>\w+) # Here goes the name and then ".html"
  1245. '''
  1246. @classmethod
  1247. def suitable(cls, url):
  1248. """Receives a URL and returns True if suitable for this IE."""
  1249. return re.match(cls._VALID_URL, url, re.VERBOSE) is not None
  1250. def _real_extract(self, url):
  1251. m=re.match(self._VALID_URL, url, re.VERBOSE)
  1252. if m.group('type_talk'):
  1253. return [self._talk_info(url)]
  1254. else :
  1255. playlist_id=m.group('playlist_id')
  1256. name=m.group('name')
  1257. self.to_screen(u'Getting info of playlist %s: "%s"' % (playlist_id,name))
  1258. return [self._playlist_videos_info(url,name,playlist_id)]
  1259. def _playlist_videos_info(self,url,name,playlist_id=0):
  1260. '''Returns the videos of the playlist'''
  1261. video_RE=r'''
  1262. <li\ id="talk_(\d+)"([.\s]*?)data-id="(?P<video_id>\d+)"
  1263. ([.\s]*?)data-playlist_item_id="(\d+)"
  1264. ([.\s]*?)data-mediaslug="(?P<mediaSlug>.+?)"
  1265. '''
  1266. video_name_RE=r'<p\ class="talk-title"><a href="(?P<talk_url>/talks/(.+).html)">(?P<fullname>.+?)</a></p>'
  1267. webpage=self._download_webpage(url, playlist_id, 'Downloading playlist webpage')
  1268. m_videos=re.finditer(video_RE,webpage,re.VERBOSE)
  1269. m_names=re.finditer(video_name_RE,webpage)
  1270. playlist_title = self._html_search_regex(r'div class="headline">\s*?<h1>\s*?<span>(.*?)</span>',
  1271. webpage, 'playlist title')
  1272. playlist_entries = []
  1273. for m_video, m_name in zip(m_videos,m_names):
  1274. video_id=m_video.group('video_id')
  1275. talk_url='http://www.ted.com%s' % m_name.group('talk_url')
  1276. playlist_entries.append(self.url_result(talk_url, 'TED'))
  1277. return self.playlist_result(playlist_entries, playlist_id = playlist_id, playlist_title = playlist_title)
  1278. def _talk_info(self, url, video_id=0):
  1279. """Return the video for the talk in the url"""
  1280. m = re.match(self._VALID_URL, url,re.VERBOSE)
  1281. video_name = m.group('name')
  1282. webpage = self._download_webpage(url, video_id, 'Downloading \"%s\" page' % video_name)
  1283. self.report_extraction(video_name)
  1284. # If the url includes the language we get the title translated
  1285. title = self._html_search_regex(r'<span id="altHeadline" >(?P<title>.*)</span>',
  1286. webpage, 'title')
  1287. json_data = self._search_regex(r'<script.*?>var talkDetails = ({.*?})</script>',
  1288. webpage, 'json data')
  1289. info = json.loads(json_data)
  1290. desc = self._html_search_regex(r'<div class="talk-intro">.*?<p.*?>(.*?)</p>',
  1291. webpage, 'description', flags = re.DOTALL)
  1292. thumbnail = self._search_regex(r'</span>[\s.]*</div>[\s.]*<img src="(.*?)"',
  1293. webpage, 'thumbnail')
  1294. info = {
  1295. 'id': info['id'],
  1296. 'url': info['htmlStreams'][-1]['file'],
  1297. 'ext': 'mp4',
  1298. 'title': title,
  1299. 'thumbnail': thumbnail,
  1300. 'description': desc,
  1301. }
  1302. return info
  1303. class MySpassIE(InfoExtractor):
  1304. _VALID_URL = r'http://www.myspass.de/.*'
  1305. def _real_extract(self, url):
  1306. META_DATA_URL_TEMPLATE = 'http://www.myspass.de/myspass/includes/apps/video/getvideometadataxml.php?id=%s'
  1307. # video id is the last path element of the URL
  1308. # usually there is a trailing slash, so also try the second but last
  1309. url_path = compat_urllib_parse_urlparse(url).path
  1310. url_parent_path, video_id = os.path.split(url_path)
  1311. if not video_id:
  1312. _, video_id = os.path.split(url_parent_path)
  1313. # get metadata
  1314. metadata_url = META_DATA_URL_TEMPLATE % video_id
  1315. metadata_text = self._download_webpage(metadata_url, video_id)
  1316. metadata = xml.etree.ElementTree.fromstring(metadata_text.encode('utf-8'))
  1317. # extract values from metadata
  1318. url_flv_el = metadata.find('url_flv')
  1319. if url_flv_el is None:
  1320. raise ExtractorError(u'Unable to extract download url')
  1321. video_url = url_flv_el.text
  1322. extension = os.path.splitext(video_url)[1][1:]
  1323. title_el = metadata.find('title')
  1324. if title_el is None:
  1325. raise ExtractorError(u'Unable to extract title')
  1326. title = title_el.text
  1327. format_id_el = metadata.find('format_id')
  1328. if format_id_el is None:
  1329. format = ext
  1330. else:
  1331. format = format_id_el.text
  1332. description_el = metadata.find('description')
  1333. if description_el is not None:
  1334. description = description_el.text
  1335. else:
  1336. description = None
  1337. imagePreview_el = metadata.find('imagePreview')
  1338. if imagePreview_el is not None:
  1339. thumbnail = imagePreview_el.text
  1340. else:
  1341. thumbnail = None
  1342. info = {
  1343. 'id': video_id,
  1344. 'url': video_url,
  1345. 'title': title,
  1346. 'ext': extension,
  1347. 'format': format,
  1348. 'thumbnail': thumbnail,
  1349. 'description': description
  1350. }
  1351. return [info]
  1352. class SpiegelIE(InfoExtractor):
  1353. _VALID_URL = r'https?://(?:www\.)?spiegel\.de/video/[^/]*-(?P<videoID>[0-9]+)(?:\.html)?(?:#.*)?$'
  1354. def _real_extract(self, url):
  1355. m = re.match(self._VALID_URL, url)
  1356. video_id = m.group('videoID')
  1357. webpage = self._download_webpage(url, video_id)
  1358. video_title = self._html_search_regex(r'<div class="module-title">(.*?)</div>',
  1359. webpage, u'title')
  1360. xml_url = u'http://video2.spiegel.de/flash/' + video_id + u'.xml'
  1361. xml_code = self._download_webpage(xml_url, video_id,
  1362. note=u'Downloading XML', errnote=u'Failed to download XML')
  1363. idoc = xml.etree.ElementTree.fromstring(xml_code)
  1364. last_type = idoc[-1]
  1365. filename = last_type.findall('./filename')[0].text
  1366. duration = float(last_type.findall('./duration')[0].text)
  1367. video_url = 'http://video2.spiegel.de/flash/' + filename
  1368. video_ext = filename.rpartition('.')[2]
  1369. info = {
  1370. 'id': video_id,
  1371. 'url': video_url,
  1372. 'ext': video_ext,
  1373. 'title': video_title,
  1374. 'duration': duration,
  1375. }
  1376. return [info]
  1377. class LiveLeakIE(InfoExtractor):
  1378. _VALID_URL = r'^(?:http?://)?(?:\w+\.)?liveleak\.com/view\?(?:.*?)i=(?P<video_id>[\w_]+)(?:.*)'
  1379. IE_NAME = u'liveleak'
  1380. def _real_extract(self, url):
  1381. mobj = re.match(self._VALID_URL, url)
  1382. if mobj is None:
  1383. raise ExtractorError(u'Invalid URL: %s' % url)
  1384. video_id = mobj.group('video_id')
  1385. webpage = self._download_webpage(url, video_id)
  1386. video_url = self._search_regex(r'file: "(.*?)",',
  1387. webpage, u'video URL')
  1388. video_title = self._html_search_regex(r'<meta property="og:title" content="(?P<title>.*?)"',
  1389. webpage, u'title').replace('LiveLeak.com -', '').strip()
  1390. video_description = self._html_search_regex(r'<meta property="og:description" content="(?P<desc>.*?)"',
  1391. webpage, u'description', fatal=False)
  1392. video_uploader = self._html_search_regex(r'By:.*?(\w+)</a>',
  1393. webpage, u'uploader', fatal=False)
  1394. info = {
  1395. 'id': video_id,
  1396. 'url': video_url,
  1397. 'ext': 'mp4',
  1398. 'title': video_title,
  1399. 'description': video_description,
  1400. 'uploader': video_uploader
  1401. }
  1402. return [info]
  1403. class TumblrIE(InfoExtractor):
  1404. _VALID_URL = r'http://(?P<blog_name>.*?)\.tumblr\.com/((post)|(video))/(?P<id>\d*)/(.*?)'
  1405. def _real_extract(self, url):
  1406. m_url = re.match(self._VALID_URL, url)
  1407. video_id = m_url.group('id')
  1408. blog = m_url.group('blog_name')
  1409. url = 'http://%s.tumblr.com/post/%s/' % (blog, video_id)
  1410. webpage = self._download_webpage(url, video_id)
  1411. re_video = r'src=\\x22(?P<video_url>http://%s\.tumblr\.com/video_file/%s/(.*?))\\x22 type=\\x22video/(?P<ext>.*?)\\x22' % (blog, video_id)
  1412. video = re.search(re_video, webpage)
  1413. if video is None:
  1414. raise ExtractorError(u'Unable to extract video')
  1415. video_url = video.group('video_url')
  1416. ext = video.group('ext')
  1417. video_thumbnail = self._search_regex(r'posters(.*?)\[\\x22(?P<thumb>.*?)\\x22',
  1418. webpage, u'thumbnail', fatal=False) # We pick the first poster
  1419. if video_thumbnail: video_thumbnail = video_thumbnail.replace('\\', '')
  1420. # The only place where you can get a title, it's not complete,
  1421. # but searching in other places doesn't work for all videos
  1422. video_title = self._html_search_regex(r'<title>(?P<title>.*?)</title>',
  1423. webpage, u'title', flags=re.DOTALL)
  1424. return [{'id': video_id,
  1425. 'url': video_url,
  1426. 'title': video_title,
  1427. 'thumbnail': video_thumbnail,
  1428. 'ext': ext
  1429. }]
  1430. class BandcampIE(InfoExtractor):
  1431. _VALID_URL = r'http://.*?\.bandcamp\.com/track/(?P<title>.*)'
  1432. def _real_extract(self, url):
  1433. mobj = re.match(self._VALID_URL, url)
  1434. title = mobj.group('title')
  1435. webpage = self._download_webpage(url, title)
  1436. # We get the link to the free download page
  1437. m_download = re.search(r'freeDownloadPage: "(.*?)"', webpage)
  1438. if m_download is None:
  1439. raise ExtractorError(u'No free songs found')
  1440. download_link = m_download.group(1)
  1441. id = re.search(r'var TralbumData = {(.*?)id: (?P<id>\d*?)$',
  1442. webpage, re.MULTILINE|re.DOTALL).group('id')
  1443. download_webpage = self._download_webpage(download_link, id,
  1444. 'Downloading free downloads page')
  1445. # We get the dictionary of the track from some javascrip code
  1446. info = re.search(r'items: (.*?),$',
  1447. download_webpage, re.MULTILINE).group(1)
  1448. info = json.loads(info)[0]
  1449. # We pick mp3-320 for now, until format selection can be easily implemented.
  1450. mp3_info = info[u'downloads'][u'mp3-320']
  1451. # If we try to use this url it says the link has expired
  1452. initial_url = mp3_info[u'url']
  1453. re_url = r'(?P<server>http://(.*?)\.bandcamp\.com)/download/track\?enc=mp3-320&fsig=(?P<fsig>.*?)&id=(?P<id>.*?)&ts=(?P<ts>.*)$'
  1454. m_url = re.match(re_url, initial_url)
  1455. #We build the url we will use to get the final track url
  1456. # This url is build in Bandcamp in the script download_bunde_*.js
  1457. 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'))
  1458. final_url_webpage = self._download_webpage(request_url, id, 'Requesting download url')
  1459. # If we could correctly generate the .rand field the url would be
  1460. #in the "download_url" key
  1461. final_url = re.search(r'"retry_url":"(.*?)"', final_url_webpage).group(1)
  1462. track_info = {'id':id,
  1463. 'title' : info[u'title'],
  1464. 'ext' : 'mp3',
  1465. 'url' : final_url,
  1466. 'thumbnail' : info[u'thumb_url'],
  1467. 'uploader' : info[u'artist']
  1468. }
  1469. return [track_info]
  1470. class RedTubeIE(InfoExtractor):
  1471. """Information Extractor for redtube"""
  1472. _VALID_URL = r'(?:http://)?(?:www\.)?redtube\.com/(?P<id>[0-9]+)'
  1473. def _real_extract(self,url):
  1474. mobj = re.match(self._VALID_URL, url)
  1475. if mobj is None:
  1476. raise ExtractorError(u'Invalid URL: %s' % url)
  1477. video_id = mobj.group('id')
  1478. video_extension = 'mp4'
  1479. webpage = self._download_webpage(url, video_id)
  1480. self.report_extraction(video_id)
  1481. video_url = self._html_search_regex(r'<source src="(.+?)" type="video/mp4">',
  1482. webpage, u'video URL')
  1483. video_title = self._html_search_regex('<h1 class="videoTitle slidePanelMovable">(.+?)</h1>',
  1484. webpage, u'title')
  1485. return [{
  1486. 'id': video_id,
  1487. 'url': video_url,
  1488. 'ext': video_extension,
  1489. 'title': video_title,
  1490. }]
  1491. class InaIE(InfoExtractor):
  1492. """Information Extractor for Ina.fr"""
  1493. _VALID_URL = r'(?:http://)?(?:www\.)?ina\.fr/video/(?P<id>I[0-9]+)/.*'
  1494. def _real_extract(self,url):
  1495. mobj = re.match(self._VALID_URL, url)
  1496. video_id = mobj.group('id')
  1497. mrss_url='http://player.ina.fr/notices/%s.mrss' % video_id
  1498. video_extension = 'mp4'
  1499. webpage = self._download_webpage(mrss_url, video_id)
  1500. self.report_extraction(video_id)
  1501. video_url = self._html_search_regex(r'<media:player url="(?P<mp4url>http://mp4.ina.fr/[^"]+\.mp4)',
  1502. webpage, u'video URL')
  1503. video_title = self._search_regex(r'<title><!\[CDATA\[(?P<titre>.*?)]]></title>',
  1504. webpage, u'title')
  1505. return [{
  1506. 'id': video_id,
  1507. 'url': video_url,
  1508. 'ext': video_extension,
  1509. 'title': video_title,
  1510. }]
  1511. class HowcastIE(InfoExtractor):
  1512. """Information Extractor for Howcast.com"""
  1513. _VALID_URL = r'(?:https?://)?(?:www\.)?howcast\.com/videos/(?P<id>\d+)'
  1514. def _real_extract(self, url):
  1515. mobj = re.match(self._VALID_URL, url)
  1516. video_id = mobj.group('id')
  1517. webpage_url = 'http://www.howcast.com/videos/' + video_id
  1518. webpage = self._download_webpage(webpage_url, video_id)
  1519. self.report_extraction(video_id)
  1520. video_url = self._search_regex(r'\'?file\'?: "(http://mobile-media\.howcast\.com/[0-9]+\.mp4)',
  1521. webpage, u'video URL')
  1522. video_title = self._html_search_regex(r'<meta content=(?:"([^"]+)"|\'([^\']+)\') property=\'og:title\'',
  1523. webpage, u'title')
  1524. video_description = self._html_search_regex(r'<meta content=(?:"([^"]+)"|\'([^\']+)\') name=\'description\'',
  1525. webpage, u'description', fatal=False)
  1526. thumbnail = self._html_search_regex(r'<meta content=\'(.+?)\' property=\'og:image\'',
  1527. webpage, u'thumbnail', fatal=False)
  1528. return [{
  1529. 'id': video_id,
  1530. 'url': video_url,
  1531. 'ext': 'mp4',
  1532. 'title': video_title,
  1533. 'description': video_description,
  1534. 'thumbnail': thumbnail,
  1535. }]
  1536. class VineIE(InfoExtractor):
  1537. """Information Extractor for Vine.co"""
  1538. _VALID_URL = r'(?:https?://)?(?:www\.)?vine\.co/v/(?P<id>\w+)'
  1539. def _real_extract(self, url):
  1540. mobj = re.match(self._VALID_URL, url)
  1541. video_id = mobj.group('id')
  1542. webpage_url = 'https://vine.co/v/' + video_id
  1543. webpage = self._download_webpage(webpage_url, video_id)
  1544. self.report_extraction(video_id)
  1545. video_url = self._html_search_regex(r'<meta property="twitter:player:stream" content="(.+?)"',
  1546. webpage, u'video URL')
  1547. video_title = self._html_search_regex(r'<meta property="og:title" content="(.+?)"',
  1548. webpage, u'title')
  1549. thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.+?)(\?.*?)?"',
  1550. webpage, u'thumbnail', fatal=False)
  1551. uploader = self._html_search_regex(r'<div class="user">.*?<h2>(.+?)</h2>',
  1552. webpage, u'uploader', fatal=False, flags=re.DOTALL)
  1553. return [{
  1554. 'id': video_id,
  1555. 'url': video_url,
  1556. 'ext': 'mp4',
  1557. 'title': video_title,
  1558. 'thumbnail': thumbnail,
  1559. 'uploader': uploader,
  1560. }]
  1561. class FlickrIE(InfoExtractor):
  1562. """Information Extractor for Flickr videos"""
  1563. _VALID_URL = r'(?:https?://)?(?:www\.)?flickr\.com/photos/(?P<uploader_id>[\w\-_@]+)/(?P<id>\d+).*'
  1564. def _real_extract(self, url):
  1565. mobj = re.match(self._VALID_URL, url)
  1566. video_id = mobj.group('id')
  1567. video_uploader_id = mobj.group('uploader_id')
  1568. webpage_url = 'http://www.flickr.com/photos/' + video_uploader_id + '/' + video_id
  1569. webpage = self._download_webpage(webpage_url, video_id)
  1570. secret = self._search_regex(r"photo_secret: '(\w+)'", webpage, u'secret')
  1571. first_url = 'https://secure.flickr.com/apps/video/video_mtl_xml.gne?v=x&photo_id=' + video_id + '&secret=' + secret + '&bitrate=700&target=_self'
  1572. first_xml = self._download_webpage(first_url, video_id, 'Downloading first data webpage')
  1573. node_id = self._html_search_regex(r'<Item id="id">(\d+-\d+)</Item>',
  1574. first_xml, u'node_id')
  1575. 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'
  1576. second_xml = self._download_webpage(second_url, video_id, 'Downloading second data webpage')
  1577. self.report_extraction(video_id)
  1578. mobj = re.search(r'<STREAM APP="(.+?)" FULLPATH="(.+?)"', second_xml)
  1579. if mobj is None:
  1580. raise ExtractorError(u'Unable to extract video url')
  1581. video_url = mobj.group(1) + unescapeHTML(mobj.group(2))
  1582. video_title = self._html_search_regex(r'<meta property="og:title" content=(?:"([^"]+)"|\'([^\']+)\')',
  1583. webpage, u'video title')
  1584. video_description = self._html_search_regex(r'<meta property="og:description" content=(?:"([^"]+)"|\'([^\']+)\')',
  1585. webpage, u'description', fatal=False)
  1586. thumbnail = self._html_search_regex(r'<meta property="og:image" content=(?:"([^"]+)"|\'([^\']+)\')',
  1587. webpage, u'thumbnail', fatal=False)
  1588. return [{
  1589. 'id': video_id,
  1590. 'url': video_url,
  1591. 'ext': 'mp4',
  1592. 'title': video_title,
  1593. 'description': video_description,
  1594. 'thumbnail': thumbnail,
  1595. 'uploader_id': video_uploader_id,
  1596. }]
  1597. class TeamcocoIE(InfoExtractor):
  1598. _VALID_URL = r'http://teamcoco\.com/video/(?P<url_title>.*)'
  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. url_title = mobj.group('url_title')
  1604. webpage = self._download_webpage(url, url_title)
  1605. video_id = self._html_search_regex(r'<article class="video" data-id="(\d+?)"',
  1606. webpage, u'video id')
  1607. self.report_extraction(video_id)
  1608. video_title = self._html_search_regex(r'<meta property="og:title" content="(.+?)"',
  1609. webpage, u'title')
  1610. thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.+?)"',
  1611. webpage, u'thumbnail', fatal=False)
  1612. video_description = self._html_search_regex(r'<meta property="og:description" content="(.*?)"',
  1613. webpage, u'description', fatal=False)
  1614. data_url = 'http://teamcoco.com/cvp/2.0/%s.xml' % video_id
  1615. data = self._download_webpage(data_url, video_id, 'Downloading data webpage')
  1616. video_url = self._html_search_regex(r'<file type="high".*?>(.*?)</file>',
  1617. data, u'video URL')
  1618. return [{
  1619. 'id': video_id,
  1620. 'url': video_url,
  1621. 'ext': 'mp4',
  1622. 'title': video_title,
  1623. 'thumbnail': thumbnail,
  1624. 'description': video_description,
  1625. }]
  1626. class XHamsterIE(InfoExtractor):
  1627. """Information Extractor for xHamster"""
  1628. _VALID_URL = r'(?:http://)?(?:www.)?xhamster\.com/movies/(?P<id>[0-9]+)/.*\.html'
  1629. def _real_extract(self,url):
  1630. mobj = re.match(self._VALID_URL, url)
  1631. video_id = mobj.group('id')
  1632. mrss_url = 'http://xhamster.com/movies/%s/.html' % video_id
  1633. webpage = self._download_webpage(mrss_url, video_id)
  1634. mobj = re.search(r'\'srv\': \'(?P<server>[^\']*)\',\s*\'file\': \'(?P<file>[^\']+)\',', webpage)
  1635. if mobj is None:
  1636. raise ExtractorError(u'Unable to extract media URL')
  1637. if len(mobj.group('server')) == 0:
  1638. video_url = compat_urllib_parse.unquote(mobj.group('file'))
  1639. else:
  1640. video_url = mobj.group('server')+'/key='+mobj.group('file')
  1641. video_extension = video_url.split('.')[-1]
  1642. video_title = self._html_search_regex(r'<title>(?P<title>.+?) - xHamster\.com</title>',
  1643. webpage, u'title')
  1644. # Can't see the description anywhere in the UI
  1645. # video_description = self._html_search_regex(r'<span>Description: </span>(?P<description>[^<]+)',
  1646. # webpage, u'description', fatal=False)
  1647. # if video_description: video_description = unescapeHTML(video_description)
  1648. 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)
  1649. if mobj:
  1650. video_upload_date = mobj.group('upload_date_Y')+mobj.group('upload_date_m')+mobj.group('upload_date_d')
  1651. else:
  1652. video_upload_date = None
  1653. self._downloader.report_warning(u'Unable to extract upload date')
  1654. video_uploader_id = self._html_search_regex(r'<a href=\'/user/[^>]+>(?P<uploader_id>[^<]+)',
  1655. webpage, u'uploader id', default=u'anonymous')
  1656. video_thumbnail = self._search_regex(r'\'image\':\'(?P<thumbnail>[^\']+)\'',
  1657. webpage, u'thumbnail', fatal=False)
  1658. return [{
  1659. 'id': video_id,
  1660. 'url': video_url,
  1661. 'ext': video_extension,
  1662. 'title': video_title,
  1663. # 'description': video_description,
  1664. 'upload_date': video_upload_date,
  1665. 'uploader_id': video_uploader_id,
  1666. 'thumbnail': video_thumbnail
  1667. }]
  1668. class HypemIE(InfoExtractor):
  1669. """Information Extractor for hypem"""
  1670. _VALID_URL = r'(?:http://)?(?:www\.)?hypem\.com/track/([^/]+)/([^/]+)'
  1671. def _real_extract(self, url):
  1672. mobj = re.match(self._VALID_URL, url)
  1673. if mobj is None:
  1674. raise ExtractorError(u'Invalid URL: %s' % url)
  1675. track_id = mobj.group(1)
  1676. data = { 'ax': 1, 'ts': time.time() }
  1677. data_encoded = compat_urllib_parse.urlencode(data)
  1678. complete_url = url + "?" + data_encoded
  1679. request = compat_urllib_request.Request(complete_url)
  1680. response, urlh = self._download_webpage_handle(request, track_id, u'Downloading webpage with the url')
  1681. cookie = urlh.headers.get('Set-Cookie', '')
  1682. self.report_extraction(track_id)
  1683. html_tracks = self._html_search_regex(r'<script type="application/json" id="displayList-data">(.*?)</script>',
  1684. response, u'tracks', flags=re.MULTILINE|re.DOTALL).strip()
  1685. try:
  1686. track_list = json.loads(html_tracks)
  1687. track = track_list[u'tracks'][0]
  1688. except ValueError:
  1689. raise ExtractorError(u'Hypemachine contained invalid JSON.')
  1690. key = track[u"key"]
  1691. track_id = track[u"id"]
  1692. artist = track[u"artist"]
  1693. title = track[u"song"]
  1694. serve_url = "http://hypem.com/serve/source/%s/%s" % (compat_str(track_id), compat_str(key))
  1695. request = compat_urllib_request.Request(serve_url, "" , {'Content-Type': 'application/json'})
  1696. request.add_header('cookie', cookie)
  1697. song_data_json = self._download_webpage(request, track_id, u'Downloading metadata')
  1698. try:
  1699. song_data = json.loads(song_data_json)
  1700. except ValueError:
  1701. raise ExtractorError(u'Hypemachine contained invalid JSON.')
  1702. final_url = song_data[u"url"]
  1703. return [{
  1704. 'id': track_id,
  1705. 'url': final_url,
  1706. 'ext': "mp3",
  1707. 'title': title,
  1708. 'artist': artist,
  1709. }]
  1710. class Vbox7IE(InfoExtractor):
  1711. """Information Extractor for Vbox7"""
  1712. _VALID_URL = r'(?:http://)?(?:www\.)?vbox7\.com/play:([^/]+)'
  1713. def _real_extract(self,url):
  1714. mobj = re.match(self._VALID_URL, url)
  1715. if mobj is None:
  1716. raise ExtractorError(u'Invalid URL: %s' % url)
  1717. video_id = mobj.group(1)
  1718. redirect_page, urlh = self._download_webpage_handle(url, video_id)
  1719. new_location = self._search_regex(r'window\.location = \'(.*)\';', redirect_page, u'redirect location')
  1720. redirect_url = urlh.geturl() + new_location
  1721. webpage = self._download_webpage(redirect_url, video_id, u'Downloading redirect page')
  1722. title = self._html_search_regex(r'<title>(.*)</title>',
  1723. webpage, u'title').split('/')[0].strip()
  1724. ext = "flv"
  1725. info_url = "http://vbox7.com/play/magare.do"
  1726. data = compat_urllib_parse.urlencode({'as3':'1','vid':video_id})
  1727. info_request = compat_urllib_request.Request(info_url, data)
  1728. info_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
  1729. info_response = self._download_webpage(info_request, video_id, u'Downloading info webpage')
  1730. if info_response is None:
  1731. raise ExtractorError(u'Unable to extract the media url')
  1732. (final_url, thumbnail_url) = map(lambda x: x.split('=')[1], info_response.split('&'))
  1733. return [{
  1734. 'id': video_id,
  1735. 'url': final_url,
  1736. 'ext': ext,
  1737. 'title': title,
  1738. 'thumbnail': thumbnail_url,
  1739. }]
  1740. def gen_extractors():
  1741. """ Return a list of an instance of every supported extractor.
  1742. The order does matter; the first extractor matched is the one handling the URL.
  1743. """
  1744. return [
  1745. YoutubePlaylistIE(),
  1746. YoutubeChannelIE(),
  1747. YoutubeUserIE(),
  1748. YoutubeSearchIE(),
  1749. YoutubeIE(),
  1750. MetacafeIE(),
  1751. DailymotionIE(),
  1752. GoogleSearchIE(),
  1753. PhotobucketIE(),
  1754. YahooIE(),
  1755. YahooSearchIE(),
  1756. DepositFilesIE(),
  1757. FacebookIE(),
  1758. BlipTVIE(),
  1759. BlipTVUserIE(),
  1760. VimeoIE(),
  1761. MyVideoIE(),
  1762. ComedyCentralIE(),
  1763. EscapistIE(),
  1764. CollegeHumorIE(),
  1765. XVideosIE(),
  1766. SoundcloudSetIE(),
  1767. SoundcloudIE(),
  1768. InfoQIE(),
  1769. MixcloudIE(),
  1770. StanfordOpenClassroomIE(),
  1771. MTVIE(),
  1772. YoukuIE(),
  1773. XNXXIE(),
  1774. YouJizzIE(),
  1775. PornotubeIE(),
  1776. YouPornIE(),
  1777. GooglePlusIE(),
  1778. ArteTvIE(),
  1779. NBAIE(),
  1780. WorldStarHipHopIE(),
  1781. JustinTVIE(),
  1782. FunnyOrDieIE(),
  1783. SteamIE(),
  1784. UstreamIE(),
  1785. RBMARadioIE(),
  1786. EightTracksIE(),
  1787. KeekIE(),
  1788. TEDIE(),
  1789. MySpassIE(),
  1790. SpiegelIE(),
  1791. LiveLeakIE(),
  1792. ARDIE(),
  1793. ZDFIE(),
  1794. TumblrIE(),
  1795. BandcampIE(),
  1796. RedTubeIE(),
  1797. InaIE(),
  1798. HowcastIE(),
  1799. VineIE(),
  1800. FlickrIE(),
  1801. TeamcocoIE(),
  1802. XHamsterIE(),
  1803. HypemIE(),
  1804. Vbox7IE(),
  1805. GametrailersIE(),
  1806. StatigramIE(),
  1807. GenericIE()
  1808. ]
  1809. def get_info_extractor(ie_name):
  1810. """Returns the info extractor class with the given ie_name"""
  1811. return globals()[ie_name+'IE']