]>
Commit | Line | Data |
---|---|---|
d6aa1967 M |
1 | # -*- coding: utf-8 -*- |
2 | from __future__ import unicode_literals | |
3 | ||
d6aa1967 | 4 | from .common import InfoExtractor |
73aeb2dc | 5 | from ..compat import compat_urlparse |
d6aa1967 | 6 | from ..utils import ( |
d6aa1967 M |
7 | ExtractorError, |
8 | ) | |
d6aa1967 M |
9 | |
10 | ||
11 | class GoshgayIE(InfoExtractor): | |
73aeb2dc | 12 | _VALID_URL = r'https?://www\.goshgay\.com/video(?P<id>\d+?)($|/)' |
d6aa1967 M |
13 | _TEST = { |
14 | 'url': 'http://www.goshgay.com/video4116282', | |
15 | 'md5': '268b9f3c3229105c57859e166dd72b03', | |
16 | 'info_dict': { | |
17 | 'id': '4116282', | |
18 | 'ext': 'flv', | |
19 | 'title': 'md5:089833a4790b5e103285a07337f245bf', | |
20 | 'thumbnail': 're:http://.*\.jpg', | |
3dfd25b3 | 21 | 'age_limit': 18, |
d6aa1967 M |
22 | } |
23 | } | |
24 | ||
25 | def _real_extract(self, url): | |
5d63b0aa | 26 | video_id = self._match_id(url) |
d6aa1967 | 27 | webpage = self._download_webpage(url, video_id) |
73aeb2dc | 28 | |
5d63b0aa NJ |
29 | title = self._og_search_title(webpage) |
30 | thumbnail = self._og_search_thumbnail(webpage) | |
31 | family_friendly = self._html_search_meta( | |
32 | 'isFamilyFriendly', webpage, default='false') | |
33 | config_url = self._search_regex( | |
34 | r"'config'\s*:\s*'([^']+)'", webpage, 'config URL') | |
d6aa1967 | 35 | |
5d63b0aa NJ |
36 | config = self._download_xml( |
37 | config_url, video_id, 'Downloading player config XML') | |
d6aa1967 | 38 | |
5d63b0aa | 39 | if config is None: |
d6aa1967 | 40 | raise ExtractorError('Missing config XML') |
5d63b0aa | 41 | if config.tag != 'config': |
d6aa1967 | 42 | raise ExtractorError('Missing config attribute') |
5d63b0aa NJ |
43 | fns = config.findall('file') |
44 | if len(fns) < 1: | |
d6aa1967 M |
45 | raise ExtractorError('Missing media URI') |
46 | video_url = fns[0].text | |
d6aa1967 M |
47 | |
48 | url_comp = compat_urlparse.urlparse(url) | |
49 | ref = "%s://%s%s" % (url_comp[0], url_comp[1], url_comp[2]) | |
50 | ||
51 | return { | |
52 | 'id': video_id, | |
53 | 'url': video_url, | |
54 | 'title': title, | |
d6aa1967 M |
55 | 'thumbnail': thumbnail, |
56 | 'http_referer': ref, | |
5d63b0aa | 57 | 'age_limit': 0 if family_friendly == 'true' else 18, |
d6aa1967 | 58 | } |