]> jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/anitube.py
[anitube] Skip test (on travis)
[yt-dlp.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 u'skip': u'Blocked in the US',
21 }
22
23 def _real_extract(self, url):
24 mobj = re.match(self._VALID_URL, url)
25 video_id = mobj.group('id')
26
27 webpage = self._download_webpage(url, video_id)
28 key = self._html_search_regex(r'http://www\.anitube\.se/embed/([A-Za-z0-9_-]*)',
29 webpage, u'key')
30
31 webpage_config = self._download_webpage('http://www.anitube.se/nuevo/econfig.php?key=%s' % key,
32 key)
33 config_xml = xml.etree.ElementTree.fromstring(webpage_config.encode('utf-8'))
34
35 video_title = config_xml.find('title').text
36
37 formats = []
38 video_url = config_xml.find('file')
39 if video_url is not None:
40 formats.append({
41 'format_id': 'sd',
42 'url': video_url.text,
43 })
44 video_url = config_xml.find('filehd')
45 if video_url is not None:
46 formats.append({
47 'format_id': 'hd',
48 'url': video_url.text,
49 })
50
51 return {
52 'id': video_id,
53 'title': video_title,
54 'formats': formats
55 }