InfoExtractors.py 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216
  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.mixcloud import MixcloudIE
  35. from .extractor.mtv import MTVIE
  36. from .extractor.myvideo import MyVideoIE
  37. from .extractor.nba import NBAIE
  38. from .extractor.statigram import StatigramIE
  39. from .extractor.photobucket import PhotobucketIE
  40. from .extractor.soundcloud import SoundcloudIE, SoundcloudSetIE
  41. from .extractor.stanfordoc import StanfordOpenClassroomIE
  42. from .extractor.steam import SteamIE
  43. from .extractor.ted import TEDIE
  44. from .extractor.vimeo import VimeoIE
  45. from .extractor.xnxx import XNXXIE
  46. from .extractor.xvideos import XVideosIE
  47. from .extractor.yahoo import YahooIE, YahooSearchIE
  48. from .extractor.youku import YoukuIE
  49. from .extractor.youtube import YoutubeIE, YoutubePlaylistIE, YoutubeSearchIE, YoutubeUserIE, YoutubeChannelIE
  50. from .extractor.zdf import ZDFIE
  51. class JustinTVIE(InfoExtractor):
  52. """Information extractor for justin.tv and twitch.tv"""
  53. # TODO: One broadcast may be split into multiple videos. The key
  54. # 'broadcast_id' is the same for all parts, and 'broadcast_part'
  55. # starts at 1 and increases. Can we treat all parts as one video?
  56. _VALID_URL = r"""(?x)^(?:http://)?(?:www\.)?(?:twitch|justin)\.tv/
  57. (?:
  58. (?P<channelid>[^/]+)|
  59. (?:(?:[^/]+)/b/(?P<videoid>[^/]+))|
  60. (?:(?:[^/]+)/c/(?P<chapterid>[^/]+))
  61. )
  62. /?(?:\#.*)?$
  63. """
  64. _JUSTIN_PAGE_LIMIT = 100
  65. IE_NAME = u'justin.tv'
  66. def report_download_page(self, channel, offset):
  67. """Report attempt to download a single page of videos."""
  68. self.to_screen(u'%s: Downloading video information from %d to %d' %
  69. (channel, offset, offset + self._JUSTIN_PAGE_LIMIT))
  70. # Return count of items, list of *valid* items
  71. def _parse_page(self, url, video_id):
  72. webpage = self._download_webpage(url, video_id,
  73. u'Downloading video info JSON',
  74. u'unable to download video info JSON')
  75. response = json.loads(webpage)
  76. if type(response) != list:
  77. error_text = response.get('error', 'unknown error')
  78. raise ExtractorError(u'Justin.tv API: %s' % error_text)
  79. info = []
  80. for clip in response:
  81. video_url = clip['video_file_url']
  82. if video_url:
  83. video_extension = os.path.splitext(video_url)[1][1:]
  84. video_date = re.sub('-', '', clip['start_time'][:10])
  85. video_uploader_id = clip.get('user_id', clip.get('channel_id'))
  86. video_id = clip['id']
  87. video_title = clip.get('title', video_id)
  88. info.append({
  89. 'id': video_id,
  90. 'url': video_url,
  91. 'title': video_title,
  92. 'uploader': clip.get('channel_name', video_uploader_id),
  93. 'uploader_id': video_uploader_id,
  94. 'upload_date': video_date,
  95. 'ext': video_extension,
  96. })
  97. return (len(response), info)
  98. def _real_extract(self, url):
  99. mobj = re.match(self._VALID_URL, url)
  100. if mobj is None:
  101. raise ExtractorError(u'invalid URL: %s' % url)
  102. api_base = 'http://api.justin.tv'
  103. paged = False
  104. if mobj.group('channelid'):
  105. paged = True
  106. video_id = mobj.group('channelid')
  107. api = api_base + '/channel/archives/%s.json' % video_id
  108. elif mobj.group('chapterid'):
  109. chapter_id = mobj.group('chapterid')
  110. webpage = self._download_webpage(url, chapter_id)
  111. m = re.search(r'PP\.archive_id = "([0-9]+)";', webpage)
  112. if not m:
  113. raise ExtractorError(u'Cannot find archive of a chapter')
  114. archive_id = m.group(1)
  115. api = api_base + '/broadcast/by_chapter/%s.xml' % chapter_id
  116. chapter_info_xml = self._download_webpage(api, chapter_id,
  117. note=u'Downloading chapter information',
  118. errnote=u'Chapter information download failed')
  119. doc = xml.etree.ElementTree.fromstring(chapter_info_xml)
  120. for a in doc.findall('.//archive'):
  121. if archive_id == a.find('./id').text:
  122. break
  123. else:
  124. raise ExtractorError(u'Could not find chapter in chapter information')
  125. video_url = a.find('./video_file_url').text
  126. video_ext = video_url.rpartition('.')[2] or u'flv'
  127. chapter_api_url = u'https://api.twitch.tv/kraken/videos/c' + chapter_id
  128. chapter_info_json = self._download_webpage(chapter_api_url, u'c' + chapter_id,
  129. note='Downloading chapter metadata',
  130. errnote='Download of chapter metadata failed')
  131. chapter_info = json.loads(chapter_info_json)
  132. bracket_start = int(doc.find('.//bracket_start').text)
  133. bracket_end = int(doc.find('.//bracket_end').text)
  134. # TODO determine start (and probably fix up file)
  135. # youtube-dl -v http://www.twitch.tv/firmbelief/c/1757457
  136. #video_url += u'?start=' + TODO:start_timestamp
  137. # bracket_start is 13290, but we want 51670615
  138. self._downloader.report_warning(u'Chapter detected, but we can just download the whole file. '
  139. u'Chapter starts at %s and ends at %s' % (formatSeconds(bracket_start), formatSeconds(bracket_end)))
  140. info = {
  141. 'id': u'c' + chapter_id,
  142. 'url': video_url,
  143. 'ext': video_ext,
  144. 'title': chapter_info['title'],
  145. 'thumbnail': chapter_info['preview'],
  146. 'description': chapter_info['description'],
  147. 'uploader': chapter_info['channel']['display_name'],
  148. 'uploader_id': chapter_info['channel']['name'],
  149. }
  150. return [info]
  151. else:
  152. video_id = mobj.group('videoid')
  153. api = api_base + '/broadcast/by_archive/%s.json' % video_id
  154. self.report_extraction(video_id)
  155. info = []
  156. offset = 0
  157. limit = self._JUSTIN_PAGE_LIMIT
  158. while True:
  159. if paged:
  160. self.report_download_page(video_id, offset)
  161. page_url = api + ('?offset=%d&limit=%d' % (offset, limit))
  162. page_count, page_info = self._parse_page(page_url, video_id)
  163. info.extend(page_info)
  164. if not paged or page_count != limit:
  165. break
  166. offset += limit
  167. return info
  168. class FunnyOrDieIE(InfoExtractor):
  169. _VALID_URL = r'^(?:https?://)?(?:www\.)?funnyordie\.com/videos/(?P<id>[0-9a-f]+)/.*$'
  170. def _real_extract(self, url):
  171. mobj = re.match(self._VALID_URL, url)
  172. if mobj is None:
  173. raise ExtractorError(u'invalid URL: %s' % url)
  174. video_id = mobj.group('id')
  175. webpage = self._download_webpage(url, video_id)
  176. video_url = self._html_search_regex(r'<video[^>]*>\s*<source[^>]*>\s*<source src="(?P<url>[^"]+)"',
  177. webpage, u'video URL', flags=re.DOTALL)
  178. title = self._html_search_regex((r"<h1 class='player_page_h1'.*?>(?P<title>.*?)</h1>",
  179. r'<title>(?P<title>[^<]+?)</title>'), webpage, 'title', flags=re.DOTALL)
  180. video_description = self._html_search_regex(r'<meta property="og:description" content="(?P<desc>.*?)"',
  181. webpage, u'description', fatal=False, flags=re.DOTALL)
  182. info = {
  183. 'id': video_id,
  184. 'url': video_url,
  185. 'ext': 'mp4',
  186. 'title': title,
  187. 'description': video_description,
  188. }
  189. return [info]
  190. class UstreamIE(InfoExtractor):
  191. _VALID_URL = r'https?://www\.ustream\.tv/recorded/(?P<videoID>\d+)'
  192. IE_NAME = u'ustream'
  193. def _real_extract(self, url):
  194. m = re.match(self._VALID_URL, url)
  195. video_id = m.group('videoID')
  196. video_url = u'http://tcdn.ustream.tv/video/%s' % video_id
  197. webpage = self._download_webpage(url, video_id)
  198. self.report_extraction(video_id)
  199. video_title = self._html_search_regex(r'data-title="(?P<title>.+)"',
  200. webpage, u'title')
  201. uploader = self._html_search_regex(r'data-content-type="channel".*?>(?P<uploader>.*?)</a>',
  202. webpage, u'uploader', fatal=False, flags=re.DOTALL)
  203. thumbnail = self._html_search_regex(r'<link rel="image_src" href="(?P<thumb>.*?)"',
  204. webpage, u'thumbnail', fatal=False)
  205. info = {
  206. 'id': video_id,
  207. 'url': video_url,
  208. 'ext': 'flv',
  209. 'title': video_title,
  210. 'uploader': uploader,
  211. 'thumbnail': thumbnail,
  212. }
  213. return info
  214. class WorldStarHipHopIE(InfoExtractor):
  215. _VALID_URL = r'https?://(?:www|m)\.worldstar(?:candy|hiphop)\.com/videos/video\.php\?v=(?P<id>.*)'
  216. IE_NAME = u'WorldStarHipHop'
  217. def _real_extract(self, url):
  218. m = re.match(self._VALID_URL, url)
  219. video_id = m.group('id')
  220. webpage_src = self._download_webpage(url, video_id)
  221. video_url = self._search_regex(r'so\.addVariable\("file","(.*?)"\)',
  222. webpage_src, u'video URL')
  223. if 'mp4' in video_url:
  224. ext = 'mp4'
  225. else:
  226. ext = 'flv'
  227. video_title = self._html_search_regex(r"<title>(.*)</title>",
  228. webpage_src, u'title')
  229. # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
  230. thumbnail = self._html_search_regex(r'rel="image_src" href="(.*)" />',
  231. webpage_src, u'thumbnail', fatal=False)
  232. if not thumbnail:
  233. _title = r"""candytitles.*>(.*)</span>"""
  234. mobj = re.search(_title, webpage_src)
  235. if mobj is not None:
  236. video_title = mobj.group(1)
  237. results = [{
  238. 'id': video_id,
  239. 'url' : video_url,
  240. 'title' : video_title,
  241. 'thumbnail' : thumbnail,
  242. 'ext' : ext,
  243. }]
  244. return results
  245. class RBMARadioIE(InfoExtractor):
  246. _VALID_URL = r'https?://(?:www\.)?rbmaradio\.com/shows/(?P<videoID>[^/]+)$'
  247. def _real_extract(self, url):
  248. m = re.match(self._VALID_URL, url)
  249. video_id = m.group('videoID')
  250. webpage = self._download_webpage(url, video_id)
  251. json_data = self._search_regex(r'window\.gon.*?gon\.show=(.+?);$',
  252. webpage, u'json data', flags=re.MULTILINE)
  253. try:
  254. data = json.loads(json_data)
  255. except ValueError as e:
  256. raise ExtractorError(u'Invalid JSON: ' + str(e))
  257. video_url = data['akamai_url'] + '&cbr=256'
  258. url_parts = compat_urllib_parse_urlparse(video_url)
  259. video_ext = url_parts.path.rpartition('.')[2]
  260. info = {
  261. 'id': video_id,
  262. 'url': video_url,
  263. 'ext': video_ext,
  264. 'title': data['title'],
  265. 'description': data.get('teaser_text'),
  266. 'location': data.get('country_of_origin'),
  267. 'uploader': data.get('host', {}).get('name'),
  268. 'uploader_id': data.get('host', {}).get('slug'),
  269. 'thumbnail': data.get('image', {}).get('large_url_2x'),
  270. 'duration': data.get('duration'),
  271. }
  272. return [info]
  273. class YouPornIE(InfoExtractor):
  274. """Information extractor for youporn.com."""
  275. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?youporn\.com/watch/(?P<videoid>[0-9]+)/(?P<title>[^/]+)'
  276. def _print_formats(self, formats):
  277. """Print all available formats"""
  278. print(u'Available formats:')
  279. print(u'ext\t\tformat')
  280. print(u'---------------------------------')
  281. for format in formats:
  282. print(u'%s\t\t%s' % (format['ext'], format['format']))
  283. def _specific(self, req_format, formats):
  284. for x in formats:
  285. if(x["format"]==req_format):
  286. return x
  287. return None
  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('videoid')
  293. req = compat_urllib_request.Request(url)
  294. req.add_header('Cookie', 'age_verified=1')
  295. webpage = self._download_webpage(req, video_id)
  296. # Get JSON parameters
  297. json_params = self._search_regex(r'var currentVideo = new Video\((.*)\);', webpage, u'JSON parameters')
  298. try:
  299. params = json.loads(json_params)
  300. except:
  301. raise ExtractorError(u'Invalid JSON')
  302. self.report_extraction(video_id)
  303. try:
  304. video_title = params['title']
  305. upload_date = unified_strdate(params['release_date_f'])
  306. video_description = params['description']
  307. video_uploader = params['submitted_by']
  308. thumbnail = params['thumbnails'][0]['image']
  309. except KeyError:
  310. raise ExtractorError('Missing JSON parameter: ' + sys.exc_info()[1])
  311. # Get all of the formats available
  312. DOWNLOAD_LIST_RE = r'(?s)<ul class="downloadList">(?P<download_list>.*?)</ul>'
  313. download_list_html = self._search_regex(DOWNLOAD_LIST_RE,
  314. webpage, u'download list').strip()
  315. # Get all of the links from the page
  316. LINK_RE = r'(?s)<a href="(?P<url>[^"]+)">'
  317. links = re.findall(LINK_RE, download_list_html)
  318. if(len(links) == 0):
  319. raise ExtractorError(u'ERROR: no known formats available for video')
  320. self.to_screen(u'Links found: %d' % len(links))
  321. formats = []
  322. for link in links:
  323. # A link looks like this:
  324. # 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
  325. # A path looks like this:
  326. # /201210/31/8004515/480p_370k_8004515/YouPorn%20-%20Nubile%20Films%20The%20Pillow%20Fight.mp4
  327. video_url = unescapeHTML( link )
  328. path = compat_urllib_parse_urlparse( video_url ).path
  329. extension = os.path.splitext( path )[1][1:]
  330. format = path.split('/')[4].split('_')[:2]
  331. size = format[0]
  332. bitrate = format[1]
  333. format = "-".join( format )
  334. # title = u'%s-%s-%s' % (video_title, size, bitrate)
  335. formats.append({
  336. 'id': video_id,
  337. 'url': video_url,
  338. 'uploader': video_uploader,
  339. 'upload_date': upload_date,
  340. 'title': video_title,
  341. 'ext': extension,
  342. 'format': format,
  343. 'thumbnail': thumbnail,
  344. 'description': video_description
  345. })
  346. if self._downloader.params.get('listformats', None):
  347. self._print_formats(formats)
  348. return
  349. req_format = self._downloader.params.get('format', None)
  350. self.to_screen(u'Format: %s' % req_format)
  351. if req_format is None or req_format == 'best':
  352. return [formats[0]]
  353. elif req_format == 'worst':
  354. return [formats[-1]]
  355. elif req_format in ('-1', 'all'):
  356. return formats
  357. else:
  358. format = self._specific( req_format, formats )
  359. if result is None:
  360. raise ExtractorError(u'Requested format not available')
  361. return [format]
  362. class PornotubeIE(InfoExtractor):
  363. """Information extractor for pornotube.com."""
  364. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?pornotube\.com(/c/(?P<channel>[0-9]+))?(/m/(?P<videoid>[0-9]+))(/(?P<title>.+))$'
  365. def _real_extract(self, url):
  366. mobj = re.match(self._VALID_URL, url)
  367. if mobj is None:
  368. raise ExtractorError(u'Invalid URL: %s' % url)
  369. video_id = mobj.group('videoid')
  370. video_title = mobj.group('title')
  371. # Get webpage content
  372. webpage = self._download_webpage(url, video_id)
  373. # Get the video URL
  374. VIDEO_URL_RE = r'url: "(?P<url>http://video[0-9].pornotube.com/.+\.flv)",'
  375. video_url = self._search_regex(VIDEO_URL_RE, webpage, u'video url')
  376. video_url = compat_urllib_parse.unquote(video_url)
  377. #Get the uploaded date
  378. VIDEO_UPLOADED_RE = r'<div class="video_added_by">Added (?P<date>[0-9\/]+) by'
  379. upload_date = self._html_search_regex(VIDEO_UPLOADED_RE, webpage, u'upload date', fatal=False)
  380. if upload_date: upload_date = unified_strdate(upload_date)
  381. info = {'id': video_id,
  382. 'url': video_url,
  383. 'uploader': None,
  384. 'upload_date': upload_date,
  385. 'title': video_title,
  386. 'ext': 'flv',
  387. 'format': 'flv'}
  388. return [info]
  389. class YouJizzIE(InfoExtractor):
  390. """Information extractor for youjizz.com."""
  391. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?youjizz\.com/videos/(?P<videoid>[^.]+).html$'
  392. def _real_extract(self, url):
  393. mobj = re.match(self._VALID_URL, url)
  394. if mobj is None:
  395. raise ExtractorError(u'Invalid URL: %s' % url)
  396. video_id = mobj.group('videoid')
  397. # Get webpage content
  398. webpage = self._download_webpage(url, video_id)
  399. # Get the video title
  400. video_title = self._html_search_regex(r'<title>(?P<title>.*)</title>',
  401. webpage, u'title').strip()
  402. # Get the embed page
  403. result = re.search(r'https?://www.youjizz.com/videos/embed/(?P<videoid>[0-9]+)', webpage)
  404. if result is None:
  405. raise ExtractorError(u'ERROR: unable to extract embed page')
  406. embed_page_url = result.group(0).strip()
  407. video_id = result.group('videoid')
  408. webpage = self._download_webpage(embed_page_url, video_id)
  409. # Get the video URL
  410. video_url = self._search_regex(r'so.addVariable\("file",encodeURIComponent\("(?P<source>[^"]+)"\)\);',
  411. webpage, u'video URL')
  412. info = {'id': video_id,
  413. 'url': video_url,
  414. 'title': video_title,
  415. 'ext': 'flv',
  416. 'format': 'flv',
  417. 'player_url': embed_page_url}
  418. return [info]
  419. class EightTracksIE(InfoExtractor):
  420. IE_NAME = '8tracks'
  421. _VALID_URL = r'https?://8tracks.com/(?P<user>[^/]+)/(?P<id>[^/#]+)(?:#.*)?$'
  422. def _real_extract(self, url):
  423. mobj = re.match(self._VALID_URL, url)
  424. if mobj is None:
  425. raise ExtractorError(u'Invalid URL: %s' % url)
  426. playlist_id = mobj.group('id')
  427. webpage = self._download_webpage(url, playlist_id)
  428. json_like = self._search_regex(r"PAGE.mix = (.*?);\n", webpage, u'trax information', flags=re.DOTALL)
  429. data = json.loads(json_like)
  430. session = str(random.randint(0, 1000000000))
  431. mix_id = data['id']
  432. track_count = data['tracks_count']
  433. first_url = 'http://8tracks.com/sets/%s/play?player=sm&mix_id=%s&format=jsonh' % (session, mix_id)
  434. next_url = first_url
  435. res = []
  436. for i in itertools.count():
  437. api_json = self._download_webpage(next_url, playlist_id,
  438. note=u'Downloading song information %s/%s' % (str(i+1), track_count),
  439. errnote=u'Failed to download song information')
  440. api_data = json.loads(api_json)
  441. track_data = api_data[u'set']['track']
  442. info = {
  443. 'id': track_data['id'],
  444. 'url': track_data['track_file_stream_url'],
  445. 'title': track_data['performer'] + u' - ' + track_data['name'],
  446. 'raw_title': track_data['name'],
  447. 'uploader_id': data['user']['login'],
  448. 'ext': 'm4a',
  449. }
  450. res.append(info)
  451. if api_data['set']['at_last_track']:
  452. break
  453. next_url = 'http://8tracks.com/sets/%s/next?player=sm&mix_id=%s&format=jsonh&track_id=%s' % (session, mix_id, track_data['id'])
  454. return res
  455. class KeekIE(InfoExtractor):
  456. _VALID_URL = r'http://(?:www\.)?keek\.com/(?:!|\w+/keeks/)(?P<videoID>\w+)'
  457. IE_NAME = u'keek'
  458. def _real_extract(self, url):
  459. m = re.match(self._VALID_URL, url)
  460. video_id = m.group('videoID')
  461. video_url = u'http://cdn.keek.com/keek/video/%s' % video_id
  462. thumbnail = u'http://cdn.keek.com/keek/thumbnail/%s/w100/h75' % video_id
  463. webpage = self._download_webpage(url, video_id)
  464. video_title = self._html_search_regex(r'<meta property="og:title" content="(?P<title>.*?)"',
  465. webpage, u'title')
  466. uploader = self._html_search_regex(r'<div class="user-name-and-bio">[\S\s]+?<h2>(?P<uploader>.+?)</h2>',
  467. webpage, u'uploader', fatal=False)
  468. info = {
  469. 'id': video_id,
  470. 'url': video_url,
  471. 'ext': 'mp4',
  472. 'title': video_title,
  473. 'thumbnail': thumbnail,
  474. 'uploader': uploader
  475. }
  476. return [info]
  477. class MySpassIE(InfoExtractor):
  478. _VALID_URL = r'http://www.myspass.de/.*'
  479. def _real_extract(self, url):
  480. META_DATA_URL_TEMPLATE = 'http://www.myspass.de/myspass/includes/apps/video/getvideometadataxml.php?id=%s'
  481. # video id is the last path element of the URL
  482. # usually there is a trailing slash, so also try the second but last
  483. url_path = compat_urllib_parse_urlparse(url).path
  484. url_parent_path, video_id = os.path.split(url_path)
  485. if not video_id:
  486. _, video_id = os.path.split(url_parent_path)
  487. # get metadata
  488. metadata_url = META_DATA_URL_TEMPLATE % video_id
  489. metadata_text = self._download_webpage(metadata_url, video_id)
  490. metadata = xml.etree.ElementTree.fromstring(metadata_text.encode('utf-8'))
  491. # extract values from metadata
  492. url_flv_el = metadata.find('url_flv')
  493. if url_flv_el is None:
  494. raise ExtractorError(u'Unable to extract download url')
  495. video_url = url_flv_el.text
  496. extension = os.path.splitext(video_url)[1][1:]
  497. title_el = metadata.find('title')
  498. if title_el is None:
  499. raise ExtractorError(u'Unable to extract title')
  500. title = title_el.text
  501. format_id_el = metadata.find('format_id')
  502. if format_id_el is None:
  503. format = ext
  504. else:
  505. format = format_id_el.text
  506. description_el = metadata.find('description')
  507. if description_el is not None:
  508. description = description_el.text
  509. else:
  510. description = None
  511. imagePreview_el = metadata.find('imagePreview')
  512. if imagePreview_el is not None:
  513. thumbnail = imagePreview_el.text
  514. else:
  515. thumbnail = None
  516. info = {
  517. 'id': video_id,
  518. 'url': video_url,
  519. 'title': title,
  520. 'ext': extension,
  521. 'format': format,
  522. 'thumbnail': thumbnail,
  523. 'description': description
  524. }
  525. return [info]
  526. class SpiegelIE(InfoExtractor):
  527. _VALID_URL = r'https?://(?:www\.)?spiegel\.de/video/[^/]*-(?P<videoID>[0-9]+)(?:\.html)?(?:#.*)?$'
  528. def _real_extract(self, url):
  529. m = re.match(self._VALID_URL, url)
  530. video_id = m.group('videoID')
  531. webpage = self._download_webpage(url, video_id)
  532. video_title = self._html_search_regex(r'<div class="module-title">(.*?)</div>',
  533. webpage, u'title')
  534. xml_url = u'http://video2.spiegel.de/flash/' + video_id + u'.xml'
  535. xml_code = self._download_webpage(xml_url, video_id,
  536. note=u'Downloading XML', errnote=u'Failed to download XML')
  537. idoc = xml.etree.ElementTree.fromstring(xml_code)
  538. last_type = idoc[-1]
  539. filename = last_type.findall('./filename')[0].text
  540. duration = float(last_type.findall('./duration')[0].text)
  541. video_url = 'http://video2.spiegel.de/flash/' + filename
  542. video_ext = filename.rpartition('.')[2]
  543. info = {
  544. 'id': video_id,
  545. 'url': video_url,
  546. 'ext': video_ext,
  547. 'title': video_title,
  548. 'duration': duration,
  549. }
  550. return [info]
  551. class LiveLeakIE(InfoExtractor):
  552. _VALID_URL = r'^(?:http?://)?(?:\w+\.)?liveleak\.com/view\?(?:.*?)i=(?P<video_id>[\w_]+)(?:.*)'
  553. IE_NAME = u'liveleak'
  554. def _real_extract(self, url):
  555. mobj = re.match(self._VALID_URL, url)
  556. if mobj is None:
  557. raise ExtractorError(u'Invalid URL: %s' % url)
  558. video_id = mobj.group('video_id')
  559. webpage = self._download_webpage(url, video_id)
  560. video_url = self._search_regex(r'file: "(.*?)",',
  561. webpage, u'video URL')
  562. video_title = self._html_search_regex(r'<meta property="og:title" content="(?P<title>.*?)"',
  563. webpage, u'title').replace('LiveLeak.com -', '').strip()
  564. video_description = self._html_search_regex(r'<meta property="og:description" content="(?P<desc>.*?)"',
  565. webpage, u'description', fatal=False)
  566. video_uploader = self._html_search_regex(r'By:.*?(\w+)</a>',
  567. webpage, u'uploader', fatal=False)
  568. info = {
  569. 'id': video_id,
  570. 'url': video_url,
  571. 'ext': 'mp4',
  572. 'title': video_title,
  573. 'description': video_description,
  574. 'uploader': video_uploader
  575. }
  576. return [info]
  577. class TumblrIE(InfoExtractor):
  578. _VALID_URL = r'http://(?P<blog_name>.*?)\.tumblr\.com/((post)|(video))/(?P<id>\d*)/(.*?)'
  579. def _real_extract(self, url):
  580. m_url = re.match(self._VALID_URL, url)
  581. video_id = m_url.group('id')
  582. blog = m_url.group('blog_name')
  583. url = 'http://%s.tumblr.com/post/%s/' % (blog, video_id)
  584. webpage = self._download_webpage(url, video_id)
  585. re_video = r'src=\\x22(?P<video_url>http://%s\.tumblr\.com/video_file/%s/(.*?))\\x22 type=\\x22video/(?P<ext>.*?)\\x22' % (blog, video_id)
  586. video = re.search(re_video, webpage)
  587. if video is None:
  588. raise ExtractorError(u'Unable to extract video')
  589. video_url = video.group('video_url')
  590. ext = video.group('ext')
  591. video_thumbnail = self._search_regex(r'posters(.*?)\[\\x22(?P<thumb>.*?)\\x22',
  592. webpage, u'thumbnail', fatal=False) # We pick the first poster
  593. if video_thumbnail: video_thumbnail = video_thumbnail.replace('\\', '')
  594. # The only place where you can get a title, it's not complete,
  595. # but searching in other places doesn't work for all videos
  596. video_title = self._html_search_regex(r'<title>(?P<title>.*?)</title>',
  597. webpage, u'title', flags=re.DOTALL)
  598. return [{'id': video_id,
  599. 'url': video_url,
  600. 'title': video_title,
  601. 'thumbnail': video_thumbnail,
  602. 'ext': ext
  603. }]
  604. class BandcampIE(InfoExtractor):
  605. _VALID_URL = r'http://.*?\.bandcamp\.com/track/(?P<title>.*)'
  606. def _real_extract(self, url):
  607. mobj = re.match(self._VALID_URL, url)
  608. title = mobj.group('title')
  609. webpage = self._download_webpage(url, title)
  610. # We get the link to the free download page
  611. m_download = re.search(r'freeDownloadPage: "(.*?)"', webpage)
  612. if m_download is None:
  613. raise ExtractorError(u'No free songs found')
  614. download_link = m_download.group(1)
  615. id = re.search(r'var TralbumData = {(.*?)id: (?P<id>\d*?)$',
  616. webpage, re.MULTILINE|re.DOTALL).group('id')
  617. download_webpage = self._download_webpage(download_link, id,
  618. 'Downloading free downloads page')
  619. # We get the dictionary of the track from some javascrip code
  620. info = re.search(r'items: (.*?),$',
  621. download_webpage, re.MULTILINE).group(1)
  622. info = json.loads(info)[0]
  623. # We pick mp3-320 for now, until format selection can be easily implemented.
  624. mp3_info = info[u'downloads'][u'mp3-320']
  625. # If we try to use this url it says the link has expired
  626. initial_url = mp3_info[u'url']
  627. re_url = r'(?P<server>http://(.*?)\.bandcamp\.com)/download/track\?enc=mp3-320&fsig=(?P<fsig>.*?)&id=(?P<id>.*?)&ts=(?P<ts>.*)$'
  628. m_url = re.match(re_url, initial_url)
  629. #We build the url we will use to get the final track url
  630. # This url is build in Bandcamp in the script download_bunde_*.js
  631. 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'))
  632. final_url_webpage = self._download_webpage(request_url, id, 'Requesting download url')
  633. # If we could correctly generate the .rand field the url would be
  634. #in the "download_url" key
  635. final_url = re.search(r'"retry_url":"(.*?)"', final_url_webpage).group(1)
  636. track_info = {'id':id,
  637. 'title' : info[u'title'],
  638. 'ext' : 'mp3',
  639. 'url' : final_url,
  640. 'thumbnail' : info[u'thumb_url'],
  641. 'uploader' : info[u'artist']
  642. }
  643. return [track_info]
  644. class RedTubeIE(InfoExtractor):
  645. """Information Extractor for redtube"""
  646. _VALID_URL = r'(?:http://)?(?:www\.)?redtube\.com/(?P<id>[0-9]+)'
  647. def _real_extract(self,url):
  648. mobj = re.match(self._VALID_URL, url)
  649. if mobj is None:
  650. raise ExtractorError(u'Invalid URL: %s' % url)
  651. video_id = mobj.group('id')
  652. video_extension = 'mp4'
  653. webpage = self._download_webpage(url, video_id)
  654. self.report_extraction(video_id)
  655. video_url = self._html_search_regex(r'<source src="(.+?)" type="video/mp4">',
  656. webpage, u'video URL')
  657. video_title = self._html_search_regex('<h1 class="videoTitle slidePanelMovable">(.+?)</h1>',
  658. webpage, u'title')
  659. return [{
  660. 'id': video_id,
  661. 'url': video_url,
  662. 'ext': video_extension,
  663. 'title': video_title,
  664. }]
  665. class InaIE(InfoExtractor):
  666. """Information Extractor for Ina.fr"""
  667. _VALID_URL = r'(?:http://)?(?:www\.)?ina\.fr/video/(?P<id>I[0-9]+)/.*'
  668. def _real_extract(self,url):
  669. mobj = re.match(self._VALID_URL, url)
  670. video_id = mobj.group('id')
  671. mrss_url='http://player.ina.fr/notices/%s.mrss' % video_id
  672. video_extension = 'mp4'
  673. webpage = self._download_webpage(mrss_url, video_id)
  674. self.report_extraction(video_id)
  675. video_url = self._html_search_regex(r'<media:player url="(?P<mp4url>http://mp4.ina.fr/[^"]+\.mp4)',
  676. webpage, u'video URL')
  677. video_title = self._search_regex(r'<title><!\[CDATA\[(?P<titre>.*?)]]></title>',
  678. webpage, u'title')
  679. return [{
  680. 'id': video_id,
  681. 'url': video_url,
  682. 'ext': video_extension,
  683. 'title': video_title,
  684. }]
  685. class HowcastIE(InfoExtractor):
  686. """Information Extractor for Howcast.com"""
  687. _VALID_URL = r'(?:https?://)?(?:www\.)?howcast\.com/videos/(?P<id>\d+)'
  688. def _real_extract(self, url):
  689. mobj = re.match(self._VALID_URL, url)
  690. video_id = mobj.group('id')
  691. webpage_url = 'http://www.howcast.com/videos/' + video_id
  692. webpage = self._download_webpage(webpage_url, video_id)
  693. self.report_extraction(video_id)
  694. video_url = self._search_regex(r'\'?file\'?: "(http://mobile-media\.howcast\.com/[0-9]+\.mp4)',
  695. webpage, u'video URL')
  696. video_title = self._html_search_regex(r'<meta content=(?:"([^"]+)"|\'([^\']+)\') property=\'og:title\'',
  697. webpage, u'title')
  698. video_description = self._html_search_regex(r'<meta content=(?:"([^"]+)"|\'([^\']+)\') name=\'description\'',
  699. webpage, u'description', fatal=False)
  700. thumbnail = self._html_search_regex(r'<meta content=\'(.+?)\' property=\'og:image\'',
  701. webpage, u'thumbnail', fatal=False)
  702. return [{
  703. 'id': video_id,
  704. 'url': video_url,
  705. 'ext': 'mp4',
  706. 'title': video_title,
  707. 'description': video_description,
  708. 'thumbnail': thumbnail,
  709. }]
  710. class VineIE(InfoExtractor):
  711. """Information Extractor for Vine.co"""
  712. _VALID_URL = r'(?:https?://)?(?:www\.)?vine\.co/v/(?P<id>\w+)'
  713. def _real_extract(self, url):
  714. mobj = re.match(self._VALID_URL, url)
  715. video_id = mobj.group('id')
  716. webpage_url = 'https://vine.co/v/' + video_id
  717. webpage = self._download_webpage(webpage_url, video_id)
  718. self.report_extraction(video_id)
  719. video_url = self._html_search_regex(r'<meta property="twitter:player:stream" content="(.+?)"',
  720. webpage, u'video URL')
  721. video_title = self._html_search_regex(r'<meta property="og:title" content="(.+?)"',
  722. webpage, u'title')
  723. thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.+?)(\?.*?)?"',
  724. webpage, u'thumbnail', fatal=False)
  725. uploader = self._html_search_regex(r'<div class="user">.*?<h2>(.+?)</h2>',
  726. webpage, u'uploader', fatal=False, flags=re.DOTALL)
  727. return [{
  728. 'id': video_id,
  729. 'url': video_url,
  730. 'ext': 'mp4',
  731. 'title': video_title,
  732. 'thumbnail': thumbnail,
  733. 'uploader': uploader,
  734. }]
  735. class FlickrIE(InfoExtractor):
  736. """Information Extractor for Flickr videos"""
  737. _VALID_URL = r'(?:https?://)?(?:www\.)?flickr\.com/photos/(?P<uploader_id>[\w\-_@]+)/(?P<id>\d+).*'
  738. def _real_extract(self, url):
  739. mobj = re.match(self._VALID_URL, url)
  740. video_id = mobj.group('id')
  741. video_uploader_id = mobj.group('uploader_id')
  742. webpage_url = 'http://www.flickr.com/photos/' + video_uploader_id + '/' + video_id
  743. webpage = self._download_webpage(webpage_url, video_id)
  744. secret = self._search_regex(r"photo_secret: '(\w+)'", webpage, u'secret')
  745. first_url = 'https://secure.flickr.com/apps/video/video_mtl_xml.gne?v=x&photo_id=' + video_id + '&secret=' + secret + '&bitrate=700&target=_self'
  746. first_xml = self._download_webpage(first_url, video_id, 'Downloading first data webpage')
  747. node_id = self._html_search_regex(r'<Item id="id">(\d+-\d+)</Item>',
  748. first_xml, u'node_id')
  749. 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'
  750. second_xml = self._download_webpage(second_url, video_id, 'Downloading second data webpage')
  751. self.report_extraction(video_id)
  752. mobj = re.search(r'<STREAM APP="(.+?)" FULLPATH="(.+?)"', second_xml)
  753. if mobj is None:
  754. raise ExtractorError(u'Unable to extract video url')
  755. video_url = mobj.group(1) + unescapeHTML(mobj.group(2))
  756. video_title = self._html_search_regex(r'<meta property="og:title" content=(?:"([^"]+)"|\'([^\']+)\')',
  757. webpage, u'video title')
  758. video_description = self._html_search_regex(r'<meta property="og:description" content=(?:"([^"]+)"|\'([^\']+)\')',
  759. webpage, u'description', fatal=False)
  760. thumbnail = self._html_search_regex(r'<meta property="og:image" content=(?:"([^"]+)"|\'([^\']+)\')',
  761. webpage, u'thumbnail', fatal=False)
  762. return [{
  763. 'id': video_id,
  764. 'url': video_url,
  765. 'ext': 'mp4',
  766. 'title': video_title,
  767. 'description': video_description,
  768. 'thumbnail': thumbnail,
  769. 'uploader_id': video_uploader_id,
  770. }]
  771. class TeamcocoIE(InfoExtractor):
  772. _VALID_URL = r'http://teamcoco\.com/video/(?P<url_title>.*)'
  773. def _real_extract(self, url):
  774. mobj = re.match(self._VALID_URL, url)
  775. if mobj is None:
  776. raise ExtractorError(u'Invalid URL: %s' % url)
  777. url_title = mobj.group('url_title')
  778. webpage = self._download_webpage(url, url_title)
  779. video_id = self._html_search_regex(r'<article class="video" data-id="(\d+?)"',
  780. webpage, u'video id')
  781. self.report_extraction(video_id)
  782. video_title = self._html_search_regex(r'<meta property="og:title" content="(.+?)"',
  783. webpage, u'title')
  784. thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.+?)"',
  785. webpage, u'thumbnail', fatal=False)
  786. video_description = self._html_search_regex(r'<meta property="og:description" content="(.*?)"',
  787. webpage, u'description', fatal=False)
  788. data_url = 'http://teamcoco.com/cvp/2.0/%s.xml' % video_id
  789. data = self._download_webpage(data_url, video_id, 'Downloading data webpage')
  790. video_url = self._html_search_regex(r'<file type="high".*?>(.*?)</file>',
  791. data, u'video URL')
  792. return [{
  793. 'id': video_id,
  794. 'url': video_url,
  795. 'ext': 'mp4',
  796. 'title': video_title,
  797. 'thumbnail': thumbnail,
  798. 'description': video_description,
  799. }]
  800. class XHamsterIE(InfoExtractor):
  801. """Information Extractor for xHamster"""
  802. _VALID_URL = r'(?:http://)?(?:www.)?xhamster\.com/movies/(?P<id>[0-9]+)/.*\.html'
  803. def _real_extract(self,url):
  804. mobj = re.match(self._VALID_URL, url)
  805. video_id = mobj.group('id')
  806. mrss_url = 'http://xhamster.com/movies/%s/.html' % video_id
  807. webpage = self._download_webpage(mrss_url, video_id)
  808. mobj = re.search(r'\'srv\': \'(?P<server>[^\']*)\',\s*\'file\': \'(?P<file>[^\']+)\',', webpage)
  809. if mobj is None:
  810. raise ExtractorError(u'Unable to extract media URL')
  811. if len(mobj.group('server')) == 0:
  812. video_url = compat_urllib_parse.unquote(mobj.group('file'))
  813. else:
  814. video_url = mobj.group('server')+'/key='+mobj.group('file')
  815. video_extension = video_url.split('.')[-1]
  816. video_title = self._html_search_regex(r'<title>(?P<title>.+?) - xHamster\.com</title>',
  817. webpage, u'title')
  818. # Can't see the description anywhere in the UI
  819. # video_description = self._html_search_regex(r'<span>Description: </span>(?P<description>[^<]+)',
  820. # webpage, u'description', fatal=False)
  821. # if video_description: video_description = unescapeHTML(video_description)
  822. 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)
  823. if mobj:
  824. video_upload_date = mobj.group('upload_date_Y')+mobj.group('upload_date_m')+mobj.group('upload_date_d')
  825. else:
  826. video_upload_date = None
  827. self._downloader.report_warning(u'Unable to extract upload date')
  828. video_uploader_id = self._html_search_regex(r'<a href=\'/user/[^>]+>(?P<uploader_id>[^<]+)',
  829. webpage, u'uploader id', default=u'anonymous')
  830. video_thumbnail = self._search_regex(r'\'image\':\'(?P<thumbnail>[^\']+)\'',
  831. webpage, u'thumbnail', fatal=False)
  832. return [{
  833. 'id': video_id,
  834. 'url': video_url,
  835. 'ext': video_extension,
  836. 'title': video_title,
  837. # 'description': video_description,
  838. 'upload_date': video_upload_date,
  839. 'uploader_id': video_uploader_id,
  840. 'thumbnail': video_thumbnail
  841. }]
  842. class HypemIE(InfoExtractor):
  843. """Information Extractor for hypem"""
  844. _VALID_URL = r'(?:http://)?(?:www\.)?hypem\.com/track/([^/]+)/([^/]+)'
  845. def _real_extract(self, url):
  846. mobj = re.match(self._VALID_URL, url)
  847. if mobj is None:
  848. raise ExtractorError(u'Invalid URL: %s' % url)
  849. track_id = mobj.group(1)
  850. data = { 'ax': 1, 'ts': time.time() }
  851. data_encoded = compat_urllib_parse.urlencode(data)
  852. complete_url = url + "?" + data_encoded
  853. request = compat_urllib_request.Request(complete_url)
  854. response, urlh = self._download_webpage_handle(request, track_id, u'Downloading webpage with the url')
  855. cookie = urlh.headers.get('Set-Cookie', '')
  856. self.report_extraction(track_id)
  857. html_tracks = self._html_search_regex(r'<script type="application/json" id="displayList-data">(.*?)</script>',
  858. response, u'tracks', flags=re.MULTILINE|re.DOTALL).strip()
  859. try:
  860. track_list = json.loads(html_tracks)
  861. track = track_list[u'tracks'][0]
  862. except ValueError:
  863. raise ExtractorError(u'Hypemachine contained invalid JSON.')
  864. key = track[u"key"]
  865. track_id = track[u"id"]
  866. artist = track[u"artist"]
  867. title = track[u"song"]
  868. serve_url = "http://hypem.com/serve/source/%s/%s" % (compat_str(track_id), compat_str(key))
  869. request = compat_urllib_request.Request(serve_url, "" , {'Content-Type': 'application/json'})
  870. request.add_header('cookie', cookie)
  871. song_data_json = self._download_webpage(request, track_id, u'Downloading metadata')
  872. try:
  873. song_data = json.loads(song_data_json)
  874. except ValueError:
  875. raise ExtractorError(u'Hypemachine contained invalid JSON.')
  876. final_url = song_data[u"url"]
  877. return [{
  878. 'id': track_id,
  879. 'url': final_url,
  880. 'ext': "mp3",
  881. 'title': title,
  882. 'artist': artist,
  883. }]
  884. class Vbox7IE(InfoExtractor):
  885. """Information Extractor for Vbox7"""
  886. _VALID_URL = r'(?:http://)?(?:www\.)?vbox7\.com/play:([^/]+)'
  887. def _real_extract(self,url):
  888. mobj = re.match(self._VALID_URL, url)
  889. if mobj is None:
  890. raise ExtractorError(u'Invalid URL: %s' % url)
  891. video_id = mobj.group(1)
  892. redirect_page, urlh = self._download_webpage_handle(url, video_id)
  893. new_location = self._search_regex(r'window\.location = \'(.*)\';', redirect_page, u'redirect location')
  894. redirect_url = urlh.geturl() + new_location
  895. webpage = self._download_webpage(redirect_url, video_id, u'Downloading redirect page')
  896. title = self._html_search_regex(r'<title>(.*)</title>',
  897. webpage, u'title').split('/')[0].strip()
  898. ext = "flv"
  899. info_url = "http://vbox7.com/play/magare.do"
  900. data = compat_urllib_parse.urlencode({'as3':'1','vid':video_id})
  901. info_request = compat_urllib_request.Request(info_url, data)
  902. info_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
  903. info_response = self._download_webpage(info_request, video_id, u'Downloading info webpage')
  904. if info_response is None:
  905. raise ExtractorError(u'Unable to extract the media url')
  906. (final_url, thumbnail_url) = map(lambda x: x.split('=')[1], info_response.split('&'))
  907. return [{
  908. 'id': video_id,
  909. 'url': final_url,
  910. 'ext': ext,
  911. 'title': title,
  912. 'thumbnail': thumbnail_url,
  913. }]
  914. def gen_extractors():
  915. """ Return a list of an instance of every supported extractor.
  916. The order does matter; the first extractor matched is the one handling the URL.
  917. """
  918. return [
  919. YoutubePlaylistIE(),
  920. YoutubeChannelIE(),
  921. YoutubeUserIE(),
  922. YoutubeSearchIE(),
  923. YoutubeIE(),
  924. MetacafeIE(),
  925. DailymotionIE(),
  926. GoogleSearchIE(),
  927. PhotobucketIE(),
  928. YahooIE(),
  929. YahooSearchIE(),
  930. DepositFilesIE(),
  931. FacebookIE(),
  932. BlipTVIE(),
  933. BlipTVUserIE(),
  934. VimeoIE(),
  935. MyVideoIE(),
  936. ComedyCentralIE(),
  937. EscapistIE(),
  938. CollegeHumorIE(),
  939. XVideosIE(),
  940. SoundcloudSetIE(),
  941. SoundcloudIE(),
  942. InfoQIE(),
  943. MixcloudIE(),
  944. StanfordOpenClassroomIE(),
  945. MTVIE(),
  946. YoukuIE(),
  947. XNXXIE(),
  948. YouJizzIE(),
  949. PornotubeIE(),
  950. YouPornIE(),
  951. GooglePlusIE(),
  952. ArteTvIE(),
  953. NBAIE(),
  954. WorldStarHipHopIE(),
  955. JustinTVIE(),
  956. FunnyOrDieIE(),
  957. SteamIE(),
  958. UstreamIE(),
  959. RBMARadioIE(),
  960. EightTracksIE(),
  961. KeekIE(),
  962. TEDIE(),
  963. MySpassIE(),
  964. SpiegelIE(),
  965. LiveLeakIE(),
  966. ARDIE(),
  967. ZDFIE(),
  968. TumblrIE(),
  969. BandcampIE(),
  970. RedTubeIE(),
  971. InaIE(),
  972. HowcastIE(),
  973. VineIE(),
  974. FlickrIE(),
  975. TeamcocoIE(),
  976. XHamsterIE(),
  977. HypemIE(),
  978. Vbox7IE(),
  979. GametrailersIE(),
  980. StatigramIE(),
  981. GenericIE()
  982. ]
  983. def get_info_extractor(ie_name):
  984. """Returns the info extractor class with the given ie_name"""
  985. return globals()[ie_name+'IE']