X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Ftrilulilu.py;h=220a05b7b493fb728f3cd3c6dab74208a8f587eb;hb=08ff6ab07e9d08853ca19cf3b8745fac11abf0f6;hp=1c46156c7c4d5e2d7501071c1f7d3c5a726836e3;hpb=6d38616e67ff9859bce2a7bea2ec4a844530eb71;p=youtube-dl diff --git a/youtube_dl/extractor/trilulilu.py b/youtube_dl/extractor/trilulilu.py index 1c46156c7..220a05b7b 100644 --- a/youtube_dl/extractor/trilulilu.py +++ b/youtube_dl/extractor/trilulilu.py @@ -1,32 +1,28 @@ +from __future__ import unicode_literals + import json -import re -import xml.etree.ElementTree from .common import InfoExtractor -from ..utils import ( - ExtractorError, -) class TriluliluIE(InfoExtractor): - _VALID_URL = r'(?x)(?:https?://)?(?:www\.)?trilulilu\.ro/video-(?P[^/]+)/(?P[^/]+)' + _VALID_URL = r'https?://(?:www\.)?trilulilu\.ro/video-[^/]+/(?P[^/]+)' _TEST = { - u"url": u"http://www.trilulilu.ro/video-animatie/big-buck-bunny-1", - u'file': u"big-buck-bunny-1.mp4", - u'info_dict': { - u"title": u"Big Buck Bunny", - u"description": u":) pentru copilul din noi", + 'url': 'http://www.trilulilu.ro/video-animatie/big-buck-bunny-1', + 'info_dict': { + 'id': 'big-buck-bunny-1', + 'ext': 'mp4', + 'title': 'Big Buck Bunny', + 'description': ':) pentru copilul din noi', }, # Server ignores Range headers (--test) - u"params": { - u"skip_download": True + 'params': { + 'skip_download': True } } def _real_extract(self, url): - mobj = re.match(self._VALID_URL, url) - video_id = mobj.group('video_id') - + video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) title = self._og_search_title(webpage) @@ -34,33 +30,32 @@ class TriluliluIE(InfoExtractor): description = self._og_search_description(webpage) log_str = self._search_regex( - r'block_flash_vars[ ]=[ ]({[^}]+})', webpage, u'log info') + r'block_flash_vars[ ]=[ ]({[^}]+})', webpage, 'log info') log = json.loads(log_str) - format_url = (u'http://fs%(server)s.trilulilu.ro/%(hash)s/' - u'video-formats2' % log) - format_str = self._download_webpage( + format_url = ('http://fs%(server)s.trilulilu.ro/%(hash)s/' + 'video-formats2' % log) + format_doc = self._download_xml( format_url, video_id, - note=u'Downloading formats', - errnote=u'Error while downloading formats') + note='Downloading formats', + errnote='Error while downloading formats') - format_doc = xml.etree.ElementTree.fromstring(format_str) - video_url_template = ( - u'http://fs%(server)s.trilulilu.ro/stream.php?type=video' - u'&source=site&hash=%(hash)s&username=%(userid)s&' - u'key=ministhebest&format=%%s&sig=&exp=' % + 'http://fs%(server)s.trilulilu.ro/stream.php?type=video' + '&source=site&hash=%(hash)s&username=%(userid)s&' + 'key=ministhebest&format=%%s&sig=&exp=' % log) formats = [ { 'format': fnode.text, 'url': video_url_template % fnode.text, + 'ext': fnode.text.partition('-')[0] } for fnode in format_doc.findall('./formats/format') ] - info = { + return { '_type': 'video', 'id': video_id, 'formats': formats, @@ -68,9 +63,3 @@ class TriluliluIE(InfoExtractor): 'description': description, 'thumbnail': thumbnail, } - - # TODO: Remove when #980 has been merged - info['url'] = formats[-1]['url'] - info['ext'] = formats[-1]['format'].partition('-')[0] - - return info