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