2 from __future__
import unicode_literals
5 from .common
import InfoExtractor
6 from ..compat
import compat_urllib_parse_urlparse
17 class IwaraIE(InfoExtractor
):
18 _VALID_URL
= r
'https?://(?:www\.|ecchi\.)?iwara\.tv/videos/(?P<id>[a-zA-Z0-9]+)'
20 'url': 'http://iwara.tv/videos/amVwUl1EHpAD9RD',
23 'id': 'amVwUl1EHpAD9RD',
25 'title': '【MMD R-18】ガールフレンド carry_me_off',
27 'thumbnail': 'https://i.iwara.tv/sites/default/files/videos/thumbnails/7951/thumbnail-7951_0001.png',
28 'uploader': 'Reimu丨Action',
29 'upload_date': '20150828',
30 'description': 'md5:1d4905ce48c66c9299c617f08e106e0f',
33 'url': 'http://ecchi.iwara.tv/videos/Vb4yf2yZspkzkBO',
34 'md5': '7e5f1f359cd51a027ba4a7b7710a50f0',
36 'id': '0B1LvuHnL-sRFNXB1WHNqbGw4SXc',
38 'title': '[3D Hentai] Kyonyu × Genkai × Emaki Shinobi Girls.mp4',
41 'add_ie': ['GoogleDrive'],
43 'url': 'http://www.iwara.tv/videos/nawkaumd6ilezzgq',
49 'title': '[MMD] Do It Again Ver.2 [1080p 60FPS] (Motion,Camera,Wav+DL)',
50 'description': 'md5:590c12c0df1443d833fbebe05da8c47a',
51 'upload_date': '20160910',
52 'uploader': 'aMMDsork',
53 'uploader_id': 'UCVOFyOSCyFkXTYYHITtqB7A',
55 'add_ie': ['Youtube'],
58 def _real_extract(self
, url
):
59 video_id
= self
._match
_id
(url
)
61 webpage
, urlh
= self
._download
_webpage
_handle
(url
, video_id
)
63 hostname
= compat_urllib_parse_urlparse(urlh
.geturl()).hostname
64 # ecchi is 'sexy' in Japanese
65 age_limit
= 18 if hostname
.split('.')[0] == 'ecchi' else 0
67 video_data
= self
._download
_json
('http://www.iwara.tv/api/video/%s' % video_id
, video_id
)
70 iframe_url
= self
._html
_search
_regex
(
71 r
'<iframe[^>]+src=([\'"])(?P<url>[^\'"]+)\
1',
72 webpage, 'iframe URL
', group='url
')
74 '_type
': 'url_transparent
',
76 'age_limit
': age_limit,
79 title = remove_end(self._html_search_regex(
80 r'<title
>([^
<]+)</title
>', webpage, 'title
'), ' | Iwara
')
82 thumbnail = self._html_search_regex(
83 r'poster
=[\'"]([^\'"]+)', webpage, 'thumbnail
', default=None)
85 uploader = self._html_search_regex(
86 r'class="username">([^
<]+)', webpage, 'uploader
', fatal=False)
88 upload_date = unified_strdate(self._html_search_regex(
89 r'作成日
:([^\s
]+)', webpage, 'upload_date
', fatal=False))
91 description = strip_or_none(self._search_regex(
92 r'<p
>(.+?
(?
=</div
))', webpage, 'description
', fatal=False,
96 for a_format in video_data:
97 format_uri = url_or_none(a_format.get('uri
'))
100 format_id = a_format.get('resolution
')
101 height = int_or_none(self._search_regex(
102 r'(\d
+)p
', format_id, 'height
', default=None))
104 'url
': self._proto_relative_url(format_uri, 'https
:'),
105 'format_id
': format_id,
106 'ext
': mimetype2ext(a_format.get('mime
')) or 'mp4
',
108 'width
': int_or_none(height / 9.0 * 16.0 if height else None),
109 'quality
': 1 if format_id == 'Source
' else 0,
112 self._sort_formats(formats)
117 'age_limit
': age_limit,
119 'thumbnail
': self._proto_relative_url(thumbnail, 'https
:'),
120 'uploader
': uploader,
121 'upload_date
': upload_date,
122 'description
': description,