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