Compare commits

..

6 Commits

View File

@ -5,7 +5,6 @@ from ..utils import (
extract_attributes,
get_element_by_attribute,
get_element_by_class,
get_element_by_id,
get_element_html_by_class,
get_elements_by_class,
int_or_none,
@ -13,7 +12,9 @@ from ..utils import (
parse_duration,
remove_end,
str_to_int,
traverse_obj,
unescapeHTML,
url_or_none,
)
from .common import InfoExtractor
@ -31,14 +32,16 @@ class Rule34VideoIE(InfoExtractor):
'thumbnail': 'https://rule34video.com/contents/videos_screenshots/3065000/3065157/preview.jpg',
'duration': 347.0,
'age_limit': 18,
'view_count': int,
'like_count': int,
'comment_count': int,
'timestamp': 1639872000,
'description': 'https://discord.gg/aBqPrHSHvv',
'creator': None,
'upload_date': '20211219',
'uploader': 'Sweet HMV',
'uploader_url': 'https://rule34video.com/members/22119/',
'categories': ['3D', 'MMD', 'iwara'],
'tags': 'count:14'
'tags': 'mincount:10'
}
},
{
@ -51,14 +54,17 @@ class Rule34VideoIE(InfoExtractor):
'thumbnail': 'https://rule34video.com/contents/videos_screenshots/3065000/3065296/preview.jpg',
'duration': 938.0,
'age_limit': 18,
'view_count': int,
'like_count': int,
'comment_count': int,
'description': None,
'timestamp': 1640131200,
'description': '',
'creator': 'WildeerStudio',
'upload_date': '20211222',
'uploader': 'CerZule',
'uploader_url': 'https://rule34video.com/members/36281/',
'categories': ['3D', 'Tomb Raider'],
'tags': 'count:50'
'tags': 'mincount:40'
}
},
]
@ -77,21 +83,18 @@ class Rule34VideoIE(InfoExtractor):
'quality': quality,
})
title = self._html_extract_title(webpage)
thumbnail = self._html_search_regex(r'preview_url:\s+\'([^\']+)\'', webpage, 'thumbnail', default=None)
duration = self._html_search_regex(r'"icon-clock"></i>\s+<span>((?:\d+:?)+)', webpage, 'duration', default=None)
like_count = str_to_int(remove_end(get_element_by_class('voters count', webpage), ' likes'))
json_ld = self._search_json_ld(webpage, video_id, default={})
title = self._html_extract_title(webpage) or json_ld.get('title')
thumbnail = (self._html_search_regex(r'preview_url:\s+\'([^\']+)\'', webpage, 'thumbnail', default=None)
or traverse_obj(json_ld.get('thumbnails'), (0, 'url'), expected_type=url_or_none))
duration = parse_duration(self._html_search_regex(r'"icon-clock"></i>\s+<span>((?:\d+:?)+)', webpage, 'duration', default=None)) or json_ld.get('duration')
view_count = int_or_none(self._html_search_regex(r'"icon-eye"></i>\s+<span>([ \d]+)', webpage, 'views', default='').replace(' ', '')) or json_ld.get('view_count')
like_count = str_to_int(remove_end(get_element_by_class('voters count', webpage), ' likes')) or json_ld.get('like_count')
comment_count = int_or_none(self._search_regex(r'[^(]+\((\d+)\)', get_element_by_attribute(
'href', '#tab_comments', webpage), 'comment count', fatal=False))
description = None
video_info_element = get_element_by_id('tab_video_info', webpage)
info_labels = get_elements_by_class('label', video_info_element)
for label in info_labels:
label_clean = label.strip(' \n\t')
if label_clean.startswith('Description:'):
description = clean_html(label_clean[len('Description:'):])
break
timestamp = json_ld.get('timestamp')
description = json_ld.get('description')
categories = None
creator = None
@ -111,10 +114,12 @@ class Rule34VideoIE(InfoExtractor):
'formats': formats,
'title': title,
'thumbnail': thumbnail,
'duration': parse_duration(duration),
'duration': duration,
'age_limit': 18,
'view_count': view_count,
'like_count': like_count,
'comment_count': comment_count,
'timestamp': timestamp,
'description': description,
'creator': creator,
'uploader': uploader,