From efc867775e09f493cca95fc5cd2986db7b55a71b Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Mon, 27 Jan 2014 07:55:30 +0100 Subject: [PATCH] [cliphunter] Simplify --- youtube_dl/extractor/cliphunter.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/youtube_dl/extractor/cliphunter.py b/youtube_dl/extractor/cliphunter.py index 2d8c09630..42d406820 100644 --- a/youtube_dl/extractor/cliphunter.py +++ b/youtube_dl/extractor/cliphunter.py @@ -1,9 +1,10 @@ +from __future__ import unicode_literals + import re import string from .common import InfoExtractor from ..utils import ( - determine_ext, ExtractorError, ) @@ -23,39 +24,34 @@ translation_table = ( class CliphunterIE(InfoExtractor): - """Information Extractor for Cliphunter""" - IE_NAME = u'cliphunter' + IE_NAME = 'cliphunter' _VALID_URL = (r'(?:http://)?(?:www\.)?cliphunter\.com/w/' '(?P[0-9]+)/' '(?P.+?)(?:\?.*)?') - _TESTS = [{ - u'url': u'http://www.cliphunter.com/w/1012420/Fun_Jynx_Maze_solo', - u'file': u'1012420.flv', - u'md5': u'15e7740f30428abf70f4223478dc1225', - u'info_dict': { - u'title': u'Fun Jynx Maze solo', + _TESTS = { + 'url': 'http://www.cliphunter.com/w/1012420/Fun_Jynx_Maze_solo', + 'file': '1012420.flv', + 'md5': '15e7740f30428abf70f4223478dc1225', + 'info_dict': { + 'title': 'Fun Jynx Maze solo', } - }] + } def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) - if mobj is None: - raise ExtractorError(u'Unable to extract media URL') - video_id = mobj.group('id') webpage = self._download_webpage(url, video_id) - pl_fiji = re.search(r'pl_fiji = \'([^\']+)\'', webpage).group(1) - pl_c_qual = re.search(r'pl_c_qual = "(.)"', webpage).group(1) - video_title = re.search(r'mediaTitle = "([^"]+)"', webpage).group(1) + 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 = string.translate(pl_fiji.encode(), translation_table) formats = [{ 'url': video_url, - 'ext': determine_ext(video_url), 'format': pl_c_qual, 'format_id': pl_c_qual, }] -- 2.22.2