]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/trilulilu.py
[atresplayer] Filter URLs and clarify android format ids
[yt-dlp.git] / youtube_dl / extractor / trilulilu.py
CommitLineData
b3034f9d
PH
1from __future__ import unicode_literals
2
341ca8d7 3import json
341ca8d7
PH
4
5from .common import InfoExtractor
341ca8d7
PH
6
7
8class TriluliluIE(InfoExtractor):
b3034f9d 9 _VALID_URL = r'https?://(?:www\.)?trilulilu\.ro/video-[^/]+/(?P<id>[^/]+)'
341ca8d7 10 _TEST = {
b3034f9d
PH
11 'url': 'http://www.trilulilu.ro/video-animatie/big-buck-bunny-1',
12 'info_dict': {
13 'id': 'big-buck-bunny-1',
14 'ext': 'mp4',
15 'title': 'Big Buck Bunny',
16 'description': ':) pentru copilul din noi',
341ca8d7
PH
17 },
18 # Server ignores Range headers (--test)
b3034f9d
PH
19 'params': {
20 'skip_download': True
341ca8d7
PH
21 }
22 }
23
24 def _real_extract(self, url):
b3034f9d 25 video_id = self._match_id(url)
341ca8d7
PH
26 webpage = self._download_webpage(url, video_id)
27
28 title = self._og_search_title(webpage)
29 thumbnail = self._og_search_thumbnail(webpage)
30 description = self._og_search_description(webpage)
31
32 log_str = self._search_regex(
b3034f9d 33 r'block_flash_vars[ ]=[ ]({[^}]+})', webpage, 'log info')
341ca8d7
PH
34 log = json.loads(log_str)
35
b3034f9d
PH
36 format_url = ('http://fs%(server)s.trilulilu.ro/%(hash)s/'
37 'video-formats2' % log)
e26f8712 38 format_doc = self._download_xml(
341ca8d7 39 format_url, video_id,
b3034f9d
PH
40 note='Downloading formats',
41 errnote='Error while downloading formats')
5f6a1245 42
341ca8d7 43 video_url_template = (
b3034f9d
PH
44 'http://fs%(server)s.trilulilu.ro/stream.php?type=video'
45 '&source=site&hash=%(hash)s&username=%(userid)s&'
46 'key=ministhebest&format=%%s&sig=&exp=' %
341ca8d7
PH
47 log)
48 formats = [
49 {
50 'format': fnode.text,
51 'url': video_url_template % fnode.text,
471a5ee9 52 'ext': fnode.text.partition('-')[0]
341ca8d7
PH
53 }
54
55 for fnode in format_doc.findall('./formats/format')
56 ]
57
fb7abb31 58 return {
341ca8d7
PH
59 '_type': 'video',
60 'id': video_id,
61 'formats': formats,
62 'title': title,
63 'description': description,
64 'thumbnail': thumbnail,
65 }