]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/iwara.py
debian/control: Rerun wrap-and-sort.
[youtubedl] / youtube_dl / extractor / iwara.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..compat import compat_urllib_parse_urlparse
6 from ..utils import remove_end
7
8
9 class IwaraIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.|ecchi\.)?iwara\.tv/videos/(?P<id>[a-zA-Z0-9]+)'
11 _TESTS = [{
12 'url': 'http://iwara.tv/videos/amVwUl1EHpAD9RD',
13 'md5': '1d53866b2c514b23ed69e4352fdc9839',
14 'info_dict': {
15 'id': 'amVwUl1EHpAD9RD',
16 'ext': 'mp4',
17 'title': '【MMD R-18】ガールフレンド carry_me_off',
18 'age_limit': 18,
19 },
20 }, {
21 'url': 'http://ecchi.iwara.tv/videos/Vb4yf2yZspkzkBO',
22 'md5': '7e5f1f359cd51a027ba4a7b7710a50f0',
23 'info_dict': {
24 'id': '0B1LvuHnL-sRFNXB1WHNqbGw4SXc',
25 'ext': 'mp4',
26 'title': '[3D Hentai] Kyonyu Ã\x97 Genkai Ã\x97 Emaki Shinobi Girls.mp4',
27 'age_limit': 18,
28 },
29 'add_ie': ['GoogleDrive'],
30 }, {
31 'url': 'http://www.iwara.tv/videos/nawkaumd6ilezzgq',
32 'md5': '1d85f1e5217d2791626cff5ec83bb189',
33 'info_dict': {
34 'id': '6liAP9s2Ojc',
35 'ext': 'mp4',
36 'age_limit': 0,
37 'title': '[MMD] Do It Again Ver.2 [1080p 60FPS] (Motion,Camera,Wav+DL)',
38 'description': 'md5:590c12c0df1443d833fbebe05da8c47a',
39 'upload_date': '20160910',
40 'uploader': 'aMMDsork',
41 'uploader_id': 'UCVOFyOSCyFkXTYYHITtqB7A',
42 },
43 'add_ie': ['Youtube'],
44 }]
45
46 def _real_extract(self, url):
47 video_id = self._match_id(url)
48
49 webpage, urlh = self._download_webpage_handle(url, video_id)
50
51 hostname = compat_urllib_parse_urlparse(urlh.geturl()).hostname
52 # ecchi is 'sexy' in Japanese
53 age_limit = 18 if hostname.split('.')[0] == 'ecchi' else 0
54
55 entries = self._parse_html5_media_entries(url, webpage, video_id)
56
57 if not entries:
58 iframe_url = self._html_search_regex(
59 r'<iframe[^>]+src=([\'"])(?P<url>[^\'"]+)\1',
60 webpage, 'iframe URL', group='url')
61 return {
62 '_type': 'url_transparent',
63 'url': iframe_url,
64 'age_limit': age_limit,
65 }
66
67 title = remove_end(self._html_search_regex(
68 r'<title>([^<]+)</title>', webpage, 'title'), ' | Iwara')
69
70 info_dict = entries[0]
71 info_dict.update({
72 'id': video_id,
73 'title': title,
74 'age_limit': age_limit,
75 })
76
77 return info_dict