1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
6 from .common import InfoExtractor
15 class GoshgayIE(InfoExtractor):
16 _VALID_URL = r'^(?:https?://)www.goshgay.com/video(?P<id>\d+?)($|/)'
18 'url': 'http://www.goshgay.com/video4116282',
19 'md5': '268b9f3c3229105c57859e166dd72b03',
23 'title': 'md5:089833a4790b5e103285a07337f245bf',
24 'thumbnail': 're:http://.*\.jpg',
28 def _real_extract(self, url):
29 mobj = re.match(self._VALID_URL, url)
30 video_id = mobj.group('id')
32 webpage = self._download_webpage(url, video_id)
33 title = self._search_regex(r'class="video-title"><h1>(.+?)<', webpage, 'title')
35 player_config = self._search_regex(r'jwplayer\("player"\)\.setup\(({.+?})\)', webpage, 'config settings',
36 fatal=True, flags=re.S)
37 player_vars = json.loads(player_config.replace("'", '"'))
38 width = str_to_int(player_vars.get('width'))
39 height = str_to_int(player_vars.get('height'))
40 config_uri = player_vars.get('config')
42 if config_uri is None:
43 raise ExtractorError('Missing config URI')
44 node = self._download_xml(config_uri, video_id, 'Downloading player config XML',
45 errnote='Unable to download XML')
47 raise ExtractorError('Missing config XML')
48 if node.tag != 'config':
49 raise ExtractorError('Missing config attribute')
50 fns = node.findall('file')
51 imgs = node.findall('image')
53 raise ExtractorError('Missing media URI')
54 video_url = fns[0].text
58 thumbnail = imgs[0].text
60 url_comp = compat_urlparse.urlparse(url)
61 ref = "%s://%s%s" % (url_comp[0], url_comp[1], url_comp[2])
69 'thumbnail': thumbnail,