]>
Commit | Line | Data |
---|---|---|
0df2dea7 S |
1 | import itertools |
2 | ||
3 | from .common import InfoExtractor | |
14f25df2 | 4 | from ..compat import compat_str |
5 | from ..utils import parse_duration, parse_iso8601, qualities, str_to_int | |
0df2dea7 S |
6 | |
7 | ||
8 | class GigaIE(InfoExtractor): | |
9 | _VALID_URL = r'https?://(?:www\.)?giga\.de/(?:[^/]+/)*(?P<id>[^/]+)' | |
10 | _TESTS = [{ | |
11 | 'url': 'http://www.giga.de/filme/anime-awesome/trailer/anime-awesome-chihiros-reise-ins-zauberland-das-beste-kommt-zum-schluss/', | |
12 | 'md5': '6bc5535e945e724640664632055a584f', | |
13 | 'info_dict': { | |
14 | 'id': '2622086', | |
15 | 'display_id': 'anime-awesome-chihiros-reise-ins-zauberland-das-beste-kommt-zum-schluss', | |
16 | 'ext': 'mp4', | |
17 | 'title': 'Anime Awesome: Chihiros Reise ins Zauberland – Das Beste kommt zum Schluss', | |
18 | 'description': 'md5:afdf5862241aded4718a30dff6a57baf', | |
ec85ded8 | 19 | 'thumbnail': r're:^https?://.*\.jpg$', |
0df2dea7 S |
20 | 'duration': 578, |
21 | 'timestamp': 1414749706, | |
22 | 'upload_date': '20141031', | |
23 | 'uploader': 'Robin Schweiger', | |
24 | 'view_count': int, | |
25 | }, | |
26 | }, { | |
27 | 'url': 'http://www.giga.de/games/channel/giga-top-montag/giga-topmontag-die-besten-serien-2014/', | |
28 | 'only_matching': True, | |
29 | }, { | |
30 | 'url': 'http://www.giga.de/extra/netzkultur/videos/giga-games-tom-mats-robin-werden-eigene-wege-gehen-eine-ankuendigung/', | |
31 | 'only_matching': True, | |
32 | }, { | |
33 | 'url': 'http://www.giga.de/tv/jonas-liest-spieletitel-eingedeutscht-episode-2/', | |
34 | 'only_matching': True, | |
35 | }] | |
36 | ||
37 | def _real_extract(self, url): | |
38 | display_id = self._match_id(url) | |
39 | ||
40 | webpage = self._download_webpage(url, display_id) | |
41 | ||
42 | video_id = self._search_regex( | |
43 | [r'data-video-id="(\d+)"', r'/api/video/jwplayer/#v=(\d+)'], | |
44 | webpage, 'video id') | |
45 | ||
46 | playlist = self._download_json( | |
47 | 'http://www.giga.de/api/syndication/video/video_id/%s/playlist.json?content=syndication/key/368b5f151da4ae05ced7fa296bdff65a/' | |
48 | % video_id, video_id)[0] | |
49 | ||
50 | quality = qualities(['normal', 'hd720']) | |
51 | ||
52 | formats = [] | |
53 | for format_id in itertools.count(0): | |
54 | fmt = playlist.get(compat_str(format_id)) | |
55 | if not fmt: | |
56 | break | |
57 | formats.append({ | |
58 | 'url': fmt['src'], | |
59 | 'format_id': '%s-%s' % (fmt['quality'], fmt['type'].split('/')[-1]), | |
60 | 'quality': quality(fmt['quality']), | |
61 | }) | |
0df2dea7 S |
62 | |
63 | title = self._html_search_meta( | |
64 | 'title', webpage, 'title', fatal=True) | |
65 | description = self._html_search_meta( | |
66 | 'description', webpage, 'description') | |
67 | thumbnail = self._og_search_thumbnail(webpage) | |
68 | ||
69 | duration = parse_duration(self._search_regex( | |
70 | r'(?s)(?:data-video-id="{0}"|data-video="[^"]*/api/video/jwplayer/#v={0}[^"]*")[^>]*>.+?<span class="duration">([^<]+)</span>'.format(video_id), | |
71 | webpage, 'duration', fatal=False)) | |
72 | ||
73 | timestamp = parse_iso8601(self._search_regex( | |
74 | r'datetime="([^"]+)"', webpage, 'upload date', fatal=False)) | |
75 | uploader = self._search_regex( | |
76 | r'class="author">([^<]+)</a>', webpage, 'uploader', fatal=False) | |
77 | ||
78 | view_count = str_to_int(self._search_regex( | |
6a8f9cd2 S |
79 | r'<span class="views"><strong>([\d.,]+)</strong>', |
80 | webpage, 'view count', fatal=False)) | |
0df2dea7 S |
81 | |
82 | return { | |
83 | 'id': video_id, | |
84 | 'display_id': display_id, | |
85 | 'title': title, | |
86 | 'description': description, | |
87 | 'thumbnail': thumbnail, | |
88 | 'duration': duration, | |
89 | 'timestamp': timestamp, | |
90 | 'uploader': uploader, | |
91 | 'view_count': view_count, | |
92 | 'formats': formats, | |
93 | } |