diff options
| author | snipem <mail@matthias-kuech.de> | 2015-04-03 15:34:49 +0200 | 
|---|---|---|
| committer | snipem <mail@matthias-kuech.de> | 2015-04-03 15:34:49 +0200 | 
| commit | e81a47460365738a0add4d4da52a712c0091704f (patch) | |
| tree | 40239253a0b0146025f999a1b67a0128ba216945 | |
| parent | a9cbab173584c716219b348ff36ccd5274f75249 (diff) | |
[Gamersyde] Add new extractor
| -rw-r--r-- | youtube_dl/extractor/__init__.py | 1 | ||||
| -rw-r--r-- | youtube_dl/extractor/gamersyde.py | 64 | 
2 files changed, 65 insertions, 0 deletions
| diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index aae4aae4c..2935d5b33 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -177,6 +177,7 @@ from .gameone import (      GameOneIE,      GameOnePlaylistIE,  ) +from .gamersyde import GamersydeIE  from .gamespot import GameSpotIE  from .gamestar import GameStarIE  from .gametrailers import GametrailersIE diff --git a/youtube_dl/extractor/gamersyde.py b/youtube_dl/extractor/gamersyde.py new file mode 100644 index 000000000..c40106216 --- /dev/null +++ b/youtube_dl/extractor/gamersyde.py @@ -0,0 +1,64 @@ +# coding: utf-8 +from __future__ import unicode_literals +import re +import json +import time +from .common import InfoExtractor + + +class GamersydeIE(InfoExtractor): +    _VALID_URL = r'https?://(?:www\.)?gamersyde\.com/hqstream_' +    _TEST = { +        'url': 'http://www.gamersyde.com/hqstream_bloodborne_birth_of_a_hero-34371_en.html', +        'md5': 'f38d400d32f19724570040d5ce3a505f', +        'info_dict': { +            'id': '34371', +            'ext': 'mp4', +            'title': 'Bloodborne - Birth of a hero', +            'thumbnail': 're:^https?://.*\.jpg$', +        } +    } + +    def _calculateDuration(self, durationString): +        duration = time.strptime(durationString, "%M minutes %S seconds") +        return duration.tm_min * 60 + duration.tm_sec + +    def _fixJsonSyntax(self, json): + +        json = re.sub(r"{\s*(\w)", r'{"\1', json) +        json = re.sub(r",\s*(\w)", r',"\1', json) +        json = re.sub(r"(\w): ", r'\1":', json) +        json = re.sub(r",\s*}", "}", json, flags=re.DOTALL) +        json = re.sub(r",\s*]", "]", json, flags=re.DOTALL) + +        return json + +    def _real_extract(self, url): + +        video_id = self._search_regex(r'-(.*?)_[a-z]{2}.html$', url, 'video_id') +        webpage = self._download_webpage(url, video_id) + +        filesJson = self._search_regex(r'playlist: (.*?)\}\);', webpage, 'files', flags=re.DOTALL) +        filesJson = self._fixJsonSyntax(filesJson) + +        data = json.loads(filesJson) +        playlist = data[0] + +        formats = [] + +        title = re.sub(r"[0-9]+ - ", "", playlist['title']) + +        for playlistEntry in playlist['sources']: +            format = { +                'url': playlistEntry['file'], +                'format_id': playlistEntry['label'] +            } + +            formats.append(format) + +        return { +            'id': video_id, +            'title': title, +            'formats': formats, +            'thumbnail': playlist['image'] +            } | 
