mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-07-27 05:44:13 +09:00
Apply suggestions from code review
Co-authored-by: dirkf <fieldhouse@gmx.net>
This commit is contained in:
parent
f5e145f82f
commit
801766a1ae
@ -21,12 +21,12 @@ class BellesaIE(InfoExtractor):
|
|||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'My First Time Kissing Women',
|
'title': 'My First Time Kissing Women',
|
||||||
'thumbnail': 'https://c.bellesa.co/dkvdbifey/image/upload/v1599024046/video_upload/2189cover.jpg',
|
'thumbnail': 'https://c.bellesa.co/dkvdbifey/image/upload/v1599024046/video_upload/2189cover.jpg',
|
||||||
'description': 'Jenna opens up about her troubles navigating a long-distance relationship. Her girlfriends ask if she’d ever be open to cheating on him but she says she would never, they’ve been together since college. Lena and Carter sit on either side of her and remind her it isn’t cheating if it’s with a girl…they start kissing and rubbing her chest, going down on her together. This girl on girl scene is so sensual, and the nerves on Jenna are real — exploring your sexuality takes courage, but there’s a lot of good vibes in this threesome.',
|
'description': 'md5:69eea8a4ee31d42d6fd6302ad9e09ab2',
|
||||||
'creator': 'Bellesa Films',
|
'creator': 'Bellesa Films',
|
||||||
'upload_date': '20191216',
|
'upload_date': '20191216',
|
||||||
'timestamp': 1576539207,
|
'timestamp': 1576539207,
|
||||||
'duration': 721,
|
'duration': 721,
|
||||||
'tags': ['HD Porn', 'Porn for Women', 'Orgasm', 'Bellesa Films', 'Threesome', 'FFF', 'Girl on Girl', 'Lesbians', 'Lesbian Porn', 'Nipple Licking', 'Finger', 'Cunnilingus', 'Anilingus', 'Eating Out', 'Clit Play', 'Clit Stimulation', 'Natural Breasts', 'Face Sitting', 'Spitting'],
|
'tags': 'mincount: 1',
|
||||||
'categories': ['Girl on Girl', 'Story'],
|
'categories': ['Girl on Girl', 'Story'],
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
}
|
}
|
||||||
@ -43,25 +43,23 @@ class BellesaIE(InfoExtractor):
|
|||||||
# thus need to raise an error
|
# thus need to raise an error
|
||||||
if 'VideoCard' not in webpage:
|
if 'VideoCard' not in webpage:
|
||||||
title = self._html_search_regex(
|
title = self._html_search_regex(
|
||||||
r'<title[^>]*>(?P<title>.+?)\s+\|\s+Bellesa',
|
r'(?s)<title\b[^>]*>(?P<title>.+?)(?:\|\s+Bellesa)?</title',
|
||||||
webpage, 'title', default=None,
|
webpage, 'title', default=None,
|
||||||
group='title', fatal=False)
|
group='title', fatal=False)
|
||||||
|
|
||||||
raise ExtractorError('%s said: %s' % (self.IE_NAME, clean_html(title)), expected=True)
|
raise ExtractorError('[%s] %s: %s' % (self.IE_NAME, video_id, clean_html(title)), expected=True)
|
||||||
|
|
||||||
initial_data_raw = self._search_regex(r'window\.__INITIAL_DATA__\s+=\s+(.+?);</script>', webpage, 'initial_data')
|
initial_data_raw = self._search_regex(r'(?s)window\s*\.\s*__INITIAL_DATA__\s*=\s*(\{.+?\})\s*;\s*</script>', webpage, 'initial_data')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
initial_data = json.loads(initial_data_raw)
|
initial_data = json.loads(initial_data_raw)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
raise ExtractorError('%s said: cannot decode initial data', self.IE_NAME, expected=True)
|
raise ExtractorError('%s said: cannot decode initial data', self.IE_NAME, expected=True)
|
||||||
|
|
||||||
video = try_get(initial_data, lambda x: x['video'])
|
video = try_get(initial_data, lambda x: x['video'], dict) or {}
|
||||||
if not video:
|
|
||||||
raise ExtractorError('%s said: initial data malformed' % self.IE_NAME, expected=True)
|
|
||||||
|
|
||||||
resolutions = try_get(video, lambda x: x['resolutions'])
|
resolutions = video.get('resolutions')
|
||||||
source = try_get(video, lambda x: x['source'])
|
source = video.get('source')
|
||||||
|
|
||||||
if not resolutions or not source:
|
if not resolutions or not source:
|
||||||
raise ExtractorError('%s said: cannot extract playlist information from meta data' % self.IE_NAME, expected=True)
|
raise ExtractorError('%s said: cannot extract playlist information from meta data' % self.IE_NAME, expected=True)
|
||||||
@ -76,38 +74,31 @@ class BellesaIE(InfoExtractor):
|
|||||||
|
|
||||||
# get from video meta data first
|
# get from video meta data first
|
||||||
title = video.get('title')
|
title = video.get('title')
|
||||||
if title:
|
title = strip_or_none(video.get('title'))
|
||||||
title = title.strip()
|
if not title:
|
||||||
else:
|
|
||||||
# fallback to og:title, which needs some treatment
|
# fallback to og:title, which needs some treatment
|
||||||
title = self._og_search_title(webpage)
|
title = self._og_search_title(webpage)
|
||||||
if title:
|
if title:
|
||||||
title = title.split('|')[0].strip()
|
title = title.split('|')[0].strip()
|
||||||
|
|
||||||
tags = None
|
tags = list(filter(None, map(lambda s: s.strip(), (video.get('tags') or '').split(','))))
|
||||||
tag_string = video.get('tags')
|
|
||||||
if tag_string:
|
|
||||||
tags = [c for c in map(lambda s: s.strip(), tag_string.split(','))]
|
|
||||||
|
|
||||||
categories = None
|
categories = None
|
||||||
if 'categories' in video:
|
if 'categories' in video:
|
||||||
categories = [c['name'] for c in video.get('categories')]
|
categories = [c['name'] for c in video.get('categories')]
|
||||||
|
list(filter(None, map(lambda d: strip_or_none(d['name']), (video.get('categories') or []))))
|
||||||
description = try_get(video, lambda x: x['description'])
|
|
||||||
if description:
|
|
||||||
description = description.strip()
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'thumbnail': try_get(video, lambda x: x['image']),
|
'thumbnail': url_or_none(video.get('image')),
|
||||||
'description': description,
|
'description': strip_or_none(video.get('description')) or None,
|
||||||
'creator': try_get(video, lambda x: x['content_provider'][0]['name']),
|
'creator': try_get(video, lambda x: x['content_provider'][0]['name'].strip(), compat_str),
|
||||||
'timestamp': try_get(video, lambda x: x['posted_on']),
|
'timestamp': int_or_none(video.get('posted_on')),
|
||||||
'duration': try_get(video, lambda x: x['duration']),
|
'duration': int_or_none(video.get('duration')),
|
||||||
'view_count': try_get(video, lambda x: x['views']),
|
'view_count': int_or_none(video.get('views')),
|
||||||
'tags': tags,
|
'tags': tags or None,
|
||||||
'categories': categories,
|
'categories': categories or None,
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user