]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/porn91.py
debian/changelog: Wrap long line.
[youtubedl] / youtube_dl / extractor / porn91.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 parse_duration,
7 int_or_none,
8 ExtractorError,
9 )
10
11
12 class Porn91IE(InfoExtractor):
13 IE_NAME = '91porn'
14 _VALID_URL = r'(?:https?://)(?:www\.|)91porn\.com/.+?\?viewkey=(?P<id>[\w\d]+)'
15
16 _TEST = {
17 'url': 'http://91porn.com/view_video.php?viewkey=7e42283b4f5ab36da134',
18 'md5': '7fcdb5349354f40d41689bd0fa8db05a',
19 'info_dict': {
20 'id': '7e42283b4f5ab36da134',
21 'title': '18岁大一漂亮学妹,水嫩性感,再爽一次!',
22 'ext': 'mp4',
23 'duration': 431,
24 'age_limit': 18,
25 }
26 }
27
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
30 self._set_cookie('91porn.com', 'language', 'cn_CN')
31
32 webpage = self._download_webpage(
33 'http://91porn.com/view_video.php?viewkey=%s' % video_id, video_id)
34
35 if '作为游客,你每天只可观看10个视频' in webpage:
36 raise ExtractorError('91 Porn says: Daily limit 10 videos exceeded', expected=True)
37
38 title = self._search_regex(
39 r'<div id="viewvideo-title">([^<]+)</div>', webpage, 'title')
40 title = title.replace('\n', '')
41
42 video_link_url = self._search_regex(
43 r'<textarea[^>]+id=["\']fm-video_link[^>]+>([^<]+)</textarea>',
44 webpage, 'video link')
45 videopage = self._download_webpage(video_link_url, video_id)
46
47 info_dict = self._parse_html5_media_entries(url, videopage, video_id)[0]
48
49 duration = parse_duration(self._search_regex(
50 r'时长:\s*</span>\s*(\d+:\d+)', webpage, 'duration', fatal=False))
51
52 comment_count = int_or_none(self._search_regex(
53 r'留言:\s*</span>\s*(\d+)', webpage, 'comment count', fatal=False))
54
55 info_dict.update({
56 'id': video_id,
57 'title': title,
58 'duration': duration,
59 'comment_count': comment_count,
60 'age_limit': self._rta_search(webpage),
61 })
62
63 return info_dict