Merge remote-tracking branch 'hojel/hentaistigma'
[youtube-dl] / youtube_dl / extractor / hentaistigma.py
1 import re
2
3 from .common import InfoExtractor
4
5 class HentaiStigmaIE(InfoExtractor):
6     _VALID_URL = r'^https?://hentai\.animestigma\.com/(?P<videoid>[^/]+)'
7     _TEST = {
8         u'url': u'http://hentai.animestigma.com/inyouchuu-etsu-bonus/',
9         u'file': u'inyouchuu-etsu-bonus.mp4',
10         u'md5': u'4e3d07422a68a4cc363d8f57c8bf0d23',
11         u'info_dict': {
12             u"title": u"Inyouchuu Etsu Bonus",
13             u"age_limit": 18,
14         }
15     }
16
17     def _real_extract(self, url):
18         mobj = re.match(self._VALID_URL, url)
19
20         video_id = mobj.group('videoid')
21
22         # Get webpage content
23         webpage = self._download_webpage(url, video_id)
24
25         # Get the video title
26         video_title = self._html_search_regex(r'<h2 class="posttitle"><a[^>]*>([^<]+)</a>',
27             webpage, u'title').strip()
28
29         # Get the wrapper url
30         wrap_url = self._html_search_regex(r'<iframe src="([^"]+mp4)"', webpage, u'wrapper url')
31
32         # Get wrapper content
33         wrap_webpage = self._download_webpage(wrap_url, video_id)
34
35         video_url = self._html_search_regex(r'clip:\s*{\s*url: "([^"]*)"', wrap_webpage, u'video url')
36
37         info = {'id': video_id,
38                 'url': video_url,
39                 'title': video_title,
40                 'format': 'mp4',
41                 'age_limit': 18}
42
43         return [info]