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