[nuevo] Generalize nuevo extractor and add support for trollvids
[youtube-dl] / youtube_dl / extractor / anitube.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .nuevo import NuevoBaseIE
6
7
8 class AnitubeIE(NuevoBaseIE):
9     IE_NAME = 'anitube.se'
10     _VALID_URL = r'https?://(?:www\.)?anitube\.se/video/(?P<id>\d+)'
11
12     _TEST = {
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,
20         },
21         'skip': 'Blocked in the US',
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)
29         key = self._search_regex(
30             r'src=["\']https?://[^/]+/embed/([A-Za-z0-9_-]+)', webpage, 'key')
31
32         config_url = 'http://www.anitube.se/nuevo/econfig.php?key=%s' % key
33         return self._extract_nuevo(config_url, video_id)