2 from __future__ import unicode_literals
6 from .common import InfoExtractor
9 class GamersydeIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?gamersyde\.com/hqstream_'
12 'url': 'http://www.gamersyde.com/hqstream_bloodborne_birth_of_a_hero-34371_en.html',
13 'md5': 'f38d400d32f19724570040d5ce3a505f',
18 'title': 'Bloodborne - Birth of a hero',
19 'thumbnail': 're:^https?://.*\.jpg$',
22 'url': 'http://www.gamersyde.com/hqstream_dark_souls_ii_scholar_of_the_first_sin_gameplay_part_1-34417_en.html',
23 'md5': '94bd7c3feff3275576cf5cb6c8a3a720',
28 'title': 'Dark Souls II: Scholar of the First Sin - Gameplay - Part 1',
29 'thumbnail': 're:^https?://.*\.jpg$',
32 'url': 'http://www.gamersyde.com/hqstream_grand_theft_auto_v_heists_trailer-33786_en.html',
33 'md5': '65e442f5f340d571ece8c80d50700369',
38 'title': 'Grand Theft Auto V - Heists Trailer',
39 'thumbnail': 're:^https?://.*\.jpg$',
44 def _calculateDuration(self, durationString):
45 if (durationString.find("minutes") > -1):
46 duration = time.strptime(durationString, "%M minutes %S seconds")
48 duration = time.strptime(durationString, "%S seconds")
49 return duration.tm_min * 60 + duration.tm_sec
51 def _fixJsonSyntax(self, json):
53 json = re.sub(r",\s*}", "}", json, flags=re.DOTALL)
54 json = re.sub(r",\s*]", "]", json, flags=re.DOTALL)
55 json = json.replace('file: "', '"file": "')
56 json = json.replace('title: "', '"title": "')
57 json = json.replace('label: "', '"label": "')
58 json = json.replace('image: "', '"image": "')
59 json = json.replace('sources: [', '"sources": [')
62 def _real_extract(self, url):
64 video_id = self._search_regex(r'-(.*?)_[a-z]{2}.html$', url, 'video_id')
65 webpage = self._download_webpage(url, video_id)
67 filesJson = self._search_regex(r'playlist: (.*?)\}\);', webpage, 'files', flags=re.DOTALL)
68 data = self._parse_json(filesJson,video_id, transform_source=self._fixJsonSyntax)
74 title = re.sub(r"[0-9]+ - ", "", playlist['title'])
76 length = self._search_regex(r'(([0-9]{1,2} minutes ){0,1}[0-9]{1,2} seconds)', webpage, 'length')
77 duration = self._calculateDuration(length)
79 for playlistEntry in playlist['sources']:
81 'url': playlistEntry['file'],
82 'format_id': playlistEntry['label']
85 formats.append(format)
92 'thumbnail': playlist['image']