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',
17 'title': 'Bloodborne - Birth of a hero',
18 'thumbnail': 're:^https?://.*\.jpg$',
22 def _calculateDuration(self, durationString):
23 duration = time.strptime(durationString, "%M minutes %S seconds")
24 return duration.tm_min * 60 + duration.tm_sec
26 def _fixJsonSyntax(self, json):
28 json = re.sub(r"{\s*(\w)", r'{"\1', json)
29 json = re.sub(r",\s*(\w)", r',"\1', json)
30 json = re.sub(r"(\w): ", r'\1":', json)
31 json = re.sub(r",\s*}", "}", json, flags=re.DOTALL)
32 json = re.sub(r",\s*]", "]", json, flags=re.DOTALL)
36 def _real_extract(self, url):
38 video_id = self._search_regex(r'-(.*?)_[a-z]{2}.html$', url, 'video_id')
39 webpage = self._download_webpage(url, video_id)
41 filesJson = self._search_regex(r'playlist: (.*?)\}\);', webpage, 'files', flags=re.DOTALL)
42 filesJson = self._fixJsonSyntax(filesJson)
44 data = json.loads(filesJson)
49 title = re.sub(r"[0-9]+ - ", "", playlist['title'])
51 for playlistEntry in playlist['sources']:
53 'url': playlistEntry['file'],
54 'format_id': playlistEntry['label']
57 formats.append(format)
63 'thumbnail': playlist['image']