2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..compat
import compat_urllib_parse_urlparse
14 class IwaraIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:www\.|ecchi\.)?iwara\.tv/videos/(?P<id>[a-zA-Z0-9]+)'
17 'url': 'http://iwara.tv/videos/amVwUl1EHpAD9RD',
20 'id': 'amVwUl1EHpAD9RD',
22 'title': '【MMD R-18】ガールフレンド carry_me_off',
26 'url': 'http://ecchi.iwara.tv/videos/Vb4yf2yZspkzkBO',
27 'md5': '7e5f1f359cd51a027ba4a7b7710a50f0',
29 'id': '0B1LvuHnL-sRFNXB1WHNqbGw4SXc',
31 'title': '[3D Hentai] Kyonyu × Genkai × Emaki Shinobi Girls.mp4',
34 'add_ie': ['GoogleDrive'],
36 'url': 'http://www.iwara.tv/videos/nawkaumd6ilezzgq',
42 'title': '[MMD] Do It Again Ver.2 [1080p 60FPS] (Motion,Camera,Wav+DL)',
43 'description': 'md5:590c12c0df1443d833fbebe05da8c47a',
44 'upload_date': '20160910',
45 'uploader': 'aMMDsork',
46 'uploader_id': 'UCVOFyOSCyFkXTYYHITtqB7A',
48 'add_ie': ['Youtube'],
51 def _real_extract(self
, url
):
52 video_id
= self
._match
_id
(url
)
54 webpage
, urlh
= self
._download
_webpage
_handle
(url
, video_id
)
56 hostname
= compat_urllib_parse_urlparse(urlh
.geturl()).hostname
57 # ecchi is 'sexy' in Japanese
58 age_limit
= 18 if hostname
.split('.')[0] == 'ecchi' else 0
60 video_data
= self
._download
_json
('http://www.iwara.tv/api/video/%s' % video_id
, video_id
)
63 iframe_url
= self
._html
_search
_regex
(
64 r
'<iframe[^>]+src=([\'"])(?P<url>[^\'"]+)\
1',
65 webpage, 'iframe URL
', group='url
')
67 '_type
': 'url_transparent
',
69 'age_limit
': age_limit,
72 title = remove_end(self._html_search_regex(
73 r'<title
>([^
<]+)</title
>', webpage, 'title
'), ' | Iwara
')
76 for a_format in video_data:
77 format_uri = url_or_none(a_format.get('uri
'))
80 format_id = a_format.get('resolution
')
81 height = int_or_none(self._search_regex(
82 r'(\d
+)p
', format_id, 'height
', default=None))
84 'url
': self._proto_relative_url(format_uri, 'https
:'),
85 'format_id
': format_id,
86 'ext
': mimetype2ext(a_format.get('mime
')) or 'mp4
',
88 'width
': int_or_none(height / 9.0 * 16.0 if height else None),
89 'quality
': 1 if format_id == 'Source
' else 0,
92 self._sort_formats(formats)
97 'age_limit
': age_limit,