From 5ca7aa42862a8c5dfc617c7d04dc40b112abcec6 Mon Sep 17 00:00:00 2001 From: Mr Scrapy Date: Sat, 22 Oct 2022 17:53:43 +0100 Subject: [PATCH 1/6] Add Recurbate premium support --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/recurbate.py | 34 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 youtube_dl/extractor/recurbate.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 751fc38b6..741ae437d 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1007,6 +1007,7 @@ from .raywenderlich import ( ) from .rbmaradio import RBMARadioIE from .rds import RDSIE +from .recurbate import RecurbateIE from .redbulltv import ( RedBullTVIE, RedBullEmbedIE, diff --git a/youtube_dl/extractor/recurbate.py b/youtube_dl/extractor/recurbate.py new file mode 100644 index 000000000..4e7e0afba --- /dev/null +++ b/youtube_dl/extractor/recurbate.py @@ -0,0 +1,34 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class RecurbateIE(InfoExtractor): + _VALID_URL = r'https?:\/\/(?:www\.)?recurbate\.com\/play\.php\?video=(?P[0-9]+)' + _TEST = { + 'url': 'https://recurbate.com/play.php?video=38825900', + 'info_dict': { + 'id': '38825900', + 'ext': 'mp4', + 'title': 'Performer vvendy show on 2022-10-21 16:55, Chaturbate Archive – Recurbate' + }, + 'skip': 'Requires premium subscription cookie session', + } + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + title = self._html_search_regex(r'(.+?)', webpage, 'title') + token = self._html_search_regex(r'data-token=(.+?")', webpage, 'play_button').strip("\"") + get_url = f"https://recurbate.com/api/get.php?video={video_id}&token={token}" + video_webpage = self._download_webpage(get_url, video_id) + real_url = self._html_search_regex(r' Date: Tue, 25 Oct 2022 20:14:03 +0100 Subject: [PATCH 2/6] Fix string interpolation to support python2 --- youtube_dl/extractor/recurbate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/recurbate.py b/youtube_dl/extractor/recurbate.py index 4e7e0afba..53d55ddf5 100644 --- a/youtube_dl/extractor/recurbate.py +++ b/youtube_dl/extractor/recurbate.py @@ -22,7 +22,7 @@ class RecurbateIE(InfoExtractor): title = self._html_search_regex(r'(.+?)', webpage, 'title') token = self._html_search_regex(r'data-token=(.+?")', webpage, 'play_button').strip("\"") - get_url = f"https://recurbate.com/api/get.php?video={video_id}&token={token}" + get_url = "https://recurbate.com/api/get.php?video={}&token={}".format(video_id, token) video_webpage = self._download_webpage(get_url, video_id) real_url = self._html_search_regex(r' Date: Tue, 25 Oct 2022 20:14:18 +0100 Subject: [PATCH 3/6] Use a smaller video for tests --- youtube_dl/extractor/recurbate.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/recurbate.py b/youtube_dl/extractor/recurbate.py index 53d55ddf5..4b203c97b 100644 --- a/youtube_dl/extractor/recurbate.py +++ b/youtube_dl/extractor/recurbate.py @@ -7,11 +7,11 @@ from .common import InfoExtractor class RecurbateIE(InfoExtractor): _VALID_URL = r'https?:\/\/(?:www\.)?recurbate\.com\/play\.php\?video=(?P[0-9]+)' _TEST = { - 'url': 'https://recurbate.com/play.php?video=38825900', + 'url': 'https://recurbate.com/play.php?video=39161415', 'info_dict': { - 'id': '38825900', + 'id': '39161415', 'ext': 'mp4', - 'title': 'Performer vvendy show on 2022-10-21 16:55, Chaturbate Archive – Recurbate' + 'title': 'Performer zsnicole33 show on 2022-10-25 20_23, Chaturbate Archive – Recurbate' }, 'skip': 'Requires premium subscription cookie session', } From ac792c93996b49cae47586a2ead7ede6d92b3819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CMr?= Date: Wed, 26 Oct 2022 22:10:56 +0100 Subject: [PATCH 4/6] Address comments --- youtube_dl/extractor/recurbate.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/youtube_dl/extractor/recurbate.py b/youtube_dl/extractor/recurbate.py index 4b203c97b..8c1d2be3b 100644 --- a/youtube_dl/extractor/recurbate.py +++ b/youtube_dl/extractor/recurbate.py @@ -1,6 +1,12 @@ # coding: utf-8 from __future__ import unicode_literals +from ..utils import ( + ExtractorError, + merge_dicts, + update_url_query, +) + from .common import InfoExtractor @@ -13,7 +19,7 @@ class RecurbateIE(InfoExtractor): 'ext': 'mp4', 'title': 'Performer zsnicole33 show on 2022-10-25 20_23, Chaturbate Archive – Recurbate' }, - 'skip': 'Requires premium subscription cookie session', + 'skip': 'Free videos are available for a limited amount of time and for a single session.', } def _real_extract(self, url): @@ -21,14 +27,18 @@ class RecurbateIE(InfoExtractor): webpage = self._download_webpage(url, video_id) title = self._html_search_regex(r'(.+?)', webpage, 'title') - token = self._html_search_regex(r'data-token=(.+?")', webpage, 'play_button').strip("\"") - get_url = "https://recurbate.com/api/get.php?video={}&token={}".format(video_id, token) + token = self._html_search_regex(r'data-token=(.+?")', webpage, 'play_button').strip('"') + get_url = update_url_query('https://recurbate.com/api/get.php', {'video': video_id, 'token': token}) video_webpage = self._download_webpage(get_url, video_id) - real_url = self._html_search_regex(r' Date: Fri, 3 Feb 2023 01:45:06 +0000 Subject: [PATCH 5/6] Small update, force CI --- youtube_dl/extractor/recurbate.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/recurbate.py b/youtube_dl/extractor/recurbate.py index 8c1d2be3b..73b6678c9 100644 --- a/youtube_dl/extractor/recurbate.py +++ b/youtube_dl/extractor/recurbate.py @@ -22,6 +22,10 @@ class RecurbateIE(InfoExtractor): 'skip': 'Free videos are available for a limited amount of time and for a single session.', } + @staticmethod + def raise_login_required(msg='Login required: use --cookies to pass your browser's login cookie, or try again later'): + raise ExtractorError(msg, expected=True) + def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) @@ -31,9 +35,7 @@ class RecurbateIE(InfoExtractor): get_url = update_url_query('https://recurbate.com/api/get.php', {'video': video_id, 'token': token}) video_webpage = self._download_webpage(get_url, video_id) if 'shall_signin' in video_webpage[:20]: - raise ExtractorError( - "Login required: use --cookies to pass your browser's login cookie, or try again later", - expected=True) + self.raise_login_required() entries = self._parse_html5_media_entries(get_url, video_webpage, video_id) if not entries: raise ExtractorError('No media links found') From 6a53f36713237d75b10010a0e30ceffc4b64f0ec Mon Sep 17 00:00:00 2001 From: dirkf Date: Fri, 3 Feb 2023 01:49:09 +0000 Subject: [PATCH 6/6] Again --- youtube_dl/extractor/recurbate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/recurbate.py b/youtube_dl/extractor/recurbate.py index 73b6678c9..eb77cc722 100644 --- a/youtube_dl/extractor/recurbate.py +++ b/youtube_dl/extractor/recurbate.py @@ -23,7 +23,7 @@ class RecurbateIE(InfoExtractor): } @staticmethod - def raise_login_required(msg='Login required: use --cookies to pass your browser's login cookie, or try again later'): + def raise_login_required(msg="Login required: use --cookies to pass your browser's login cookie, or try again later"): raise ExtractorError(msg, expected=True) def _real_extract(self, url):