]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/anitube.py
[toutv] really skip test
[youtube-dl.git] / youtube_dl / extractor / anitube.py
1 import re
2 import xml.etree.ElementTree
3
4 from .common import InfoExtractor
5
6
7 class AnitubeIE(InfoExtractor):
8     IE_NAME = u'anitube.se'
9     _VALID_URL = r'https?://(?:www\.)?anitube\.se/video/(?P<id>\d+)'
10
11     _TEST = {
12         u'url': u'http://www.anitube.se/video/36621',
13         u'md5': u'59d0eeae28ea0bc8c05e7af429998d43',
14         u'file': u'36621.mp4',
15         u'info_dict': {
16             u'id': u'36621',
17             u'ext': u'mp4',
18             u'title': u'Recorder to Randoseru 01',
19         },
20     }
21
22     def _real_extract(self, url):
23         mobj = re.match(self._VALID_URL, url)
24         video_id = mobj.group('id')
25
26         webpage = self._download_webpage(url, video_id)
27         key = self._html_search_regex(r'http://www\.anitube\.se/embed/([A-Za-z0-9_-]*)',
28                                       webpage, u'key')
29
30         webpage_config = self._download_webpage('http://www.anitube.se/nuevo/econfig.php?key=%s' % key,
31                                                 key)
32         config_xml = xml.etree.ElementTree.fromstring(webpage_config.encode('utf-8'))
33
34         video_title = config_xml.find('title').text
35
36         formats = []
37         video_url = config_xml.find('file')
38         if video_url is not None:
39             formats.append({
40                 'format_id': 'sd',
41                 'url': video_url.text,
42             })
43         video_url = config_xml.find('filehd')
44         if video_url is not None:
45             formats.append({
46                 'format_id': 'hd',
47                 'url': video_url.text,
48             })
49
50         return {
51             'id': video_id,
52             'title': video_title,
53             'formats': formats
54         }