]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/recurbate.py
[ie/box] Fix formats extraction (#8649)
[yt-dlp.git] / yt_dlp / extractor / recurbate.py
1 from .common import InfoExtractor
2 from ..networking.exceptions import HTTPError
3 from ..utils import ExtractorError, merge_dicts
4
5
6 class RecurbateIE(InfoExtractor):
7 _VALID_URL = r'https?://(?:www\.)?recurbate\.com/play\.php\?video=(?P<id>\d+)'
8 _TESTS = [{
9 'url': 'https://recurbate.com/play.php?video=39161415',
10 'md5': 'dd2b4ec57aa3e3572cb5cf0997fca99f',
11 'info_dict': {
12 'id': '39161415',
13 'ext': 'mp4',
14 'description': 'md5:db48d09e4d93fc715f47fd3d6b7edd51',
15 'title': 'Performer zsnicole33 show on 2022-10-25 20:23, Chaturbate Archive – Recurbate',
16 'age_limit': 18,
17 },
18 'skip': 'Website require membership.',
19 }]
20
21 def _real_extract(self, url):
22 SUBSCRIPTION_MISSING_MESSAGE = 'This video is only available for registered users; Set your authenticated browser user agent via the --user-agent parameter.'
23 video_id = self._match_id(url)
24 try:
25 webpage = self._download_webpage(url, video_id)
26 except ExtractorError as e:
27 if isinstance(e.cause, HTTPError) and e.cause.status == 403:
28 self.raise_login_required(msg=SUBSCRIPTION_MISSING_MESSAGE, method='cookies')
29 raise
30 token = self._html_search_regex(r'data-token="([^"]+)"', webpage, 'token')
31 video_url = f'https://recurbate.com/api/get.php?video={video_id}&token={token}'
32
33 video_webpage = self._download_webpage(video_url, video_id)
34 if video_webpage == 'shall_subscribe':
35 self.raise_login_required(msg=SUBSCRIPTION_MISSING_MESSAGE, method='cookies')
36 entries = self._parse_html5_media_entries(video_url, video_webpage, video_id)
37 return merge_dicts({
38 'id': video_id,
39 'title': self._html_extract_title(webpage, 'title'),
40 'description': self._og_search_description(webpage),
41 'age_limit': self._rta_search(webpage),
42 }, entries[0])