]>
Commit | Line | Data |
---|---|---|
93881db2 S |
1 | from __future__ import unicode_literals |
2 | ||
ba3881df | 3 | import re |
ba3881df AL |
4 | |
5 | from .common import InfoExtractor | |
6 | ||
7 | ||
8 | class AnitubeIE(InfoExtractor): | |
93881db2 | 9 | IE_NAME = 'anitube.se' |
8f053519 | 10 | _VALID_URL = r'https?://(?:www\.)?anitube\.se/video/(?P<id>\d+)' |
ba3881df AL |
11 | |
12 | _TEST = { | |
93881db2 S |
13 | 'url': 'http://www.anitube.se/video/36621', |
14 | 'md5': '59d0eeae28ea0bc8c05e7af429998d43', | |
15 | 'info_dict': { | |
16 | 'id': '36621', | |
17 | 'ext': 'mp4', | |
18 | 'title': 'Recorder to Randoseru 01', | |
19 | 'duration': 180.19, | |
ba3881df | 20 | }, |
93881db2 | 21 | 'skip': 'Blocked in the US', |
ba3881df AL |
22 | } |
23 | ||
24 | def _real_extract(self, url): | |
25 | mobj = re.match(self._VALID_URL, url) | |
26 | video_id = mobj.group('id') | |
27 | ||
28 | webpage = self._download_webpage(url, video_id) | |
93881db2 S |
29 | key = self._html_search_regex( |
30 | r'http://www\.anitube\.se/embed/([A-Za-z0-9_-]*)', webpage, 'key') | |
ba3881df | 31 | |
93881db2 S |
32 | config_xml = self._download_xml( |
33 | 'http://www.anitube.se/nuevo/econfig.php?key=%s' % key, key) | |
ba3881df AL |
34 | |
35 | video_title = config_xml.find('title').text | |
93881db2 S |
36 | thumbnail = config_xml.find('image').text |
37 | duration = float(config_xml.find('duration').text) | |
ba3881df | 38 | |
ba3881df | 39 | formats = [] |
ba3881df AL |
40 | video_url = config_xml.find('file') |
41 | if video_url is not None: | |
42 | formats.append({ | |
43 | 'format_id': 'sd', | |
44 | 'url': video_url.text, | |
45 | }) | |
ba3881df AL |
46 | video_url = config_xml.find('filehd') |
47 | if video_url is not None: | |
48 | formats.append({ | |
49 | 'format_id': 'hd', | |
50 | 'url': video_url.text, | |
51 | }) | |
52 | ||
53 | return { | |
54 | 'id': video_id, | |
55 | 'title': video_title, | |
93881db2 S |
56 | 'thumbnail': thumbnail, |
57 | 'duration': duration, | |
ba3881df AL |
58 | 'formats': formats |
59 | } |