Compare commits

...

4 Commits

Author SHA1 Message Date
Franklin Lee
a0c52e4ba2
Merge ba50c89113 into a9f85670d0 2024-11-12 16:12:21 +05:30
manav_chaudhary
a9f85670d0
[ie/Chaturbate] Support alternate domains (#10595)
Closes #10594
Authored by: manavchaudhary1
2024-11-11 23:41:56 +01:00
Franklin Lee
ba50c89113
Merge branch 'yt-dlp:master' into master 2024-10-18 02:11:03 -07:00
Franklin Lee
6c6eecce23 [ie/rule34video] Fix extractor: use height instead of quality and fix extracting attributes 2024-10-06 22:43:10 -07:00
2 changed files with 35 additions and 15 deletions

View File

@ -9,7 +9,7 @@ from ..utils import (
class ChaturbateIE(InfoExtractor):
_VALID_URL = r'https?://(?:[^/]+\.)?chaturbate\.com/(?:fullvideo/?\?.*?\bb=)?(?P<id>[^/?&#]+)'
_VALID_URL = r'https?://(?:[^/]+\.)?chaturbate\.(?P<tld>com|eu|global)/(?:fullvideo/?\?.*?\bb=)?(?P<id>[^/?&#]+)'
_TESTS = [{
'url': 'https://www.chaturbate.com/siswet19/',
'info_dict': {
@ -29,15 +29,24 @@ class ChaturbateIE(InfoExtractor):
}, {
'url': 'https://en.chaturbate.com/siswet19/',
'only_matching': True,
}, {
'url': 'https://chaturbate.eu/siswet19/',
'only_matching': True,
}, {
'url': 'https://chaturbate.eu/fullvideo/?b=caylin',
'only_matching': True,
}, {
'url': 'https://chaturbate.global/siswet19/',
'only_matching': True,
}]
_ROOM_OFFLINE = 'Room is currently offline'
def _real_extract(self, url):
video_id = self._match_id(url)
video_id, tld = self._match_valid_url(url).group('id', 'tld')
webpage = self._download_webpage(
f'https://chaturbate.com/{video_id}/', video_id,
f'https://chaturbate.{tld}/{video_id}/', video_id,
headers=self.geo_verification_headers())
found_m3u8_urls = []

View File

@ -9,8 +9,8 @@ from ..utils import (
get_element_html_by_class,
get_elements_by_class,
int_or_none,
parse_count,
parse_duration,
str_to_int,
unescapeHTML,
)
from ..utils.traversal import traverse_obj
@ -77,20 +77,32 @@ class Rule34VideoIE(InfoExtractor):
formats.append({
'url': url,
'ext': ext.lower(),
'quality': quality,
'height': int(quality),
})
categories, creators, uploader, uploader_url = [None] * 4
categories, creators, uploader, uploader_url, views, likes = [None] * 6
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:':
uploader = clean_html(get_element_by_class('name', col))
uploader_url = extract_attributes(get_element_html_by_class('name', col) or '').get('href')
elif label == 'Uploaded by':
uploader = clean_html(get_element_by_class('item', col))
uploader_url = extract_attributes(get_element_html_by_class('item', col) or '').get('href')
views_text = self._html_search_regex(
r'custom-eye">\s+<use[^>]+></use>\s+</svg>\s+<span>([^<]+)', webpage, 'views', default='').replace(' ', '')
views = int_or_none(views_text)
if views is None:
precise_match = re.search(r'\((?P<precise_views>[^d]+)\)', views_text)
if precise_match:
views = str_to_int(precise_match['precise_views'])
likes_text = get_element_by_class('voters count', webpage)
likes_match = re.search(r'\((?P<num_likes>[^d]+)\)', likes_text)
if likes_match:
likes = str_to_int(likes_match['num_likes'])
return {
**traverse_obj(self._search_json_ld(webpage, video_id, default={}), ({
'title': 'title',
@ -107,10 +119,9 @@ class Rule34VideoIE(InfoExtractor):
'thumbnail': self._html_search_regex(
r'preview_url:\s+\'([^\']+)\'', webpage, 'thumbnail', default=None),
'duration': parse_duration(self._html_search_regex(
r'"icon-clock"></i>\s+<span>((?:\d+:?)+)', webpage, 'duration', default=None)),
'view_count': int_or_none(self._html_search_regex(
r'"icon-eye"></i>\s+<span>([ \d]+)', webpage, 'views', default='').replace(' ', '')),
'like_count': parse_count(get_element_by_class('voters count', webpage)),
r'custom-time">\s+<use[^>]+></use>\s+</svg>\s+<span>((?:\d+:?)+)', webpage, 'duration', default=None)),
'view_count': views,
'like_count': likes,
'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,