From e719bf1fbb7f4225b6babee586cb3ceaedb1ec4d Mon Sep 17 00:00:00 2001 From: Jackson Humphrey Date: Wed, 13 Nov 2024 15:59:21 -0600 Subject: [PATCH 1/4] Applied the patch provided by dirkf in https://github.com/ytdl-org/youtube-dl/issues/30458. --- yt_dlp/extractor/alphaporno.py | 92 +++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 29 deletions(-) diff --git a/yt_dlp/extractor/alphaporno.py b/yt_dlp/extractor/alphaporno.py index 7b74d5524d..bfbe1f0401 100644 --- a/yt_dlp/extractor/alphaporno.py +++ b/yt_dlp/extractor/alphaporno.py @@ -1,9 +1,13 @@ +import re + from .common import InfoExtractor from ..utils import ( int_or_none, parse_duration, parse_filesize, - parse_iso8601, + parse_resolution, + unified_timestamp, + urljoin, ) @@ -11,18 +15,17 @@ class AlphaPornoIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?alphaporno\.com/videos/(?P[^/]+)' _TEST = { 'url': 'http://www.alphaporno.com/videos/sensual-striptease-porn-with-samantha-alexandra/', - 'md5': 'feb6d3bba8848cd54467a87ad34bd38e', + 'md5': '7e6a1cdd48fa67362a5a11d7039164e7', 'info_dict': { 'id': '258807', 'display_id': 'sensual-striptease-porn-with-samantha-alexandra', 'ext': 'mp4', 'title': 'Sensual striptease porn with Samantha Alexandra', + 'description': 'md5:3c6d31008980654acaeb11451454a62c', 'thumbnail': r're:https?://.*\.jpg$', - 'timestamp': 1418694611, + 'timestamp': 1418701811, 'upload_date': '20141216', 'duration': 387, - 'filesize_approx': 54120000, - 'tbr': 1145, 'categories': list, 'age_limit': 18, }, @@ -31,40 +34,70 @@ class AlphaPornoIE(InfoExtractor): def _real_extract(self, url): display_id = self._match_id(url) - webpage = self._download_webpage(url, display_id) + webpage, urlh = self._download_webpage_handle(url, display_id) + info = { + 'display_id': display_id, + } video_id = self._search_regex( r"video_id\s*:\s*'([^']+)'", webpage, 'video id', default=None) + if video_id: + info['url'] = self._search_regex( + r"video_url\s*:\s*'([^']+)'", webpage, 'video url') + info['ext'] = self._html_search_meta( + 'encodingFormat', webpage, 'ext', default='.mp4')[1:] + else: + video_id = self._search_regex( + r'video_id=(\d+)\b', webpage, 'video id') + formats = [] + joined_url = urljoin(urlh.geturl(), rf'/get_file/\d.+?/{video_id}/{video_id}_(\w+)\..+?') + for video_url, res in re.findall(rf'''({joined_url})(?:'|"|\b)\s''', webpage): + fmt = { + 'format_id': f'f{res}', + 'url': video_url, + } + fmt.update(parse_resolution(res) or {}) + formats.append(fmt) + self._sort_formats(formats) + info['formats'] = formats - video_url = self._search_regex( - r"video_url\s*:\s*'([^']+)'", webpage, 'video url') - ext = self._html_search_meta( - 'encodingFormat', webpage, 'ext', default='.mp4')[1:] - - title = self._search_regex( - [r'', - r'class="title" itemprop="name">([^<]+)<'], - webpage, 'title') - thumbnail = self._html_search_meta('thumbnail', webpage, 'thumbnail') - timestamp = parse_iso8601(self._html_search_meta( - 'uploadDate', webpage, 'upload date')) - duration = parse_duration(self._html_search_meta( - 'duration', webpage, 'duration')) + title = ( + self._html_search_regex(r']*>([^<]+?)(?:\s*-\s*Alpha\s*Porno\s*)?<', webpage, 'title', default=None) + or self._og_search_title(webpage, default=None) + or self._search_regex( + (r'', + r'class="title" itemprop="name">([^<]+)<'), + webpage, 'title') + ) + description = ( + self._og_search_description(webpage) + or self._search_regex( + r'', + webpage, 'description') + ) + thumbnail = ( + self._og_search_thumbnail(webpage) + or self._html_search_meta('thumbnail', webpage, 'thumbnail') + ) + timestamp = unified_timestamp(self._og_search_property('video:release_date', webpage) + or self._html_search_meta('uploadDate', webpage, 'upload date')) + duration = parse_duration(self._og_search_property('video:duration', webpage) + or self._html_search_meta('duration', webpage, 'duration')) filesize_approx = parse_filesize(self._html_search_meta( - 'contentSize', webpage, 'file size')) + 'contentSize', webpage, 'file size', default=None)) bitrate = int_or_none(self._html_search_meta( - 'bitrate', webpage, 'bitrate')) - categories = self._html_search_meta( - 'keywords', webpage, 'categories', default='').split(',') + 'bitrate', webpage, 'bitrate', default=None)) + categories = re.split( + r'\s*,\s*', + self._html_search_meta( + 'keywords', webpage, 'categories', default='')) age_limit = self._rta_search(webpage) - return { + info.update({ 'id': video_id, - 'display_id': display_id, - 'url': video_url, - 'ext': ext, 'title': title, + 'description': description, 'thumbnail': thumbnail, 'timestamp': timestamp, 'duration': duration, @@ -72,4 +105,5 @@ class AlphaPornoIE(InfoExtractor): 'tbr': bitrate, 'categories': categories, 'age_limit': age_limit, - } + }) + return info From 10834f196dca983423bf5b90057540abf5c79c67 Mon Sep 17 00:00:00 2001 From: Jackson Humphrey Date: Wed, 13 Nov 2024 16:00:29 -0600 Subject: [PATCH 2/4] Removed deprecated constructions to satisfy DeprecationWarnings when running tests. Tests now pass. --- yt_dlp/extractor/alphaporno.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/yt_dlp/extractor/alphaporno.py b/yt_dlp/extractor/alphaporno.py index bfbe1f0401..3b3da37da0 100644 --- a/yt_dlp/extractor/alphaporno.py +++ b/yt_dlp/extractor/alphaporno.py @@ -50,7 +50,7 @@ class AlphaPornoIE(InfoExtractor): video_id = self._search_regex( r'video_id=(\d+)\b', webpage, 'video id') formats = [] - joined_url = urljoin(urlh.geturl(), rf'/get_file/\d.+?/{video_id}/{video_id}_(\w+)\..+?') + joined_url = urljoin(urlh.url, rf'/get_file/\d.+?/{video_id}/{video_id}_(\w+)\..+?') for video_url, res in re.findall(rf'''({joined_url})(?:'|"|\b)\s''', webpage): fmt = { 'format_id': f'f{res}', @@ -58,7 +58,6 @@ class AlphaPornoIE(InfoExtractor): } fmt.update(parse_resolution(res) or {}) formats.append(fmt) - self._sort_formats(formats) info['formats'] = formats title = ( From d45461e4b3e9b926defa3998e8dcf7969b7f6e99 Mon Sep 17 00:00:00 2001 From: Jackson Humphrey Date: Wed, 13 Nov 2024 16:12:55 -0600 Subject: [PATCH 3/4] Added a test for the URL reported in youtube-dl Issue #30458. --- yt_dlp/extractor/alphaporno.py | 50 +++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/yt_dlp/extractor/alphaporno.py b/yt_dlp/extractor/alphaporno.py index 3b3da37da0..9caf44d013 100644 --- a/yt_dlp/extractor/alphaporno.py +++ b/yt_dlp/extractor/alphaporno.py @@ -13,23 +13,41 @@ from ..utils import ( class AlphaPornoIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?alphaporno\.com/videos/(?P[^/]+)' - _TEST = { - 'url': 'http://www.alphaporno.com/videos/sensual-striptease-porn-with-samantha-alexandra/', - 'md5': '7e6a1cdd48fa67362a5a11d7039164e7', - 'info_dict': { - 'id': '258807', - 'display_id': 'sensual-striptease-porn-with-samantha-alexandra', - 'ext': 'mp4', - 'title': 'Sensual striptease porn with Samantha Alexandra', - 'description': 'md5:3c6d31008980654acaeb11451454a62c', - 'thumbnail': r're:https?://.*\.jpg$', - 'timestamp': 1418701811, - 'upload_date': '20141216', - 'duration': 387, - 'categories': list, - 'age_limit': 18, + _TESTS = [ + { + 'url': 'http://www.alphaporno.com/videos/sensual-striptease-porn-with-samantha-alexandra/', + 'md5': '7e6a1cdd48fa67362a5a11d7039164e7', + 'info_dict': { + 'id': '258807', + 'display_id': 'sensual-striptease-porn-with-samantha-alexandra', + 'ext': 'mp4', + 'title': 'Sensual striptease porn with Samantha Alexandra', + 'description': 'md5:3c6d31008980654acaeb11451454a62c', + 'thumbnail': r're:https?://.*\.jpg$', + 'timestamp': 1418701811, + 'upload_date': '20141216', + 'duration': 387, + 'categories': list, + 'age_limit': 18, + }, }, - } + { + 'url': 'https://www.alphaporno.com/videos/amazing-inches-hammering-her-pussy-in-such-addictive-ways/', + 'info_dict': { + 'id': '433761', + 'ext': 'mp4', + 'title': 'Amazing inches hammering her pussy in such addictive ways', + 'display_id': 'amazing-inches-hammering-her-pussy-in-such-addictive-ways', + 'timestamp': 1641065820, + 'upload_date': '20220101', + 'description': 'md5:8bf8e04807b890b847cc9238c445783a', + 'categories': 'count:12', + 'age_limit': 18, + 'thumbnail': r're:https?://.*\.jpg$', + 'duration': 298.0, + }, + }, + ] def _real_extract(self, url): display_id = self._match_id(url) From f242b7c42dfe88701964fa89ecfbf52b7b9ccb1b Mon Sep 17 00:00:00 2001 From: Jackson Humphrey Date: Wed, 13 Nov 2024 16:15:41 -0600 Subject: [PATCH 4/4] Added a test for the URL referenced in Issue #2702. --- yt_dlp/extractor/alphaporno.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/yt_dlp/extractor/alphaporno.py b/yt_dlp/extractor/alphaporno.py index 9caf44d013..1ca478898a 100644 --- a/yt_dlp/extractor/alphaporno.py +++ b/yt_dlp/extractor/alphaporno.py @@ -47,6 +47,22 @@ class AlphaPornoIE(InfoExtractor): 'duration': 298.0, }, }, + { + 'url': 'https://www.alphaporno.com/videos/anal-threesome-for-girls-younger-than-the-average/', + 'info_dict': { + 'id': '435603', + 'ext': 'mp4', + 'duration': 358.0, + 'description': 'md5:bf8ca502575c20e15f4f33740cd20a94', + 'categories': 'count:21', + 'title': 'Anal threesome for girls y***er than the average', + 'display_id': 'anal-threesome-for-girls-younger-than-the-average', + 'upload_date': '20220209', + 'thumbnail': r're:https?://.*\.jpg$', + 'age_limit': 18, + 'timestamp': 1644387720, + }, + }, ] def _real_extract(self, url):