1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-08-18 02:18:29 +00:00
This commit is contained in:
gmes78 2025-08-10 04:25:49 +01:00 committed by GitHub
commit 54fc2c2d4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,6 +9,7 @@
get_element_html_by_class, get_element_html_by_class,
get_elements_by_class, get_elements_by_class,
int_or_none, int_or_none,
merge_dicts,
parse_count, parse_count,
parse_duration, parse_duration,
unescapeHTML, unescapeHTML,
@ -72,45 +73,58 @@ def _real_extract(self, url):
formats = [] formats = []
for mobj in re.finditer(r'<a[^>]+href="(?P<video_url>[^"]+download=true[^"]+)".*>(?P<ext>[^\s]+) (?P<quality>[^<]+)p</a>', webpage): for mobj in re.finditer(r'<a[^>]+href="(?P<video_url>[^"]+download=true[^"]+)".*>(?P<ext>[^\s]+) (?P<height>[^<]+)p</a>', webpage):
url, ext, quality = mobj.groups() url, ext, height = mobj.groups()
formats.append({ formats.append({
'url': url, 'url': url,
'ext': ext.lower(), 'ext': ext.lower(),
'quality': quality, 'height': int_or_none(height),
}) })
categories, creators, uploader, uploader_url = [None] * 4 categories, creators, uploader, uploader_url = [None] * 4
for col in get_elements_by_class('col', webpage): for col in get_elements_by_class('col', webpage):
label = clean_html(get_element_by_class('label', col)) label = clean_html(get_element_by_class('label', col))
if label == 'Categories:': if label == 'Categories':
categories = list(map(clean_html, get_elements_by_class('item', col))) categories = list(map(clean_html, get_elements_by_class('item', col)))
elif label == 'Artist:': elif label == 'Artist':
creators = list(map(clean_html, get_elements_by_class('item', col))) creators = list(map(clean_html, get_elements_by_class('item', col)))
elif label == 'Uploaded By:': elif label == 'Uploaded by':
uploader = clean_html(get_element_by_class('name', col)) uploader_link = get_element_html_by_class('btn_link', col)
uploader_url = extract_attributes(get_element_html_by_class('name', col) or '').get('href') uploader = clean_html(uploader_link)
uploader_url = extract_attributes(uploader_link or '').get('href')
return { view_count, duration = [None] * 2
**traverse_obj(self._search_json_ld(webpage, video_id, default={}), ({ for item_info in get_elements_by_class('item_info', webpage):
'title': 'title', item_info_text = clean_html(item_info)
'view_count': 'view_count', if get_element_by_class('custom-eye', item_info) is not None:
'like_count': 'like_count', precise_view_count = re.search(r'\(([\d,]+)\)', item_info_text)
'duration': 'duration', view_count = parse_count(precise_view_count.group(1) if precise_view_count is not None else item_info_text)
'timestamp': 'timestamp', elif get_element_by_class('custom-time', item_info) is not None:
'description': 'description', duration = parse_duration(clean_html(item_info))
'thumbnail': ('thumbnails', 0, 'url'),
})), like_count = None
if like_count_text := re.search(r'\(([\d,]+)\)', get_element_by_class('voters count', webpage)):
like_count = parse_count(like_count_text.group(1))
json_ld = traverse_obj(self._search_json_ld(webpage, video_id, default={}), ({
'title': 'title',
'view_count': 'view_count',
'like_count': 'like_count',
'duration': 'duration',
'timestamp': 'timestamp',
'description': 'description',
'thumbnail': ('thumbnails', 0, 'url'),
}))
return merge_dicts({
'id': video_id, 'id': video_id,
'formats': formats, 'formats': formats,
'title': self._html_extract_title(webpage), 'title': self._html_extract_title(webpage),
'thumbnail': self._html_search_regex( 'thumbnail': self._html_search_regex(
r'preview_url:\s+\'([^\']+)\'', webpage, 'thumbnail', default=None), r'preview_url:\s+\'([^\']+)\'', webpage, 'thumbnail', default=None),
'duration': parse_duration(self._html_search_regex( 'duration': duration,
r'"icon-clock"></i>\s+<span>((?:\d+:?)+)', webpage, 'duration', default=None)), 'view_count': view_count,
'view_count': int_or_none(self._html_search_regex( 'like_count': like_count,
r'"icon-eye"></i>\s+<span>([ \d]+)', webpage, 'views', default='').replace(' ', '')),
'like_count': parse_count(get_element_by_class('voters count', webpage)),
'comment_count': int_or_none(self._search_regex( 'comment_count': int_or_none(self._search_regex(
r'[^(]+\((\d+)\)', get_element_by_attribute('href', '#tab_comments', webpage), 'comment count', fatal=False)), r'[^(]+\((\d+)\)', get_element_by_attribute('href', '#tab_comments', webpage), 'comment count', fatal=False)),
'age_limit': 18, 'age_limit': 18,
@ -120,4 +134,4 @@ def _real_extract(self, url):
'categories': categories, 'categories': categories,
'tags': list(map(unescapeHTML, re.findall( 'tags': list(map(unescapeHTML, re.findall(
r'<a class="tag_item"[^>]+\bhref="https://rule34video\.com/tags/\d+/"[^>]*>(?P<tag>[^>]*)</a>', webpage))), r'<a class="tag_item"[^>]+\bhref="https://rule34video\.com/tags/\d+/"[^>]*>(?P<tag>[^>]*)</a>', webpage))),
} }, json_ld)