2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..compat
import compat_urlparse
16 class PiaproIE(InfoExtractor
):
17 _NETRC_MACHINE
= 'piapro'
18 _VALID_URL
= r
'https?://piapro\.jp/t/(?P<id>\w+)/?'
20 'url': 'https://piapro.jp/t/NXYR',
21 'md5': 'a9d52f27d13bafab7ee34116a7dcfa77',
26 'uploader_id': 'wowaka',
28 'thumbnail': r
're:^https?://.*\.jpg$',
32 def _real_initialize(self
):
33 self
._login
_status
= self
._login
()
36 username
, password
= self
._get
_login
_info
()
41 '_username': username
,
42 '_password': password
,
46 self
._request
_webpage
('https://piapro.jp/login/', None)
47 urlh
= self
._request
_webpage
(
48 'https://piapro.jp/login/exe', None,
49 note
='Logging in', errnote
='Unable to log in',
50 data
=urlencode_postdata(login_form_strs
))
54 parts
= compat_urlparse
.urlparse(urlh
.geturl())
59 'unable to log in: bad username or password')
62 def _real_extract(self
, url
):
63 video_id
= self
._match
_id
(url
)
64 webpage
= self
._download
_webpage
(url
, video_id
)
66 category_id
= self
._search
_regex
(r
'categoryId=(.+)">', webpage
, 'category ID')
67 if category_id
not in ('1', '2', '21', '22', '23', '24', '25'):
68 raise ExtractorError('The URL does not contain audio.', expected
=True)
70 str_duration
, str_filesize
= self
._search
_regex
(
71 r
'サイズ:</span>(.+?)/\(([0-9,]+?[KMG]?B))', webpage
, 'duration and size',
72 group
=(1, 2), default
=(None, None))
73 str_viewcount
= self
._search
_regex
(r
'閲覧数:</span>([0-9,]+)\s+', webpage
, 'view count', fatal
=False)
75 uploader_id
, uploader
= self
._search
_regex
(
76 r
'<a\s+class="cd_user-name"\s+href="/(.*)">([^<]+)さん<', webpage
, 'uploader',
77 group
=(1, 2), default
=(None, None))
78 content_id
= self
._search
_regex
(r
'contentId\:\'(.+)\'', webpage, 'content ID
')
79 create_date = self._search_regex(r'createDate\
:\'(.+)\'', webpage, 'timestamp
')
81 player_webpage = self._download_webpage(
82 f'https
://piapro
.jp
/html5_player_popup
/?
id={content_id}
&cdate
={create_date}
',
83 video_id, note='Downloading player webpage
')
87 'title
': self._html_search_regex(r'<h1\s
+class="cd_works-title">(.+?
)</h1
>', webpage, 'title
', fatal=False),
88 'description
': self._html_search_regex(r'<p\s
+class="cd_dtl_cap">(.+?
)</p
>\s
*<div
', webpage, 'description
', fatal=False),
90 'uploader_id
': uploader_id,
91 'timestamp
': unified_timestamp(create_date, False),
92 'duration
': parse_duration(str_duration),
93 'view_count
': str_to_int(str_viewcount),
94 'thumbnail
': self._html_search_meta('twitter
:image
', webpage),
96 'filesize_approx
': parse_filesize(str_filesize.replace(',', '')),
97 'url
': self._search_regex(r'mp3
:\s
*\'(.*?
)\'\
}', player_webpage, 'url
'),