X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fcliphunter.py;h=d46592cc5c8c71d30fda96c1b25c6f4a9c55ad75;hb=e4df2f98ccbe2e24785dd6883d7fd495193fd8e6;hp=58846e8e7cfacc631015ce32ace23cbd9b8a2576;hpb=23fe495feb8e1a54f20beb6c7b9e976c6d1a1759;p=youtube-dl diff --git a/youtube_dl/extractor/cliphunter.py b/youtube_dl/extractor/cliphunter.py index 58846e8e7..d46592cc5 100644 --- a/youtube_dl/extractor/cliphunter.py +++ b/youtube_dl/extractor/cliphunter.py @@ -1,11 +1,10 @@ from __future__ import unicode_literals -import re - from .common import InfoExtractor +from ..utils import determine_ext -translation_table = { +_translation_table = { 'a': 'h', 'd': 'e', 'e': 'v', 'f': 'o', 'g': 'f', 'i': 'd', 'l': 'n', 'm': 'a', 'n': 'm', 'p': 'u', 'q': 't', 'r': 's', 'v': 'p', 'x': 'r', 'y': 'l', 'z': 'i', @@ -13,6 +12,10 @@ translation_table = { } +def _decode(s): + return ''.join(_translation_table.get(c, c) for c in s) + + class CliphunterIE(InfoExtractor): IE_NAME = 'cliphunter' @@ -22,35 +25,58 @@ class CliphunterIE(InfoExtractor): ''' _TEST = { 'url': 'http://www.cliphunter.com/w/1012420/Fun_Jynx_Maze_solo', - 'file': '1012420.flv', - 'md5': '15e7740f30428abf70f4223478dc1225', + 'md5': 'b7c9bbd4eb3a226ab91093714dcaa480', 'info_dict': { + 'id': '1012420', + 'ext': 'flv', 'title': 'Fun Jynx Maze solo', + 'thumbnail': 're:^https?://.*\.jpg$', + 'age_limit': 18, } } def _real_extract(self, url): - mobj = re.match(self._VALID_URL, url) - video_id = mobj.group('id') - + video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) - pl_fiji = self._search_regex( - r'pl_fiji = \'([^\']+)\'', webpage, 'video data') - pl_c_qual = self._search_regex( - r'pl_c_qual = "(.)"', webpage, 'video quality') video_title = self._search_regex( r'mediaTitle = "([^"]+)"', webpage, 'title') - video_url = ''.join(translation_table.get(c, c) for c in pl_fiji) + fmts = {} + for fmt in ('mp4', 'flv'): + fmt_list = self._parse_json(self._search_regex( + r'var %sjson\s*=\s*(\[.*?\]);' % fmt, webpage, '%s formats' % fmt), video_id) + for f in fmt_list: + fmts[f['fname']] = _decode(f['sUrl']) + + qualities = self._parse_json(self._search_regex( + r'var player_btns\s*=\s*(.*?);\n', webpage, 'quality info'), video_id) + + formats = [] + for fname, url in fmts.items(): + f = { + 'url': url, + } + if fname in qualities: + qual = qualities[fname] + f.update({ + 'format_id': '%s_%sp' % (determine_ext(url), qual['h']), + 'width': qual['w'], + 'height': qual['h'], + 'tbr': qual['br'], + }) + formats.append(f) + + self._sort_formats(formats) - formats = [{ - 'url': video_url, - 'format_id': pl_c_qual, - }] + thumbnail = self._search_regex( + r"var\s+mov_thumb\s*=\s*'([^']+)';", + webpage, 'thumbnail', fatal=False) return { 'id': video_id, 'title': video_title, 'formats': formats, + 'age_limit': self._rta_search(webpage), + 'thumbnail': thumbnail, }