From 1a53a2eb631ed65975a963d2fa22eb445a6ce4ab Mon Sep 17 00:00:00 2001 From: gmes78 Date: Fri, 27 Jun 2025 10:28:11 +0100 Subject: [PATCH 1/6] [ie/rule34video] Fix text labels --- yt_dlp/extractor/rule34video.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yt_dlp/extractor/rule34video.py b/yt_dlp/extractor/rule34video.py index 3630f5e40..481e3222a 100644 --- a/yt_dlp/extractor/rule34video.py +++ b/yt_dlp/extractor/rule34video.py @@ -83,11 +83,11 @@ def _real_extract(self, url): categories, creators, uploader, uploader_url = [None] * 4 for col in get_elements_by_class('col', webpage): 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))) - elif label == 'Artist:': + elif label == 'Artist': 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_url = extract_attributes(get_element_html_by_class('name', col) or '').get('href') From 7b336d1e735b996a537a5170286f125b121f857d Mon Sep 17 00:00:00 2001 From: gmes78 Date: Fri, 27 Jun 2025 10:29:44 +0100 Subject: [PATCH 2/6] [ie/rule34video] Fix finding the uploader --- yt_dlp/extractor/rule34video.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/yt_dlp/extractor/rule34video.py b/yt_dlp/extractor/rule34video.py index 481e3222a..7e80f3dde 100644 --- a/yt_dlp/extractor/rule34video.py +++ b/yt_dlp/extractor/rule34video.py @@ -88,8 +88,9 @@ def _real_extract(self, url): elif label == 'Artist': creators = list(map(clean_html, get_elements_by_class('item', col))) elif label == 'Uploaded by': - uploader = clean_html(get_element_by_class('name', col)) - uploader_url = extract_attributes(get_element_html_by_class('name', col) or '').get('href') + uploader_link = get_element_html_by_class('btn_link', col) + uploader = clean_html(uploader_link) + uploader_url = extract_attributes(uploader_link or '').get('href') return { **traverse_obj(self._search_json_ld(webpage, video_id, default={}), ({ From f44a01bf67db996486d0bb24d040383c100628c5 Mon Sep 17 00:00:00 2001 From: gmes78 Date: Fri, 27 Jun 2025 10:42:20 +0100 Subject: [PATCH 3/6] [ie/rule34video] Properly fall back to JSON-LD info --- yt_dlp/extractor/rule34video.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/yt_dlp/extractor/rule34video.py b/yt_dlp/extractor/rule34video.py index 7e80f3dde..915e3e86d 100644 --- a/yt_dlp/extractor/rule34video.py +++ b/yt_dlp/extractor/rule34video.py @@ -9,6 +9,7 @@ get_element_html_by_class, get_elements_by_class, int_or_none, + merge_dicts, parse_count, parse_duration, unescapeHTML, @@ -92,16 +93,17 @@ def _real_extract(self, url): uploader = clean_html(uploader_link) uploader_url = extract_attributes(uploader_link or '').get('href') - return { - **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'), - })), + 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, 'formats': formats, 'title': self._html_extract_title(webpage), @@ -121,4 +123,4 @@ def _real_extract(self, url): 'categories': categories, 'tags': list(map(unescapeHTML, re.findall( r']+\bhref="https://rule34video\.com/tags/\d+/"[^>]*>(?P[^>]*)', webpage))), - } + }, json_ld) From 2f9e5789b7991f1f5cd6fc46d7db311799161939 Mon Sep 17 00:00:00 2001 From: gmes78 Date: Fri, 27 Jun 2025 11:15:22 +0100 Subject: [PATCH 4/6] [ie/rule34video] Fix extracting like count --- yt_dlp/extractor/rule34video.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/yt_dlp/extractor/rule34video.py b/yt_dlp/extractor/rule34video.py index 915e3e86d..525d85e37 100644 --- a/yt_dlp/extractor/rule34video.py +++ b/yt_dlp/extractor/rule34video.py @@ -93,6 +93,10 @@ def _real_extract(self, url): uploader = clean_html(uploader_link) uploader_url = extract_attributes(uploader_link or '').get('href') + 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', @@ -113,7 +117,7 @@ def _real_extract(self, url): r'"icon-clock">\s+((?:\d+:?)+)', webpage, 'duration', default=None)), 'view_count': int_or_none(self._html_search_regex( r'"icon-eye">\s+([ \d]+)', webpage, 'views', default='').replace(' ', '')), - 'like_count': parse_count(get_element_by_class('voters count', webpage)), + 'like_count': like_count, 'comment_count': int_or_none(self._search_regex( r'[^(]+\((\d+)\)', get_element_by_attribute('href', '#tab_comments', webpage), 'comment count', fatal=False)), 'age_limit': 18, From 9d46daeff762db21ab8c5b968a11de45e4899bf5 Mon Sep 17 00:00:00 2001 From: gmes78 Date: Fri, 27 Jun 2025 11:45:31 +0100 Subject: [PATCH 5/6] [ie/rule34video] Fix extracting duration and view count --- yt_dlp/extractor/rule34video.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/yt_dlp/extractor/rule34video.py b/yt_dlp/extractor/rule34video.py index 525d85e37..7eb3c6f1f 100644 --- a/yt_dlp/extractor/rule34video.py +++ b/yt_dlp/extractor/rule34video.py @@ -93,6 +93,15 @@ def _real_extract(self, url): uploader = clean_html(uploader_link) uploader_url = extract_attributes(uploader_link or '').get('href') + view_count, duration = [None] * 2 + for item_info in get_elements_by_class('item_info', webpage): + item_info_text = clean_html(item_info) + if get_element_by_class('custom-eye', item_info) is not None: + precise_view_count = re.search(r'\(([\d,]+)\)', item_info_text) + view_count = parse_count(precise_view_count.group(1) if precise_view_count is not None else item_info_text) + elif get_element_by_class('custom-time', item_info) is not None: + duration = parse_duration(clean_html(item_info)) + 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)) @@ -113,10 +122,8 @@ def _real_extract(self, url): 'title': self._html_extract_title(webpage), 'thumbnail': self._html_search_regex( r'preview_url:\s+\'([^\']+)\'', webpage, 'thumbnail', default=None), - 'duration': parse_duration(self._html_search_regex( - r'"icon-clock">\s+((?:\d+:?)+)', webpage, 'duration', default=None)), - 'view_count': int_or_none(self._html_search_regex( - r'"icon-eye">\s+([ \d]+)', webpage, 'views', default='').replace(' ', '')), + 'duration': duration, + 'view_count': view_count, 'like_count': like_count, 'comment_count': int_or_none(self._search_regex( r'[^(]+\((\d+)\)', get_element_by_attribute('href', '#tab_comments', webpage), 'comment count', fatal=False)), From 2e7b3d38b9ebc387463de0c4777bd841466d62a3 Mon Sep 17 00:00:00 2001 From: gmes78 Date: Fri, 27 Jun 2025 12:24:44 +0100 Subject: [PATCH 6/6] [ie/rule34video] Set format height instead of quality --- yt_dlp/extractor/rule34video.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yt_dlp/extractor/rule34video.py b/yt_dlp/extractor/rule34video.py index 7eb3c6f1f..bfcd7110e 100644 --- a/yt_dlp/extractor/rule34video.py +++ b/yt_dlp/extractor/rule34video.py @@ -73,12 +73,12 @@ def _real_extract(self, url): formats = [] - for mobj in re.finditer(r']+href="(?P[^"]+download=true[^"]+)".*>(?P[^\s]+) (?P[^<]+)p', webpage): - url, ext, quality = mobj.groups() + for mobj in re.finditer(r']+href="(?P[^"]+download=true[^"]+)".*>(?P[^\s]+) (?P[^<]+)p', webpage): + url, ext, height = mobj.groups() formats.append({ 'url': url, 'ext': ext.lower(), - 'quality': quality, + 'height': int_or_none(height), }) categories, creators, uploader, uploader_url = [None] * 4