]>
Commit | Line | Data |
---|---|---|
e81a4746 | 1 | from __future__ import unicode_literals |
5c29dbd0 | 2 | |
e81a4746 | 3 | import re |
3d24d997 | 4 | |
e81a4746 | 5 | from .common import InfoExtractor |
5c29dbd0 S |
6 | from ..utils import ( |
7 | js_to_json, | |
8 | parse_duration, | |
9 | remove_start, | |
10 | ) | |
e81a4746 | 11 | |
12 | ||
13 | class GamersydeIE(InfoExtractor): | |
5c29dbd0 S |
14 | _VALID_URL = r'https?://(?:www\.)?gamersyde\.com/hqstream_(?P<display_id>[\da-z_]+)-(?P<id>\d+)_[a-z]{2}\.html' |
15 | _TEST = { | |
e81a4746 | 16 | 'url': 'http://www.gamersyde.com/hqstream_bloodborne_birth_of_a_hero-34371_en.html', |
17 | 'md5': 'f38d400d32f19724570040d5ce3a505f', | |
18 | 'info_dict': { | |
19 | 'id': '34371', | |
20 | 'ext': 'mp4', | |
3d24d997 | 21 | 'duration': 372, |
e81a4746 | 22 | 'title': 'Bloodborne - Birth of a hero', |
23 | 'thumbnail': 're:^https?://.*\.jpg$', | |
24 | } | |
25 | } | |
e81a4746 | 26 | |
27 | def _real_extract(self, url): | |
5c29dbd0 S |
28 | mobj = re.match(self._VALID_URL, url) |
29 | video_id = mobj.group('id') | |
30 | display_id = mobj.group('display_id') | |
e81a4746 | 31 | |
5c29dbd0 | 32 | webpage = self._download_webpage(url, display_id) |
e81a4746 | 33 | |
5c29dbd0 S |
34 | playlist = self._parse_json( |
35 | self._search_regex( | |
36 | r'(?s)playlist: \[({.+?})\]\s*}\);', webpage, 'files'), | |
37 | display_id, transform_source=js_to_json) | |
e81a4746 | 38 | |
39 | formats = [] | |
5c29dbd0 S |
40 | for source in playlist['sources']: |
41 | video_url = source.get('file') | |
42 | if not video_url: | |
43 | continue | |
44 | format_id = source.get('label') | |
45 | f = { | |
46 | 'url': video_url, | |
47 | 'format_id': format_id, | |
e81a4746 | 48 | } |
5c29dbd0 S |
49 | m = re.search(r'^(?P<height>\d+)[pP](?P<fps>\d+)fps', format_id) |
50 | if m: | |
51 | f.update({ | |
52 | 'height': int(m.group('height')), | |
53 | 'fps': int(m.group('fps')), | |
54 | }) | |
55 | formats.append(f) | |
56 | self._sort_formats(formats) | |
e81a4746 | 57 | |
5c29dbd0 S |
58 | title = remove_start(playlist['title'], '%s - ' % video_id) |
59 | thumbnail = playlist.get('image') | |
60 | duration = parse_duration(self._search_regex( | |
61 | r'Length:</label>([^<]+)<', webpage, 'duration', fatal=False)) | |
e81a4746 | 62 | |
63 | return { | |
64 | 'id': video_id, | |
5c29dbd0 | 65 | 'display_id': display_id, |
e81a4746 | 66 | 'title': title, |
5c29dbd0 | 67 | 'thumbnail': thumbnail, |
3d24d997 | 68 | 'duration': duration, |
5c29dbd0 S |
69 | 'formats': formats, |
70 | } |