mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-26 21:59:08 +01:00
[ie/Piapro] Fix extractor (#9311)
Closes #9884 Authored by: FinnRG, seproDev
This commit is contained in:
parent
0d067e77c3
commit
3ba8de62d6
1 changed files with 14 additions and 24 deletions
|
@ -2,6 +2,8 @@ from .common import InfoExtractor
|
||||||
from ..compat import compat_urlparse
|
from ..compat import compat_urlparse
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
|
clean_html,
|
||||||
|
get_element_by_class,
|
||||||
parse_duration,
|
parse_duration,
|
||||||
parse_filesize,
|
parse_filesize,
|
||||||
str_to_int,
|
str_to_int,
|
||||||
|
@ -88,34 +90,22 @@ class PiaproIE(InfoExtractor):
|
||||||
if category_id not in ('1', '2', '21', '22', '23', '24', '25'):
|
if category_id not in ('1', '2', '21', '22', '23', '24', '25'):
|
||||||
raise ExtractorError('The URL does not contain audio.', expected=True)
|
raise ExtractorError('The URL does not contain audio.', expected=True)
|
||||||
|
|
||||||
str_duration, str_filesize = self._search_regex(
|
def extract_info(name, description):
|
||||||
r'サイズ:</span>(.+?)/\(([0-9,]+?[KMG]?B))', webpage, 'duration and size',
|
return self._search_regex(rf'{name}[::]\s*([\d\s,:/]+)\s*</p>', webpage, description, default=None)
|
||||||
group=(1, 2), default=(None, None))
|
|
||||||
str_viewcount = self._search_regex(r'閲覧数:</span>([0-9,]+)\s+', webpage, 'view count', fatal=False)
|
|
||||||
|
|
||||||
uploader_id, uploader = self._search_regex(
|
|
||||||
r'<a\s+class="cd_user-name"\s+href="/(.*)">([^<]+)さん<', webpage, 'uploader',
|
|
||||||
group=(1, 2), default=(None, None))
|
|
||||||
content_id = self._search_regex(r'contentId\:\'(.+)\'', webpage, 'content ID')
|
|
||||||
create_date = self._search_regex(r'createDate\:\'(.+)\'', webpage, 'timestamp')
|
|
||||||
|
|
||||||
player_webpage = self._download_webpage(
|
|
||||||
f'https://piapro.jp/html5_player_popup/?id={content_id}&cdate={create_date}',
|
|
||||||
video_id, note='Downloading player webpage')
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': self._html_search_regex(r'<h1\s+class="cd_works-title">(.+?)</h1>', webpage, 'title', fatal=False),
|
'title': clean_html(get_element_by_class('contents_title', webpage)),
|
||||||
'description': self._html_search_regex(r'(?s)<p\s+class="cd_dtl_cap">(.+?)</p>\s*<div', webpage, 'description', fatal=False),
|
'description': clean_html(get_element_by_class('contents_description', webpage)),
|
||||||
'uploader': uploader,
|
'uploader': clean_html(get_element_by_class('contents_creator_txt', webpage)),
|
||||||
'uploader_id': uploader_id,
|
'uploader_id': self._search_regex(
|
||||||
'timestamp': unified_timestamp(create_date, False),
|
r'<a\s+href="/([^"]+)"', get_element_by_class('contents_creator', webpage), 'uploader id', default=None),
|
||||||
'duration': parse_duration(str_duration),
|
'timestamp': unified_timestamp(extract_info('投稿日', 'timestamp'), False),
|
||||||
'view_count': str_to_int(str_viewcount),
|
'duration': parse_duration(extract_info('長さ', 'duration')),
|
||||||
|
'view_count': str_to_int(extract_info('閲覧数', 'view count')),
|
||||||
'thumbnail': self._html_search_meta('twitter:image', webpage),
|
'thumbnail': self._html_search_meta('twitter:image', webpage),
|
||||||
|
'filesize_approx': parse_filesize((extract_info('サイズ', 'size') or '').replace(',', '')),
|
||||||
'filesize_approx': parse_filesize(str_filesize.replace(',', '')),
|
'url': self._search_regex(r'\"url\":\s*\"(.*?)\"', webpage, 'url'),
|
||||||
'url': self._search_regex(r'mp3:\s*\'(.*?)\'\}', player_webpage, 'url'),
|
|
||||||
'ext': 'mp3',
|
'ext': 'mp3',
|
||||||
'vcodec': 'none',
|
'vcodec': 'none',
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue