3 import xml.etree.ElementTree
5 from .common import InfoExtractor
11 class TriluliluIE(InfoExtractor):
12 _VALID_URL = r'(?x)(?:https?://)?(?:www\.)?trilulilu\.ro/video-(?P<category>[^/]+)/(?P<video_id>[^/]+)'
14 u"url": u"http://www.trilulilu.ro/video-animatie/big-buck-bunny-1",
15 u'file': u"big-buck-bunny-1.mp4",
17 u"title": u"Big Buck Bunny",
18 u"description": u":) pentru copilul din noi",
20 # Server ignores Range headers (--test)
22 u"skip_download": True
26 def _real_extract(self, url):
27 mobj = re.match(self._VALID_URL, url)
28 video_id = mobj.group('video_id')
30 webpage = self._download_webpage(url, video_id)
32 title = self._og_search_title(webpage)
33 thumbnail = self._og_search_thumbnail(webpage)
34 description = self._og_search_description(webpage)
36 log_str = self._search_regex(
37 r'block_flash_vars[ ]=[ ]({[^}]+})', webpage, u'log info')
38 log = json.loads(log_str)
40 format_url = (u'http://fs%(server)s.trilulilu.ro/%(hash)s/'
41 u'video-formats2' % log)
42 format_str = self._download_webpage(
44 note=u'Downloading formats',
45 errnote=u'Error while downloading formats')
47 format_doc = xml.etree.ElementTree.fromstring(format_str)
49 video_url_template = (
50 u'http://fs%(server)s.trilulilu.ro/stream.php?type=video'
51 u'&source=site&hash=%(hash)s&username=%(userid)s&'
52 u'key=ministhebest&format=%%s&sig=&exp=' %
57 'url': video_url_template % fnode.text,
60 for fnode in format_doc.findall('./formats/format')
68 'description': description,
69 'thumbnail': thumbnail,
72 # TODO: Remove when #980 has been merged
73 info['url'] = formats[-1]['url']
74 info['ext'] = formats[-1]['format'].partition('-')[0]