InfoExtractors.py 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664
  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.collegehumor import CollegeHumorIE
  24. from .extractor.dailymotion import DailymotionIE
  25. from .extractor.depositfiles import DepositFilesIE
  26. from .extractor.escapist import EscapistIE
  27. from .extractor.facebook import FacebookIE
  28. from .extractor.gametrailers import GametrailersIE
  29. from .extractor.generic import GenericIE
  30. from .extractor.googleplus import GooglePlusIE
  31. from .extractor.googlesearch import GoogleSearchIE
  32. from .extractor.infoq import InfoQIE
  33. from .extractor.metacafe import MetacafeIE
  34. from .extractor.myvideo import MyVideoIE
  35. from .extractor.statigram import StatigramIE
  36. from .extractor.photobucket import PhotobucketIE
  37. from .extractor.soundcloud import SoundcloudIE, SoundcloudSetIE
  38. from .extractor.stanfordoc import StanfordOpenClassroomIE
  39. from .extractor.vimeo import VimeoIE
  40. from .extractor.xvideos import XVideosIE
  41. from .extractor.yahoo import YahooIE, YahooSearchIE
  42. from .extractor.youtube import YoutubeIE, YoutubePlaylistIE, YoutubeSearchIE, YoutubeUserIE, YoutubeChannelIE
  43. from .extractor.zdf import ZDFIE
  44. class MixcloudIE(InfoExtractor):
  45. """Information extractor for www.mixcloud.com"""
  46. _WORKING = False # New API, but it seems good http://www.mixcloud.com/developers/documentation/
  47. _VALID_URL = r'^(?:https?://)?(?:www\.)?mixcloud\.com/([\w\d-]+)/([\w\d-]+)'
  48. IE_NAME = u'mixcloud'
  49. def report_download_json(self, file_id):
  50. """Report JSON download."""
  51. self.to_screen(u'Downloading json')
  52. def get_urls(self, jsonData, fmt, bitrate='best'):
  53. """Get urls from 'audio_formats' section in json"""
  54. file_url = None
  55. try:
  56. bitrate_list = jsonData[fmt]
  57. if bitrate is None or bitrate == 'best' or bitrate not in bitrate_list:
  58. bitrate = max(bitrate_list) # select highest
  59. url_list = jsonData[fmt][bitrate]
  60. except TypeError: # we have no bitrate info.
  61. url_list = jsonData[fmt]
  62. return url_list
  63. def check_urls(self, url_list):
  64. """Returns 1st active url from list"""
  65. for url in url_list:
  66. try:
  67. compat_urllib_request.urlopen(url)
  68. return url
  69. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  70. url = None
  71. return None
  72. def _print_formats(self, formats):
  73. print('Available formats:')
  74. for fmt in formats.keys():
  75. for b in formats[fmt]:
  76. try:
  77. ext = formats[fmt][b][0]
  78. print('%s\t%s\t[%s]' % (fmt, b, ext.split('.')[-1]))
  79. except TypeError: # we have no bitrate info
  80. ext = formats[fmt][0]
  81. print('%s\t%s\t[%s]' % (fmt, '??', ext.split('.')[-1]))
  82. break
  83. def _real_extract(self, url):
  84. mobj = re.match(self._VALID_URL, url)
  85. if mobj is None:
  86. raise ExtractorError(u'Invalid URL: %s' % url)
  87. # extract uploader & filename from url
  88. uploader = mobj.group(1).decode('utf-8')
  89. file_id = uploader + "-" + mobj.group(2).decode('utf-8')
  90. # construct API request
  91. file_url = 'http://www.mixcloud.com/api/1/cloudcast/' + '/'.join(url.split('/')[-3:-1]) + '.json'
  92. # retrieve .json file with links to files
  93. request = compat_urllib_request.Request(file_url)
  94. try:
  95. self.report_download_json(file_url)
  96. jsonData = compat_urllib_request.urlopen(request).read()
  97. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  98. raise ExtractorError(u'Unable to retrieve file: %s' % compat_str(err))
  99. # parse JSON
  100. json_data = json.loads(jsonData)
  101. player_url = json_data['player_swf_url']
  102. formats = dict(json_data['audio_formats'])
  103. req_format = self._downloader.params.get('format', None)
  104. bitrate = None
  105. if self._downloader.params.get('listformats', None):
  106. self._print_formats(formats)
  107. return
  108. if req_format is None or req_format == 'best':
  109. for format_param in formats.keys():
  110. url_list = self.get_urls(formats, format_param)
  111. # check urls
  112. file_url = self.check_urls(url_list)
  113. if file_url is not None:
  114. break # got it!
  115. else:
  116. if req_format not in formats:
  117. raise ExtractorError(u'Format is not available')
  118. url_list = self.get_urls(formats, req_format)
  119. file_url = self.check_urls(url_list)
  120. format_param = req_format
  121. return [{
  122. 'id': file_id.decode('utf-8'),
  123. 'url': file_url.decode('utf-8'),
  124. 'uploader': uploader.decode('utf-8'),
  125. 'upload_date': None,
  126. 'title': json_data['name'],
  127. 'ext': file_url.split('.')[-1].decode('utf-8'),
  128. 'format': (format_param is None and u'NA' or format_param.decode('utf-8')),
  129. 'thumbnail': json_data['thumbnail_url'],
  130. 'description': json_data['description'],
  131. 'player_url': player_url.decode('utf-8'),
  132. }]
  133. class MTVIE(InfoExtractor):
  134. """Information extractor for MTV.com"""
  135. _VALID_URL = r'^(?P<proto>https?://)?(?:www\.)?mtv\.com/videos/[^/]+/(?P<videoid>[0-9]+)/[^/]+$'
  136. IE_NAME = u'mtv'
  137. def _real_extract(self, url):
  138. mobj = re.match(self._VALID_URL, url)
  139. if mobj is None:
  140. raise ExtractorError(u'Invalid URL: %s' % url)
  141. if not mobj.group('proto'):
  142. url = 'http://' + url
  143. video_id = mobj.group('videoid')
  144. webpage = self._download_webpage(url, video_id)
  145. song_name = self._html_search_regex(r'<meta name="mtv_vt" content="([^"]+)"/>',
  146. webpage, u'song name', fatal=False)
  147. video_title = self._html_search_regex(r'<meta name="mtv_an" content="([^"]+)"/>',
  148. webpage, u'title')
  149. mtvn_uri = self._html_search_regex(r'<meta name="mtvn_uri" content="([^"]+)"/>',
  150. webpage, u'mtvn_uri', fatal=False)
  151. content_id = self._search_regex(r'MTVN.Player.defaultPlaylistId = ([0-9]+);',
  152. webpage, u'content id', fatal=False)
  153. 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
  154. self.report_extraction(video_id)
  155. request = compat_urllib_request.Request(videogen_url)
  156. try:
  157. metadataXml = compat_urllib_request.urlopen(request).read()
  158. except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
  159. raise ExtractorError(u'Unable to download video metadata: %s' % compat_str(err))
  160. mdoc = xml.etree.ElementTree.fromstring(metadataXml)
  161. renditions = mdoc.findall('.//rendition')
  162. # For now, always pick the highest quality.
  163. rendition = renditions[-1]
  164. try:
  165. _,_,ext = rendition.attrib['type'].partition('/')
  166. format = ext + '-' + rendition.attrib['width'] + 'x' + rendition.attrib['height'] + '_' + rendition.attrib['bitrate']
  167. video_url = rendition.find('./src').text
  168. except KeyError:
  169. raise ExtractorError('Invalid rendition field.')
  170. info = {
  171. 'id': video_id,
  172. 'url': video_url,
  173. 'uploader': performer,
  174. 'upload_date': None,
  175. 'title': video_title,
  176. 'ext': ext,
  177. 'format': format,
  178. }
  179. return [info]
  180. class YoukuIE(InfoExtractor):
  181. _VALID_URL = r'(?:http://)?v\.youku\.com/v_show/id_(?P<ID>[A-Za-z0-9]+)\.html'
  182. def _gen_sid(self):
  183. nowTime = int(time.time() * 1000)
  184. random1 = random.randint(1000,1998)
  185. random2 = random.randint(1000,9999)
  186. return "%d%d%d" %(nowTime,random1,random2)
  187. def _get_file_ID_mix_string(self, seed):
  188. mixed = []
  189. source = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/\:._-1234567890")
  190. seed = float(seed)
  191. for i in range(len(source)):
  192. seed = (seed * 211 + 30031 ) % 65536
  193. index = math.floor(seed / 65536 * len(source) )
  194. mixed.append(source[int(index)])
  195. source.remove(source[int(index)])
  196. #return ''.join(mixed)
  197. return mixed
  198. def _get_file_id(self, fileId, seed):
  199. mixed = self._get_file_ID_mix_string(seed)
  200. ids = fileId.split('*')
  201. realId = []
  202. for ch in ids:
  203. if ch:
  204. realId.append(mixed[int(ch)])
  205. return ''.join(realId)
  206. def _real_extract(self, url):
  207. mobj = re.match(self._VALID_URL, url)
  208. if mobj is None:
  209. raise ExtractorError(u'Invalid URL: %s' % url)
  210. video_id = mobj.group('ID')
  211. info_url = 'http://v.youku.com/player/getPlayList/VideoIDS/' + video_id
  212. jsondata = self._download_webpage(info_url, video_id)
  213. self.report_extraction(video_id)
  214. try:
  215. config = json.loads(jsondata)
  216. video_title = config['data'][0]['title']
  217. seed = config['data'][0]['seed']
  218. format = self._downloader.params.get('format', None)
  219. supported_format = list(config['data'][0]['streamfileids'].keys())
  220. if format is None or format == 'best':
  221. if 'hd2' in supported_format:
  222. format = 'hd2'
  223. else:
  224. format = 'flv'
  225. ext = u'flv'
  226. elif format == 'worst':
  227. format = 'mp4'
  228. ext = u'mp4'
  229. else:
  230. format = 'flv'
  231. ext = u'flv'
  232. fileid = config['data'][0]['streamfileids'][format]
  233. keys = [s['k'] for s in config['data'][0]['segs'][format]]
  234. except (UnicodeDecodeError, ValueError, KeyError):
  235. raise ExtractorError(u'Unable to extract info section')
  236. files_info=[]
  237. sid = self._gen_sid()
  238. fileid = self._get_file_id(fileid, seed)
  239. #column 8,9 of fileid represent the segment number
  240. #fileid[7:9] should be changed
  241. for index, key in enumerate(keys):
  242. temp_fileid = '%s%02X%s' % (fileid[0:8], index, fileid[10:])
  243. download_url = 'http://f.youku.com/player/getFlvPath/sid/%s_%02X/st/flv/fileid/%s?k=%s' % (sid, index, temp_fileid, key)
  244. info = {
  245. 'id': '%s_part%02d' % (video_id, index),
  246. 'url': download_url,
  247. 'uploader': None,
  248. 'upload_date': None,
  249. 'title': video_title,
  250. 'ext': ext,
  251. }
  252. files_info.append(info)
  253. return files_info
  254. class XNXXIE(InfoExtractor):
  255. """Information extractor for xnxx.com"""
  256. _VALID_URL = r'^(?:https?://)?video\.xnxx\.com/video([0-9]+)/(.*)'
  257. IE_NAME = u'xnxx'
  258. VIDEO_URL_RE = r'flv_url=(.*?)&amp;'
  259. VIDEO_TITLE_RE = r'<title>(.*?)\s+-\s+XNXX.COM'
  260. VIDEO_THUMB_RE = r'url_bigthumb=(.*?)&amp;'
  261. def _real_extract(self, url):
  262. mobj = re.match(self._VALID_URL, url)
  263. if mobj is None:
  264. raise ExtractorError(u'Invalid URL: %s' % url)
  265. video_id = mobj.group(1)
  266. # Get webpage content
  267. webpage = self._download_webpage(url, video_id)
  268. video_url = self._search_regex(self.VIDEO_URL_RE,
  269. webpage, u'video URL')
  270. video_url = compat_urllib_parse.unquote(video_url)
  271. video_title = self._html_search_regex(self.VIDEO_TITLE_RE,
  272. webpage, u'title')
  273. video_thumbnail = self._search_regex(self.VIDEO_THUMB_RE,
  274. webpage, u'thumbnail', fatal=False)
  275. return [{
  276. 'id': video_id,
  277. 'url': video_url,
  278. 'uploader': None,
  279. 'upload_date': None,
  280. 'title': video_title,
  281. 'ext': 'flv',
  282. 'thumbnail': video_thumbnail,
  283. 'description': None,
  284. }]
  285. class NBAIE(InfoExtractor):
  286. _VALID_URL = r'^(?:https?://)?(?:watch\.|www\.)?nba\.com/(?:nba/)?video(/[^?]*?)(?:/index\.html)?(?:\?.*)?$'
  287. IE_NAME = u'nba'
  288. def _real_extract(self, url):
  289. mobj = re.match(self._VALID_URL, url)
  290. if mobj is None:
  291. raise ExtractorError(u'Invalid URL: %s' % url)
  292. video_id = mobj.group(1)
  293. webpage = self._download_webpage(url, video_id)
  294. video_url = u'http://ht-mobile.cdn.turner.com/nba/big' + video_id + '_nba_1280x720.mp4'
  295. shortened_video_id = video_id.rpartition('/')[2]
  296. title = self._html_search_regex(r'<meta property="og:title" content="(.*?)"',
  297. webpage, 'title', default=shortened_video_id).replace('NBA.com: ', '')
  298. # It isn't there in the HTML it returns to us
  299. # uploader_date = self._html_search_regex(r'<b>Date:</b> (.*?)</div>', webpage, 'upload_date', fatal=False)
  300. description = self._html_search_regex(r'<meta name="description" (?:content|value)="(.*?)" />', webpage, 'description', fatal=False)
  301. info = {
  302. 'id': shortened_video_id,
  303. 'url': video_url,
  304. 'ext': 'mp4',
  305. 'title': title,
  306. # 'uploader_date': uploader_date,
  307. 'description': description,
  308. }
  309. return [info]
  310. class JustinTVIE(InfoExtractor):
  311. """Information extractor for justin.tv and twitch.tv"""
  312. # TODO: One broadcast may be split into multiple videos. The key
  313. # 'broadcast_id' is the same for all parts, and 'broadcast_part'
  314. # starts at 1 and increases. Can we treat all parts as one video?
  315. _VALID_URL = r"""(?x)^(?:http://)?(?:www\.)?(?:twitch|justin)\.tv/
  316. (?:
  317. (?P<channelid>[^/]+)|
  318. (?:(?:[^/]+)/b/(?P<videoid>[^/]+))|
  319. (?:(?:[^/]+)/c/(?P<chapterid>[^/]+))
  320. )
  321. /?(?:\#.*)?$
  322. """
  323. _JUSTIN_PAGE_LIMIT = 100
  324. IE_NAME = u'justin.tv'
  325. def report_download_page(self, channel, offset):
  326. """Report attempt to download a single page of videos."""
  327. self.to_screen(u'%s: Downloading video information from %d to %d' %
  328. (channel, offset, offset + self._JUSTIN_PAGE_LIMIT))
  329. # Return count of items, list of *valid* items
  330. def _parse_page(self, url, video_id):
  331. webpage = self._download_webpage(url, video_id,
  332. u'Downloading video info JSON',
  333. u'unable to download video info JSON')
  334. response = json.loads(webpage)
  335. if type(response) != list:
  336. error_text = response.get('error', 'unknown error')
  337. raise ExtractorError(u'Justin.tv API: %s' % error_text)
  338. info = []
  339. for clip in response:
  340. video_url = clip['video_file_url']
  341. if video_url:
  342. video_extension = os.path.splitext(video_url)[1][1:]
  343. video_date = re.sub('-', '', clip['start_time'][:10])
  344. video_uploader_id = clip.get('user_id', clip.get('channel_id'))
  345. video_id = clip['id']
  346. video_title = clip.get('title', video_id)
  347. info.append({
  348. 'id': video_id,
  349. 'url': video_url,
  350. 'title': video_title,
  351. 'uploader': clip.get('channel_name', video_uploader_id),
  352. 'uploader_id': video_uploader_id,
  353. 'upload_date': video_date,
  354. 'ext': video_extension,
  355. })
  356. return (len(response), info)
  357. def _real_extract(self, url):
  358. mobj = re.match(self._VALID_URL, url)
  359. if mobj is None:
  360. raise ExtractorError(u'invalid URL: %s' % url)
  361. api_base = 'http://api.justin.tv'
  362. paged = False
  363. if mobj.group('channelid'):
  364. paged = True
  365. video_id = mobj.group('channelid')
  366. api = api_base + '/channel/archives/%s.json' % video_id
  367. elif mobj.group('chapterid'):
  368. chapter_id = mobj.group('chapterid')
  369. webpage = self._download_webpage(url, chapter_id)
  370. m = re.search(r'PP\.archive_id = "([0-9]+)";', webpage)
  371. if not m:
  372. raise ExtractorError(u'Cannot find archive of a chapter')
  373. archive_id = m.group(1)
  374. api = api_base + '/broadcast/by_chapter/%s.xml' % chapter_id
  375. chapter_info_xml = self._download_webpage(api, chapter_id,
  376. note=u'Downloading chapter information',
  377. errnote=u'Chapter information download failed')
  378. doc = xml.etree.ElementTree.fromstring(chapter_info_xml)
  379. for a in doc.findall('.//archive'):
  380. if archive_id == a.find('./id').text:
  381. break
  382. else:
  383. raise ExtractorError(u'Could not find chapter in chapter information')
  384. video_url = a.find('./video_file_url').text
  385. video_ext = video_url.rpartition('.')[2] or u'flv'
  386. chapter_api_url = u'https://api.twitch.tv/kraken/videos/c' + chapter_id
  387. chapter_info_json = self._download_webpage(chapter_api_url, u'c' + chapter_id,
  388. note='Downloading chapter metadata',
  389. errnote='Download of chapter metadata failed')
  390. chapter_info = json.loads(chapter_info_json)
  391. bracket_start = int(doc.find('.//bracket_start').text)
  392. bracket_end = int(doc.find('.//bracket_end').text)
  393. # TODO determine start (and probably fix up file)
  394. # youtube-dl -v http://www.twitch.tv/firmbelief/c/1757457
  395. #video_url += u'?start=' + TODO:start_timestamp
  396. # bracket_start is 13290, but we want 51670615
  397. self._downloader.report_warning(u'Chapter detected, but we can just download the whole file. '
  398. u'Chapter starts at %s and ends at %s' % (formatSeconds(bracket_start), formatSeconds(bracket_end)))
  399. info = {
  400. 'id': u'c' + chapter_id,
  401. 'url': video_url,
  402. 'ext': video_ext,
  403. 'title': chapter_info['title'],
  404. 'thumbnail': chapter_info['preview'],
  405. 'description': chapter_info['description'],
  406. 'uploader': chapter_info['channel']['display_name'],
  407. 'uploader_id': chapter_info['channel']['name'],
  408. }
  409. return [info]
  410. else:
  411. video_id = mobj.group('videoid')
  412. api = api_base + '/broadcast/by_archive/%s.json' % video_id
  413. self.report_extraction(video_id)
  414. info = []
  415. offset = 0
  416. limit = self._JUSTIN_PAGE_LIMIT
  417. while True:
  418. if paged:
  419. self.report_download_page(video_id, offset)
  420. page_url = api + ('?offset=%d&limit=%d' % (offset, limit))
  421. page_count, page_info = self._parse_page(page_url, video_id)
  422. info.extend(page_info)
  423. if not paged or page_count != limit:
  424. break
  425. offset += limit
  426. return info
  427. class FunnyOrDieIE(InfoExtractor):
  428. _VALID_URL = r'^(?:https?://)?(?:www\.)?funnyordie\.com/videos/(?P<id>[0-9a-f]+)/.*$'
  429. def _real_extract(self, url):
  430. mobj = re.match(self._VALID_URL, url)
  431. if mobj is None:
  432. raise ExtractorError(u'invalid URL: %s' % url)
  433. video_id = mobj.group('id')
  434. webpage = self._download_webpage(url, video_id)
  435. video_url = self._html_search_regex(r'<video[^>]*>\s*<source[^>]*>\s*<source src="(?P<url>[^"]+)"',
  436. webpage, u'video URL', flags=re.DOTALL)
  437. title = self._html_search_regex((r"<h1 class='player_page_h1'.*?>(?P<title>.*?)</h1>",
  438. r'<title>(?P<title>[^<]+?)</title>'), webpage, 'title', flags=re.DOTALL)
  439. video_description = self._html_search_regex(r'<meta property="og:description" content="(?P<desc>.*?)"',
  440. webpage, u'description', fatal=False, flags=re.DOTALL)
  441. info = {
  442. 'id': video_id,
  443. 'url': video_url,
  444. 'ext': 'mp4',
  445. 'title': title,
  446. 'description': video_description,
  447. }
  448. return [info]
  449. class SteamIE(InfoExtractor):
  450. _VALID_URL = r"""http://store\.steampowered\.com/
  451. (agecheck/)?
  452. (?P<urltype>video|app)/ #If the page is only for videos or for a game
  453. (?P<gameID>\d+)/?
  454. (?P<videoID>\d*)(?P<extra>\??) #For urltype == video we sometimes get the videoID
  455. """
  456. _VIDEO_PAGE_TEMPLATE = 'http://store.steampowered.com/video/%s/'
  457. _AGECHECK_TEMPLATE = 'http://store.steampowered.com/agecheck/video/%s/?snr=1_agecheck_agecheck__age-gate&ageDay=1&ageMonth=January&ageYear=1970'
  458. @classmethod
  459. def suitable(cls, url):
  460. """Receives a URL and returns True if suitable for this IE."""
  461. return re.match(cls._VALID_URL, url, re.VERBOSE) is not None
  462. def _real_extract(self, url):
  463. m = re.match(self._VALID_URL, url, re.VERBOSE)
  464. gameID = m.group('gameID')
  465. videourl = self._VIDEO_PAGE_TEMPLATE % gameID
  466. webpage = self._download_webpage(videourl, gameID)
  467. if re.search('<h2>Please enter your birth date to continue:</h2>', webpage) is not None:
  468. videourl = self._AGECHECK_TEMPLATE % gameID
  469. self.report_age_confirmation()
  470. webpage = self._download_webpage(videourl, gameID)
  471. self.report_extraction(gameID)
  472. game_title = self._html_search_regex(r'<h2 class="pageheader">(.*?)</h2>',
  473. webpage, 'game title')
  474. urlRE = r"'movie_(?P<videoID>\d+)': \{\s*FILENAME: \"(?P<videoURL>[\w:/\.\?=]+)\"(,\s*MOVIE_NAME: \"(?P<videoName>[\w:/\.\?=\+-]+)\")?\s*\},"
  475. mweb = re.finditer(urlRE, webpage)
  476. namesRE = r'<span class="title">(?P<videoName>.+?)</span>'
  477. titles = re.finditer(namesRE, webpage)
  478. thumbsRE = r'<img class="movie_thumb" src="(?P<thumbnail>.+?)">'
  479. thumbs = re.finditer(thumbsRE, webpage)
  480. videos = []
  481. for vid,vtitle,thumb in zip(mweb,titles,thumbs):
  482. video_id = vid.group('videoID')
  483. title = vtitle.group('videoName')
  484. video_url = vid.group('videoURL')
  485. video_thumb = thumb.group('thumbnail')
  486. if not video_url:
  487. raise ExtractorError(u'Cannot find video url for %s' % video_id)
  488. info = {
  489. 'id':video_id,
  490. 'url':video_url,
  491. 'ext': 'flv',
  492. 'title': unescapeHTML(title),
  493. 'thumbnail': video_thumb
  494. }
  495. videos.append(info)
  496. return [self.playlist_result(videos, gameID, game_title)]
  497. class UstreamIE(InfoExtractor):
  498. _VALID_URL = r'https?://www\.ustream\.tv/recorded/(?P<videoID>\d+)'
  499. IE_NAME = u'ustream'
  500. def _real_extract(self, url):
  501. m = re.match(self._VALID_URL, url)
  502. video_id = m.group('videoID')
  503. video_url = u'http://tcdn.ustream.tv/video/%s' % video_id
  504. webpage = self._download_webpage(url, video_id)
  505. self.report_extraction(video_id)
  506. video_title = self._html_search_regex(r'data-title="(?P<title>.+)"',
  507. webpage, u'title')
  508. uploader = self._html_search_regex(r'data-content-type="channel".*?>(?P<uploader>.*?)</a>',
  509. webpage, u'uploader', fatal=False, flags=re.DOTALL)
  510. thumbnail = self._html_search_regex(r'<link rel="image_src" href="(?P<thumb>.*?)"',
  511. webpage, u'thumbnail', fatal=False)
  512. info = {
  513. 'id': video_id,
  514. 'url': video_url,
  515. 'ext': 'flv',
  516. 'title': video_title,
  517. 'uploader': uploader,
  518. 'thumbnail': thumbnail,
  519. }
  520. return info
  521. class WorldStarHipHopIE(InfoExtractor):
  522. _VALID_URL = r'https?://(?:www|m)\.worldstar(?:candy|hiphop)\.com/videos/video\.php\?v=(?P<id>.*)'
  523. IE_NAME = u'WorldStarHipHop'
  524. def _real_extract(self, url):
  525. m = re.match(self._VALID_URL, url)
  526. video_id = m.group('id')
  527. webpage_src = self._download_webpage(url, video_id)
  528. video_url = self._search_regex(r'so\.addVariable\("file","(.*?)"\)',
  529. webpage_src, u'video URL')
  530. if 'mp4' in video_url:
  531. ext = 'mp4'
  532. else:
  533. ext = 'flv'
  534. video_title = self._html_search_regex(r"<title>(.*)</title>",
  535. webpage_src, u'title')
  536. # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
  537. thumbnail = self._html_search_regex(r'rel="image_src" href="(.*)" />',
  538. webpage_src, u'thumbnail', fatal=False)
  539. if not thumbnail:
  540. _title = r"""candytitles.*>(.*)</span>"""
  541. mobj = re.search(_title, webpage_src)
  542. if mobj is not None:
  543. video_title = mobj.group(1)
  544. results = [{
  545. 'id': video_id,
  546. 'url' : video_url,
  547. 'title' : video_title,
  548. 'thumbnail' : thumbnail,
  549. 'ext' : ext,
  550. }]
  551. return results
  552. class RBMARadioIE(InfoExtractor):
  553. _VALID_URL = r'https?://(?:www\.)?rbmaradio\.com/shows/(?P<videoID>[^/]+)$'
  554. def _real_extract(self, url):
  555. m = re.match(self._VALID_URL, url)
  556. video_id = m.group('videoID')
  557. webpage = self._download_webpage(url, video_id)
  558. json_data = self._search_regex(r'window\.gon.*?gon\.show=(.+?);$',
  559. webpage, u'json data', flags=re.MULTILINE)
  560. try:
  561. data = json.loads(json_data)
  562. except ValueError as e:
  563. raise ExtractorError(u'Invalid JSON: ' + str(e))
  564. video_url = data['akamai_url'] + '&cbr=256'
  565. url_parts = compat_urllib_parse_urlparse(video_url)
  566. video_ext = url_parts.path.rpartition('.')[2]
  567. info = {
  568. 'id': video_id,
  569. 'url': video_url,
  570. 'ext': video_ext,
  571. 'title': data['title'],
  572. 'description': data.get('teaser_text'),
  573. 'location': data.get('country_of_origin'),
  574. 'uploader': data.get('host', {}).get('name'),
  575. 'uploader_id': data.get('host', {}).get('slug'),
  576. 'thumbnail': data.get('image', {}).get('large_url_2x'),
  577. 'duration': data.get('duration'),
  578. }
  579. return [info]
  580. class YouPornIE(InfoExtractor):
  581. """Information extractor for youporn.com."""
  582. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?youporn\.com/watch/(?P<videoid>[0-9]+)/(?P<title>[^/]+)'
  583. def _print_formats(self, formats):
  584. """Print all available formats"""
  585. print(u'Available formats:')
  586. print(u'ext\t\tformat')
  587. print(u'---------------------------------')
  588. for format in formats:
  589. print(u'%s\t\t%s' % (format['ext'], format['format']))
  590. def _specific(self, req_format, formats):
  591. for x in formats:
  592. if(x["format"]==req_format):
  593. return x
  594. return None
  595. def _real_extract(self, url):
  596. mobj = re.match(self._VALID_URL, url)
  597. if mobj is None:
  598. raise ExtractorError(u'Invalid URL: %s' % url)
  599. video_id = mobj.group('videoid')
  600. req = compat_urllib_request.Request(url)
  601. req.add_header('Cookie', 'age_verified=1')
  602. webpage = self._download_webpage(req, video_id)
  603. # Get JSON parameters
  604. json_params = self._search_regex(r'var currentVideo = new Video\((.*)\);', webpage, u'JSON parameters')
  605. try:
  606. params = json.loads(json_params)
  607. except:
  608. raise ExtractorError(u'Invalid JSON')
  609. self.report_extraction(video_id)
  610. try:
  611. video_title = params['title']
  612. upload_date = unified_strdate(params['release_date_f'])
  613. video_description = params['description']
  614. video_uploader = params['submitted_by']
  615. thumbnail = params['thumbnails'][0]['image']
  616. except KeyError:
  617. raise ExtractorError('Missing JSON parameter: ' + sys.exc_info()[1])
  618. # Get all of the formats available
  619. DOWNLOAD_LIST_RE = r'(?s)<ul class="downloadList">(?P<download_list>.*?)</ul>'
  620. download_list_html = self._search_regex(DOWNLOAD_LIST_RE,
  621. webpage, u'download list').strip()
  622. # Get all of the links from the page
  623. LINK_RE = r'(?s)<a href="(?P<url>[^"]+)">'
  624. links = re.findall(LINK_RE, download_list_html)
  625. if(len(links) == 0):
  626. raise ExtractorError(u'ERROR: no known formats available for video')
  627. self.to_screen(u'Links found: %d' % len(links))
  628. formats = []
  629. for link in links:
  630. # A link looks like this:
  631. # 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
  632. # A path looks like this:
  633. # /201210/31/8004515/480p_370k_8004515/YouPorn%20-%20Nubile%20Films%20The%20Pillow%20Fight.mp4
  634. video_url = unescapeHTML( link )
  635. path = compat_urllib_parse_urlparse( video_url ).path
  636. extension = os.path.splitext( path )[1][1:]
  637. format = path.split('/')[4].split('_')[:2]
  638. size = format[0]
  639. bitrate = format[1]
  640. format = "-".join( format )
  641. # title = u'%s-%s-%s' % (video_title, size, bitrate)
  642. formats.append({
  643. 'id': video_id,
  644. 'url': video_url,
  645. 'uploader': video_uploader,
  646. 'upload_date': upload_date,
  647. 'title': video_title,
  648. 'ext': extension,
  649. 'format': format,
  650. 'thumbnail': thumbnail,
  651. 'description': video_description
  652. })
  653. if self._downloader.params.get('listformats', None):
  654. self._print_formats(formats)
  655. return
  656. req_format = self._downloader.params.get('format', None)
  657. self.to_screen(u'Format: %s' % req_format)
  658. if req_format is None or req_format == 'best':
  659. return [formats[0]]
  660. elif req_format == 'worst':
  661. return [formats[-1]]
  662. elif req_format in ('-1', 'all'):
  663. return formats
  664. else:
  665. format = self._specific( req_format, formats )
  666. if result is None:
  667. raise ExtractorError(u'Requested format not available')
  668. return [format]
  669. class PornotubeIE(InfoExtractor):
  670. """Information extractor for pornotube.com."""
  671. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?pornotube\.com(/c/(?P<channel>[0-9]+))?(/m/(?P<videoid>[0-9]+))(/(?P<title>.+))$'
  672. def _real_extract(self, url):
  673. mobj = re.match(self._VALID_URL, url)
  674. if mobj is None:
  675. raise ExtractorError(u'Invalid URL: %s' % url)
  676. video_id = mobj.group('videoid')
  677. video_title = mobj.group('title')
  678. # Get webpage content
  679. webpage = self._download_webpage(url, video_id)
  680. # Get the video URL
  681. VIDEO_URL_RE = r'url: "(?P<url>http://video[0-9].pornotube.com/.+\.flv)",'
  682. video_url = self._search_regex(VIDEO_URL_RE, webpage, u'video url')
  683. video_url = compat_urllib_parse.unquote(video_url)
  684. #Get the uploaded date
  685. VIDEO_UPLOADED_RE = r'<div class="video_added_by">Added (?P<date>[0-9\/]+) by'
  686. upload_date = self._html_search_regex(VIDEO_UPLOADED_RE, webpage, u'upload date', fatal=False)
  687. if upload_date: upload_date = unified_strdate(upload_date)
  688. info = {'id': video_id,
  689. 'url': video_url,
  690. 'uploader': None,
  691. 'upload_date': upload_date,
  692. 'title': video_title,
  693. 'ext': 'flv',
  694. 'format': 'flv'}
  695. return [info]
  696. class YouJizzIE(InfoExtractor):
  697. """Information extractor for youjizz.com."""
  698. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?youjizz\.com/videos/(?P<videoid>[^.]+).html$'
  699. def _real_extract(self, url):
  700. mobj = re.match(self._VALID_URL, url)
  701. if mobj is None:
  702. raise ExtractorError(u'Invalid URL: %s' % url)
  703. video_id = mobj.group('videoid')
  704. # Get webpage content
  705. webpage = self._download_webpage(url, video_id)
  706. # Get the video title
  707. video_title = self._html_search_regex(r'<title>(?P<title>.*)</title>',
  708. webpage, u'title').strip()
  709. # Get the embed page
  710. result = re.search(r'https?://www.youjizz.com/videos/embed/(?P<videoid>[0-9]+)', webpage)
  711. if result is None:
  712. raise ExtractorError(u'ERROR: unable to extract embed page')
  713. embed_page_url = result.group(0).strip()
  714. video_id = result.group('videoid')
  715. webpage = self._download_webpage(embed_page_url, video_id)
  716. # Get the video URL
  717. video_url = self._search_regex(r'so.addVariable\("file",encodeURIComponent\("(?P<source>[^"]+)"\)\);',
  718. webpage, u'video URL')
  719. info = {'id': video_id,
  720. 'url': video_url,
  721. 'title': video_title,
  722. 'ext': 'flv',
  723. 'format': 'flv',
  724. 'player_url': embed_page_url}
  725. return [info]
  726. class EightTracksIE(InfoExtractor):
  727. IE_NAME = '8tracks'
  728. _VALID_URL = r'https?://8tracks.com/(?P<user>[^/]+)/(?P<id>[^/#]+)(?:#.*)?$'
  729. def _real_extract(self, url):
  730. mobj = re.match(self._VALID_URL, url)
  731. if mobj is None:
  732. raise ExtractorError(u'Invalid URL: %s' % url)
  733. playlist_id = mobj.group('id')
  734. webpage = self._download_webpage(url, playlist_id)
  735. json_like = self._search_regex(r"PAGE.mix = (.*?);\n", webpage, u'trax information', flags=re.DOTALL)
  736. data = json.loads(json_like)
  737. session = str(random.randint(0, 1000000000))
  738. mix_id = data['id']
  739. track_count = data['tracks_count']
  740. first_url = 'http://8tracks.com/sets/%s/play?player=sm&mix_id=%s&format=jsonh' % (session, mix_id)
  741. next_url = first_url
  742. res = []
  743. for i in itertools.count():
  744. api_json = self._download_webpage(next_url, playlist_id,
  745. note=u'Downloading song information %s/%s' % (str(i+1), track_count),
  746. errnote=u'Failed to download song information')
  747. api_data = json.loads(api_json)
  748. track_data = api_data[u'set']['track']
  749. info = {
  750. 'id': track_data['id'],
  751. 'url': track_data['track_file_stream_url'],
  752. 'title': track_data['performer'] + u' - ' + track_data['name'],
  753. 'raw_title': track_data['name'],
  754. 'uploader_id': data['user']['login'],
  755. 'ext': 'm4a',
  756. }
  757. res.append(info)
  758. if api_data['set']['at_last_track']:
  759. break
  760. next_url = 'http://8tracks.com/sets/%s/next?player=sm&mix_id=%s&format=jsonh&track_id=%s' % (session, mix_id, track_data['id'])
  761. return res
  762. class KeekIE(InfoExtractor):
  763. _VALID_URL = r'http://(?:www\.)?keek\.com/(?:!|\w+/keeks/)(?P<videoID>\w+)'
  764. IE_NAME = u'keek'
  765. def _real_extract(self, url):
  766. m = re.match(self._VALID_URL, url)
  767. video_id = m.group('videoID')
  768. video_url = u'http://cdn.keek.com/keek/video/%s' % video_id
  769. thumbnail = u'http://cdn.keek.com/keek/thumbnail/%s/w100/h75' % video_id
  770. webpage = self._download_webpage(url, video_id)
  771. video_title = self._html_search_regex(r'<meta property="og:title" content="(?P<title>.*?)"',
  772. webpage, u'title')
  773. uploader = self._html_search_regex(r'<div class="user-name-and-bio">[\S\s]+?<h2>(?P<uploader>.+?)</h2>',
  774. webpage, u'uploader', fatal=False)
  775. info = {
  776. 'id': video_id,
  777. 'url': video_url,
  778. 'ext': 'mp4',
  779. 'title': video_title,
  780. 'thumbnail': thumbnail,
  781. 'uploader': uploader
  782. }
  783. return [info]
  784. class TEDIE(InfoExtractor):
  785. _VALID_URL=r'''http://www\.ted\.com/
  786. (
  787. ((?P<type_playlist>playlists)/(?P<playlist_id>\d+)) # We have a playlist
  788. |
  789. ((?P<type_talk>talks)) # We have a simple talk
  790. )
  791. (/lang/(.*?))? # The url may contain the language
  792. /(?P<name>\w+) # Here goes the name and then ".html"
  793. '''
  794. @classmethod
  795. def suitable(cls, url):
  796. """Receives a URL and returns True if suitable for this IE."""
  797. return re.match(cls._VALID_URL, url, re.VERBOSE) is not None
  798. def _real_extract(self, url):
  799. m=re.match(self._VALID_URL, url, re.VERBOSE)
  800. if m.group('type_talk'):
  801. return [self._talk_info(url)]
  802. else :
  803. playlist_id=m.group('playlist_id')
  804. name=m.group('name')
  805. self.to_screen(u'Getting info of playlist %s: "%s"' % (playlist_id,name))
  806. return [self._playlist_videos_info(url,name,playlist_id)]
  807. def _playlist_videos_info(self,url,name,playlist_id=0):
  808. '''Returns the videos of the playlist'''
  809. video_RE=r'''
  810. <li\ id="talk_(\d+)"([.\s]*?)data-id="(?P<video_id>\d+)"
  811. ([.\s]*?)data-playlist_item_id="(\d+)"
  812. ([.\s]*?)data-mediaslug="(?P<mediaSlug>.+?)"
  813. '''
  814. video_name_RE=r'<p\ class="talk-title"><a href="(?P<talk_url>/talks/(.+).html)">(?P<fullname>.+?)</a></p>'
  815. webpage=self._download_webpage(url, playlist_id, 'Downloading playlist webpage')
  816. m_videos=re.finditer(video_RE,webpage,re.VERBOSE)
  817. m_names=re.finditer(video_name_RE,webpage)
  818. playlist_title = self._html_search_regex(r'div class="headline">\s*?<h1>\s*?<span>(.*?)</span>',
  819. webpage, 'playlist title')
  820. playlist_entries = []
  821. for m_video, m_name in zip(m_videos,m_names):
  822. video_id=m_video.group('video_id')
  823. talk_url='http://www.ted.com%s' % m_name.group('talk_url')
  824. playlist_entries.append(self.url_result(talk_url, 'TED'))
  825. return self.playlist_result(playlist_entries, playlist_id = playlist_id, playlist_title = playlist_title)
  826. def _talk_info(self, url, video_id=0):
  827. """Return the video for the talk in the url"""
  828. m = re.match(self._VALID_URL, url,re.VERBOSE)
  829. video_name = m.group('name')
  830. webpage = self._download_webpage(url, video_id, 'Downloading \"%s\" page' % video_name)
  831. self.report_extraction(video_name)
  832. # If the url includes the language we get the title translated
  833. title = self._html_search_regex(r'<span id="altHeadline" >(?P<title>.*)</span>',
  834. webpage, 'title')
  835. json_data = self._search_regex(r'<script.*?>var talkDetails = ({.*?})</script>',
  836. webpage, 'json data')
  837. info = json.loads(json_data)
  838. desc = self._html_search_regex(r'<div class="talk-intro">.*?<p.*?>(.*?)</p>',
  839. webpage, 'description', flags = re.DOTALL)
  840. thumbnail = self._search_regex(r'</span>[\s.]*</div>[\s.]*<img src="(.*?)"',
  841. webpage, 'thumbnail')
  842. info = {
  843. 'id': info['id'],
  844. 'url': info['htmlStreams'][-1]['file'],
  845. 'ext': 'mp4',
  846. 'title': title,
  847. 'thumbnail': thumbnail,
  848. 'description': desc,
  849. }
  850. return info
  851. class MySpassIE(InfoExtractor):
  852. _VALID_URL = r'http://www.myspass.de/.*'
  853. def _real_extract(self, url):
  854. META_DATA_URL_TEMPLATE = 'http://www.myspass.de/myspass/includes/apps/video/getvideometadataxml.php?id=%s'
  855. # video id is the last path element of the URL
  856. # usually there is a trailing slash, so also try the second but last
  857. url_path = compat_urllib_parse_urlparse(url).path
  858. url_parent_path, video_id = os.path.split(url_path)
  859. if not video_id:
  860. _, video_id = os.path.split(url_parent_path)
  861. # get metadata
  862. metadata_url = META_DATA_URL_TEMPLATE % video_id
  863. metadata_text = self._download_webpage(metadata_url, video_id)
  864. metadata = xml.etree.ElementTree.fromstring(metadata_text.encode('utf-8'))
  865. # extract values from metadata
  866. url_flv_el = metadata.find('url_flv')
  867. if url_flv_el is None:
  868. raise ExtractorError(u'Unable to extract download url')
  869. video_url = url_flv_el.text
  870. extension = os.path.splitext(video_url)[1][1:]
  871. title_el = metadata.find('title')
  872. if title_el is None:
  873. raise ExtractorError(u'Unable to extract title')
  874. title = title_el.text
  875. format_id_el = metadata.find('format_id')
  876. if format_id_el is None:
  877. format = ext
  878. else:
  879. format = format_id_el.text
  880. description_el = metadata.find('description')
  881. if description_el is not None:
  882. description = description_el.text
  883. else:
  884. description = None
  885. imagePreview_el = metadata.find('imagePreview')
  886. if imagePreview_el is not None:
  887. thumbnail = imagePreview_el.text
  888. else:
  889. thumbnail = None
  890. info = {
  891. 'id': video_id,
  892. 'url': video_url,
  893. 'title': title,
  894. 'ext': extension,
  895. 'format': format,
  896. 'thumbnail': thumbnail,
  897. 'description': description
  898. }
  899. return [info]
  900. class SpiegelIE(InfoExtractor):
  901. _VALID_URL = r'https?://(?:www\.)?spiegel\.de/video/[^/]*-(?P<videoID>[0-9]+)(?:\.html)?(?:#.*)?$'
  902. def _real_extract(self, url):
  903. m = re.match(self._VALID_URL, url)
  904. video_id = m.group('videoID')
  905. webpage = self._download_webpage(url, video_id)
  906. video_title = self._html_search_regex(r'<div class="module-title">(.*?)</div>',
  907. webpage, u'title')
  908. xml_url = u'http://video2.spiegel.de/flash/' + video_id + u'.xml'
  909. xml_code = self._download_webpage(xml_url, video_id,
  910. note=u'Downloading XML', errnote=u'Failed to download XML')
  911. idoc = xml.etree.ElementTree.fromstring(xml_code)
  912. last_type = idoc[-1]
  913. filename = last_type.findall('./filename')[0].text
  914. duration = float(last_type.findall('./duration')[0].text)
  915. video_url = 'http://video2.spiegel.de/flash/' + filename
  916. video_ext = filename.rpartition('.')[2]
  917. info = {
  918. 'id': video_id,
  919. 'url': video_url,
  920. 'ext': video_ext,
  921. 'title': video_title,
  922. 'duration': duration,
  923. }
  924. return [info]
  925. class LiveLeakIE(InfoExtractor):
  926. _VALID_URL = r'^(?:http?://)?(?:\w+\.)?liveleak\.com/view\?(?:.*?)i=(?P<video_id>[\w_]+)(?:.*)'
  927. IE_NAME = u'liveleak'
  928. def _real_extract(self, url):
  929. mobj = re.match(self._VALID_URL, url)
  930. if mobj is None:
  931. raise ExtractorError(u'Invalid URL: %s' % url)
  932. video_id = mobj.group('video_id')
  933. webpage = self._download_webpage(url, video_id)
  934. video_url = self._search_regex(r'file: "(.*?)",',
  935. webpage, u'video URL')
  936. video_title = self._html_search_regex(r'<meta property="og:title" content="(?P<title>.*?)"',
  937. webpage, u'title').replace('LiveLeak.com -', '').strip()
  938. video_description = self._html_search_regex(r'<meta property="og:description" content="(?P<desc>.*?)"',
  939. webpage, u'description', fatal=False)
  940. video_uploader = self._html_search_regex(r'By:.*?(\w+)</a>',
  941. webpage, u'uploader', fatal=False)
  942. info = {
  943. 'id': video_id,
  944. 'url': video_url,
  945. 'ext': 'mp4',
  946. 'title': video_title,
  947. 'description': video_description,
  948. 'uploader': video_uploader
  949. }
  950. return [info]
  951. class TumblrIE(InfoExtractor):
  952. _VALID_URL = r'http://(?P<blog_name>.*?)\.tumblr\.com/((post)|(video))/(?P<id>\d*)/(.*?)'
  953. def _real_extract(self, url):
  954. m_url = re.match(self._VALID_URL, url)
  955. video_id = m_url.group('id')
  956. blog = m_url.group('blog_name')
  957. url = 'http://%s.tumblr.com/post/%s/' % (blog, video_id)
  958. webpage = self._download_webpage(url, video_id)
  959. re_video = r'src=\\x22(?P<video_url>http://%s\.tumblr\.com/video_file/%s/(.*?))\\x22 type=\\x22video/(?P<ext>.*?)\\x22' % (blog, video_id)
  960. video = re.search(re_video, webpage)
  961. if video is None:
  962. raise ExtractorError(u'Unable to extract video')
  963. video_url = video.group('video_url')
  964. ext = video.group('ext')
  965. video_thumbnail = self._search_regex(r'posters(.*?)\[\\x22(?P<thumb>.*?)\\x22',
  966. webpage, u'thumbnail', fatal=False) # We pick the first poster
  967. if video_thumbnail: video_thumbnail = video_thumbnail.replace('\\', '')
  968. # The only place where you can get a title, it's not complete,
  969. # but searching in other places doesn't work for all videos
  970. video_title = self._html_search_regex(r'<title>(?P<title>.*?)</title>',
  971. webpage, u'title', flags=re.DOTALL)
  972. return [{'id': video_id,
  973. 'url': video_url,
  974. 'title': video_title,
  975. 'thumbnail': video_thumbnail,
  976. 'ext': ext
  977. }]
  978. class BandcampIE(InfoExtractor):
  979. _VALID_URL = r'http://.*?\.bandcamp\.com/track/(?P<title>.*)'
  980. def _real_extract(self, url):
  981. mobj = re.match(self._VALID_URL, url)
  982. title = mobj.group('title')
  983. webpage = self._download_webpage(url, title)
  984. # We get the link to the free download page
  985. m_download = re.search(r'freeDownloadPage: "(.*?)"', webpage)
  986. if m_download is None:
  987. raise ExtractorError(u'No free songs found')
  988. download_link = m_download.group(1)
  989. id = re.search(r'var TralbumData = {(.*?)id: (?P<id>\d*?)$',
  990. webpage, re.MULTILINE|re.DOTALL).group('id')
  991. download_webpage = self._download_webpage(download_link, id,
  992. 'Downloading free downloads page')
  993. # We get the dictionary of the track from some javascrip code
  994. info = re.search(r'items: (.*?),$',
  995. download_webpage, re.MULTILINE).group(1)
  996. info = json.loads(info)[0]
  997. # We pick mp3-320 for now, until format selection can be easily implemented.
  998. mp3_info = info[u'downloads'][u'mp3-320']
  999. # If we try to use this url it says the link has expired
  1000. initial_url = mp3_info[u'url']
  1001. re_url = r'(?P<server>http://(.*?)\.bandcamp\.com)/download/track\?enc=mp3-320&fsig=(?P<fsig>.*?)&id=(?P<id>.*?)&ts=(?P<ts>.*)$'
  1002. m_url = re.match(re_url, initial_url)
  1003. #We build the url we will use to get the final track url
  1004. # This url is build in Bandcamp in the script download_bunde_*.js
  1005. 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'))
  1006. final_url_webpage = self._download_webpage(request_url, id, 'Requesting download url')
  1007. # If we could correctly generate the .rand field the url would be
  1008. #in the "download_url" key
  1009. final_url = re.search(r'"retry_url":"(.*?)"', final_url_webpage).group(1)
  1010. track_info = {'id':id,
  1011. 'title' : info[u'title'],
  1012. 'ext' : 'mp3',
  1013. 'url' : final_url,
  1014. 'thumbnail' : info[u'thumb_url'],
  1015. 'uploader' : info[u'artist']
  1016. }
  1017. return [track_info]
  1018. class RedTubeIE(InfoExtractor):
  1019. """Information Extractor for redtube"""
  1020. _VALID_URL = r'(?:http://)?(?:www\.)?redtube\.com/(?P<id>[0-9]+)'
  1021. def _real_extract(self,url):
  1022. mobj = re.match(self._VALID_URL, url)
  1023. if mobj is None:
  1024. raise ExtractorError(u'Invalid URL: %s' % url)
  1025. video_id = mobj.group('id')
  1026. video_extension = 'mp4'
  1027. webpage = self._download_webpage(url, video_id)
  1028. self.report_extraction(video_id)
  1029. video_url = self._html_search_regex(r'<source src="(.+?)" type="video/mp4">',
  1030. webpage, u'video URL')
  1031. video_title = self._html_search_regex('<h1 class="videoTitle slidePanelMovable">(.+?)</h1>',
  1032. webpage, u'title')
  1033. return [{
  1034. 'id': video_id,
  1035. 'url': video_url,
  1036. 'ext': video_extension,
  1037. 'title': video_title,
  1038. }]
  1039. class InaIE(InfoExtractor):
  1040. """Information Extractor for Ina.fr"""
  1041. _VALID_URL = r'(?:http://)?(?:www\.)?ina\.fr/video/(?P<id>I[0-9]+)/.*'
  1042. def _real_extract(self,url):
  1043. mobj = re.match(self._VALID_URL, url)
  1044. video_id = mobj.group('id')
  1045. mrss_url='http://player.ina.fr/notices/%s.mrss' % video_id
  1046. video_extension = 'mp4'
  1047. webpage = self._download_webpage(mrss_url, video_id)
  1048. self.report_extraction(video_id)
  1049. video_url = self._html_search_regex(r'<media:player url="(?P<mp4url>http://mp4.ina.fr/[^"]+\.mp4)',
  1050. webpage, u'video URL')
  1051. video_title = self._search_regex(r'<title><!\[CDATA\[(?P<titre>.*?)]]></title>',
  1052. webpage, u'title')
  1053. return [{
  1054. 'id': video_id,
  1055. 'url': video_url,
  1056. 'ext': video_extension,
  1057. 'title': video_title,
  1058. }]
  1059. class HowcastIE(InfoExtractor):
  1060. """Information Extractor for Howcast.com"""
  1061. _VALID_URL = r'(?:https?://)?(?:www\.)?howcast\.com/videos/(?P<id>\d+)'
  1062. def _real_extract(self, url):
  1063. mobj = re.match(self._VALID_URL, url)
  1064. video_id = mobj.group('id')
  1065. webpage_url = 'http://www.howcast.com/videos/' + video_id
  1066. webpage = self._download_webpage(webpage_url, video_id)
  1067. self.report_extraction(video_id)
  1068. video_url = self._search_regex(r'\'?file\'?: "(http://mobile-media\.howcast\.com/[0-9]+\.mp4)',
  1069. webpage, u'video URL')
  1070. video_title = self._html_search_regex(r'<meta content=(?:"([^"]+)"|\'([^\']+)\') property=\'og:title\'',
  1071. webpage, u'title')
  1072. video_description = self._html_search_regex(r'<meta content=(?:"([^"]+)"|\'([^\']+)\') name=\'description\'',
  1073. webpage, u'description', fatal=False)
  1074. thumbnail = self._html_search_regex(r'<meta content=\'(.+?)\' property=\'og:image\'',
  1075. webpage, u'thumbnail', fatal=False)
  1076. return [{
  1077. 'id': video_id,
  1078. 'url': video_url,
  1079. 'ext': 'mp4',
  1080. 'title': video_title,
  1081. 'description': video_description,
  1082. 'thumbnail': thumbnail,
  1083. }]
  1084. class VineIE(InfoExtractor):
  1085. """Information Extractor for Vine.co"""
  1086. _VALID_URL = r'(?:https?://)?(?:www\.)?vine\.co/v/(?P<id>\w+)'
  1087. def _real_extract(self, url):
  1088. mobj = re.match(self._VALID_URL, url)
  1089. video_id = mobj.group('id')
  1090. webpage_url = 'https://vine.co/v/' + video_id
  1091. webpage = self._download_webpage(webpage_url, video_id)
  1092. self.report_extraction(video_id)
  1093. video_url = self._html_search_regex(r'<meta property="twitter:player:stream" content="(.+?)"',
  1094. webpage, u'video URL')
  1095. video_title = self._html_search_regex(r'<meta property="og:title" content="(.+?)"',
  1096. webpage, u'title')
  1097. thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.+?)(\?.*?)?"',
  1098. webpage, u'thumbnail', fatal=False)
  1099. uploader = self._html_search_regex(r'<div class="user">.*?<h2>(.+?)</h2>',
  1100. webpage, u'uploader', fatal=False, flags=re.DOTALL)
  1101. return [{
  1102. 'id': video_id,
  1103. 'url': video_url,
  1104. 'ext': 'mp4',
  1105. 'title': video_title,
  1106. 'thumbnail': thumbnail,
  1107. 'uploader': uploader,
  1108. }]
  1109. class FlickrIE(InfoExtractor):
  1110. """Information Extractor for Flickr videos"""
  1111. _VALID_URL = r'(?:https?://)?(?:www\.)?flickr\.com/photos/(?P<uploader_id>[\w\-_@]+)/(?P<id>\d+).*'
  1112. def _real_extract(self, url):
  1113. mobj = re.match(self._VALID_URL, url)
  1114. video_id = mobj.group('id')
  1115. video_uploader_id = mobj.group('uploader_id')
  1116. webpage_url = 'http://www.flickr.com/photos/' + video_uploader_id + '/' + video_id
  1117. webpage = self._download_webpage(webpage_url, video_id)
  1118. secret = self._search_regex(r"photo_secret: '(\w+)'", webpage, u'secret')
  1119. first_url = 'https://secure.flickr.com/apps/video/video_mtl_xml.gne?v=x&photo_id=' + video_id + '&secret=' + secret + '&bitrate=700&target=_self'
  1120. first_xml = self._download_webpage(first_url, video_id, 'Downloading first data webpage')
  1121. node_id = self._html_search_regex(r'<Item id="id">(\d+-\d+)</Item>',
  1122. first_xml, u'node_id')
  1123. 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'
  1124. second_xml = self._download_webpage(second_url, video_id, 'Downloading second data webpage')
  1125. self.report_extraction(video_id)
  1126. mobj = re.search(r'<STREAM APP="(.+?)" FULLPATH="(.+?)"', second_xml)
  1127. if mobj is None:
  1128. raise ExtractorError(u'Unable to extract video url')
  1129. video_url = mobj.group(1) + unescapeHTML(mobj.group(2))
  1130. video_title = self._html_search_regex(r'<meta property="og:title" content=(?:"([^"]+)"|\'([^\']+)\')',
  1131. webpage, u'video title')
  1132. video_description = self._html_search_regex(r'<meta property="og:description" content=(?:"([^"]+)"|\'([^\']+)\')',
  1133. webpage, u'description', fatal=False)
  1134. thumbnail = self._html_search_regex(r'<meta property="og:image" content=(?:"([^"]+)"|\'([^\']+)\')',
  1135. webpage, u'thumbnail', fatal=False)
  1136. return [{
  1137. 'id': video_id,
  1138. 'url': video_url,
  1139. 'ext': 'mp4',
  1140. 'title': video_title,
  1141. 'description': video_description,
  1142. 'thumbnail': thumbnail,
  1143. 'uploader_id': video_uploader_id,
  1144. }]
  1145. class TeamcocoIE(InfoExtractor):
  1146. _VALID_URL = r'http://teamcoco\.com/video/(?P<url_title>.*)'
  1147. def _real_extract(self, url):
  1148. mobj = re.match(self._VALID_URL, url)
  1149. if mobj is None:
  1150. raise ExtractorError(u'Invalid URL: %s' % url)
  1151. url_title = mobj.group('url_title')
  1152. webpage = self._download_webpage(url, url_title)
  1153. video_id = self._html_search_regex(r'<article class="video" data-id="(\d+?)"',
  1154. webpage, u'video id')
  1155. self.report_extraction(video_id)
  1156. video_title = self._html_search_regex(r'<meta property="og:title" content="(.+?)"',
  1157. webpage, u'title')
  1158. thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.+?)"',
  1159. webpage, u'thumbnail', fatal=False)
  1160. video_description = self._html_search_regex(r'<meta property="og:description" content="(.*?)"',
  1161. webpage, u'description', fatal=False)
  1162. data_url = 'http://teamcoco.com/cvp/2.0/%s.xml' % video_id
  1163. data = self._download_webpage(data_url, video_id, 'Downloading data webpage')
  1164. video_url = self._html_search_regex(r'<file type="high".*?>(.*?)</file>',
  1165. data, u'video URL')
  1166. return [{
  1167. 'id': video_id,
  1168. 'url': video_url,
  1169. 'ext': 'mp4',
  1170. 'title': video_title,
  1171. 'thumbnail': thumbnail,
  1172. 'description': video_description,
  1173. }]
  1174. class XHamsterIE(InfoExtractor):
  1175. """Information Extractor for xHamster"""
  1176. _VALID_URL = r'(?:http://)?(?:www.)?xhamster\.com/movies/(?P<id>[0-9]+)/.*\.html'
  1177. def _real_extract(self,url):
  1178. mobj = re.match(self._VALID_URL, url)
  1179. video_id = mobj.group('id')
  1180. mrss_url = 'http://xhamster.com/movies/%s/.html' % video_id
  1181. webpage = self._download_webpage(mrss_url, video_id)
  1182. mobj = re.search(r'\'srv\': \'(?P<server>[^\']*)\',\s*\'file\': \'(?P<file>[^\']+)\',', webpage)
  1183. if mobj is None:
  1184. raise ExtractorError(u'Unable to extract media URL')
  1185. if len(mobj.group('server')) == 0:
  1186. video_url = compat_urllib_parse.unquote(mobj.group('file'))
  1187. else:
  1188. video_url = mobj.group('server')+'/key='+mobj.group('file')
  1189. video_extension = video_url.split('.')[-1]
  1190. video_title = self._html_search_regex(r'<title>(?P<title>.+?) - xHamster\.com</title>',
  1191. webpage, u'title')
  1192. # Can't see the description anywhere in the UI
  1193. # video_description = self._html_search_regex(r'<span>Description: </span>(?P<description>[^<]+)',
  1194. # webpage, u'description', fatal=False)
  1195. # if video_description: video_description = unescapeHTML(video_description)
  1196. 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)
  1197. if mobj:
  1198. video_upload_date = mobj.group('upload_date_Y')+mobj.group('upload_date_m')+mobj.group('upload_date_d')
  1199. else:
  1200. video_upload_date = None
  1201. self._downloader.report_warning(u'Unable to extract upload date')
  1202. video_uploader_id = self._html_search_regex(r'<a href=\'/user/[^>]+>(?P<uploader_id>[^<]+)',
  1203. webpage, u'uploader id', default=u'anonymous')
  1204. video_thumbnail = self._search_regex(r'\'image\':\'(?P<thumbnail>[^\']+)\'',
  1205. webpage, u'thumbnail', fatal=False)
  1206. return [{
  1207. 'id': video_id,
  1208. 'url': video_url,
  1209. 'ext': video_extension,
  1210. 'title': video_title,
  1211. # 'description': video_description,
  1212. 'upload_date': video_upload_date,
  1213. 'uploader_id': video_uploader_id,
  1214. 'thumbnail': video_thumbnail
  1215. }]
  1216. class HypemIE(InfoExtractor):
  1217. """Information Extractor for hypem"""
  1218. _VALID_URL = r'(?:http://)?(?:www\.)?hypem\.com/track/([^/]+)/([^/]+)'
  1219. def _real_extract(self, url):
  1220. mobj = re.match(self._VALID_URL, url)
  1221. if mobj is None:
  1222. raise ExtractorError(u'Invalid URL: %s' % url)
  1223. track_id = mobj.group(1)
  1224. data = { 'ax': 1, 'ts': time.time() }
  1225. data_encoded = compat_urllib_parse.urlencode(data)
  1226. complete_url = url + "?" + data_encoded
  1227. request = compat_urllib_request.Request(complete_url)
  1228. response, urlh = self._download_webpage_handle(request, track_id, u'Downloading webpage with the url')
  1229. cookie = urlh.headers.get('Set-Cookie', '')
  1230. self.report_extraction(track_id)
  1231. html_tracks = self._html_search_regex(r'<script type="application/json" id="displayList-data">(.*?)</script>',
  1232. response, u'tracks', flags=re.MULTILINE|re.DOTALL).strip()
  1233. try:
  1234. track_list = json.loads(html_tracks)
  1235. track = track_list[u'tracks'][0]
  1236. except ValueError:
  1237. raise ExtractorError(u'Hypemachine contained invalid JSON.')
  1238. key = track[u"key"]
  1239. track_id = track[u"id"]
  1240. artist = track[u"artist"]
  1241. title = track[u"song"]
  1242. serve_url = "http://hypem.com/serve/source/%s/%s" % (compat_str(track_id), compat_str(key))
  1243. request = compat_urllib_request.Request(serve_url, "" , {'Content-Type': 'application/json'})
  1244. request.add_header('cookie', cookie)
  1245. song_data_json = self._download_webpage(request, track_id, u'Downloading metadata')
  1246. try:
  1247. song_data = json.loads(song_data_json)
  1248. except ValueError:
  1249. raise ExtractorError(u'Hypemachine contained invalid JSON.')
  1250. final_url = song_data[u"url"]
  1251. return [{
  1252. 'id': track_id,
  1253. 'url': final_url,
  1254. 'ext': "mp3",
  1255. 'title': title,
  1256. 'artist': artist,
  1257. }]
  1258. class Vbox7IE(InfoExtractor):
  1259. """Information Extractor for Vbox7"""
  1260. _VALID_URL = r'(?:http://)?(?:www\.)?vbox7\.com/play:([^/]+)'
  1261. def _real_extract(self,url):
  1262. mobj = re.match(self._VALID_URL, url)
  1263. if mobj is None:
  1264. raise ExtractorError(u'Invalid URL: %s' % url)
  1265. video_id = mobj.group(1)
  1266. redirect_page, urlh = self._download_webpage_handle(url, video_id)
  1267. new_location = self._search_regex(r'window\.location = \'(.*)\';', redirect_page, u'redirect location')
  1268. redirect_url = urlh.geturl() + new_location
  1269. webpage = self._download_webpage(redirect_url, video_id, u'Downloading redirect page')
  1270. title = self._html_search_regex(r'<title>(.*)</title>',
  1271. webpage, u'title').split('/')[0].strip()
  1272. ext = "flv"
  1273. info_url = "http://vbox7.com/play/magare.do"
  1274. data = compat_urllib_parse.urlencode({'as3':'1','vid':video_id})
  1275. info_request = compat_urllib_request.Request(info_url, data)
  1276. info_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
  1277. info_response = self._download_webpage(info_request, video_id, u'Downloading info webpage')
  1278. if info_response is None:
  1279. raise ExtractorError(u'Unable to extract the media url')
  1280. (final_url, thumbnail_url) = map(lambda x: x.split('=')[1], info_response.split('&'))
  1281. return [{
  1282. 'id': video_id,
  1283. 'url': final_url,
  1284. 'ext': ext,
  1285. 'title': title,
  1286. 'thumbnail': thumbnail_url,
  1287. }]
  1288. def gen_extractors():
  1289. """ Return a list of an instance of every supported extractor.
  1290. The order does matter; the first extractor matched is the one handling the URL.
  1291. """
  1292. return [
  1293. YoutubePlaylistIE(),
  1294. YoutubeChannelIE(),
  1295. YoutubeUserIE(),
  1296. YoutubeSearchIE(),
  1297. YoutubeIE(),
  1298. MetacafeIE(),
  1299. DailymotionIE(),
  1300. GoogleSearchIE(),
  1301. PhotobucketIE(),
  1302. YahooIE(),
  1303. YahooSearchIE(),
  1304. DepositFilesIE(),
  1305. FacebookIE(),
  1306. BlipTVIE(),
  1307. BlipTVUserIE(),
  1308. VimeoIE(),
  1309. MyVideoIE(),
  1310. ComedyCentralIE(),
  1311. EscapistIE(),
  1312. CollegeHumorIE(),
  1313. XVideosIE(),
  1314. SoundcloudSetIE(),
  1315. SoundcloudIE(),
  1316. InfoQIE(),
  1317. MixcloudIE(),
  1318. StanfordOpenClassroomIE(),
  1319. MTVIE(),
  1320. YoukuIE(),
  1321. XNXXIE(),
  1322. YouJizzIE(),
  1323. PornotubeIE(),
  1324. YouPornIE(),
  1325. GooglePlusIE(),
  1326. ArteTvIE(),
  1327. NBAIE(),
  1328. WorldStarHipHopIE(),
  1329. JustinTVIE(),
  1330. FunnyOrDieIE(),
  1331. SteamIE(),
  1332. UstreamIE(),
  1333. RBMARadioIE(),
  1334. EightTracksIE(),
  1335. KeekIE(),
  1336. TEDIE(),
  1337. MySpassIE(),
  1338. SpiegelIE(),
  1339. LiveLeakIE(),
  1340. ARDIE(),
  1341. ZDFIE(),
  1342. TumblrIE(),
  1343. BandcampIE(),
  1344. RedTubeIE(),
  1345. InaIE(),
  1346. HowcastIE(),
  1347. VineIE(),
  1348. FlickrIE(),
  1349. TeamcocoIE(),
  1350. XHamsterIE(),
  1351. HypemIE(),
  1352. Vbox7IE(),
  1353. GametrailersIE(),
  1354. StatigramIE(),
  1355. GenericIE()
  1356. ]
  1357. def get_info_extractor(ie_name):
  1358. """Returns the info extractor class with the given ie_name"""
  1359. return globals()[ie_name+'IE']