]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/trilulilu.py
220a05b7b493fb728f3cd3c6dab74208a8f587eb
[youtubedl] / youtube_dl / extractor / trilulilu.py
1 from __future__ import unicode_literals
2
3 import json
4
5 from .common import InfoExtractor
6
7
8 class TriluliluIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?trilulilu\.ro/video-[^/]+/(?P<id>[^/]+)'
10 _TEST = {
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',
17 },
18 # Server ignores Range headers (--test)
19 'params': {
20 'skip_download': True
21 }
22 }
23
24 def _real_extract(self, url):
25 video_id = self._match_id(url)
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(
33 r'block_flash_vars[ ]=[ ]({[^}]+})', webpage, 'log info')
34 log = json.loads(log_str)
35
36 format_url = ('http://fs%(server)s.trilulilu.ro/%(hash)s/'
37 'video-formats2' % log)
38 format_doc = self._download_xml(
39 format_url, video_id,
40 note='Downloading formats',
41 errnote='Error while downloading formats')
42
43 video_url_template = (
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=' %
47 log)
48 formats = [
49 {
50 'format': fnode.text,
51 'url': video_url_template % fnode.text,
52 'ext': fnode.text.partition('-')[0]
53 }
54
55 for fnode in format_doc.findall('./formats/format')
56 ]
57
58 return {
59 '_type': 'video',
60 'id': video_id,
61 'formats': formats,
62 'title': title,
63 'description': description,
64 'thumbnail': thumbnail,
65 }