]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/anitube.py
Update changelog.
[youtubedl] / youtube_dl / extractor / anitube.py
1 import re
2
3 from .common import InfoExtractor
4
5
6 class AnitubeIE(InfoExtractor):
7 IE_NAME = u'anitube.se'
8 _VALID_URL = r'https?://(?:www\.)?anitube\.se/video/(?P<id>\d+)'
9
10 _TEST = {
11 u'url': u'http://www.anitube.se/video/36621',
12 u'md5': u'59d0eeae28ea0bc8c05e7af429998d43',
13 u'file': u'36621.mp4',
14 u'info_dict': {
15 u'id': u'36621',
16 u'ext': u'mp4',
17 u'title': u'Recorder to Randoseru 01',
18 },
19 u'skip': u'Blocked in the US',
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 config_xml = self._download_xml('http://www.anitube.se/nuevo/econfig.php?key=%s' % key,
31 key)
32
33 video_title = config_xml.find('title').text
34
35 formats = []
36 video_url = config_xml.find('file')
37 if video_url is not None:
38 formats.append({
39 'format_id': 'sd',
40 'url': video_url.text,
41 })
42 video_url = config_xml.find('filehd')
43 if video_url is not None:
44 formats.append({
45 'format_id': 'hd',
46 'url': video_url.text,
47 })
48
49 return {
50 'id': video_id,
51 'title': video_title,
52 'formats': formats
53 }