1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-28 13:11:49 +00:00
youtube-dl/youtube_dl/extractor/recurbate.py

47 lines
1.7 KiB
Python
Raw Normal View History

2022-10-22 16:53:43 +00:00
# coding: utf-8
from __future__ import unicode_literals
2022-10-26 21:10:56 +00:00
from ..utils import (
ExtractorError,
merge_dicts,
update_url_query,
)
2022-10-22 16:53:43 +00:00
from .common import InfoExtractor
class RecurbateIE(InfoExtractor):
_VALID_URL = r'https?:\/\/(?:www\.)?recurbate\.com\/play\.php\?video=(?P<id>[0-9]+)'
_TEST = {
2022-10-25 19:14:18 +00:00
'url': 'https://recurbate.com/play.php?video=39161415',
2022-10-22 16:53:43 +00:00
'info_dict': {
2022-10-25 19:14:18 +00:00
'id': '39161415',
2022-10-22 16:53:43 +00:00
'ext': 'mp4',
2022-10-25 19:14:18 +00:00
'title': 'Performer zsnicole33 show on 2022-10-25 20_23, Chaturbate Archive Recurbate'
2022-10-22 16:53:43 +00:00
},
2022-10-26 21:10:56 +00:00
'skip': 'Free videos are available for a limited amount of time and for a single session.',
2022-10-22 16:53:43 +00:00
}
2023-02-03 01:45:06 +00:00
@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)
2022-10-22 16:53:43 +00:00
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
title = self._html_search_regex(r'<title>(.+?)</title>', webpage, 'title')
2022-10-26 21:10:56 +00:00
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})
2022-10-22 16:53:43 +00:00
video_webpage = self._download_webpage(get_url, video_id)
2022-10-26 21:10:56 +00:00
if 'shall_signin' in video_webpage[:20]:
2023-02-03 01:45:06 +00:00
self.raise_login_required()
2022-10-26 21:10:56 +00:00
entries = self._parse_html5_media_entries(get_url, video_webpage, video_id)
if not entries:
raise ExtractorError('No media links found')
return merge_dicts({
2022-10-22 16:53:43 +00:00
'id': video_id,
'title': title,
'description': self._og_search_description(webpage),
2022-10-26 21:10:56 +00:00
}, entries[0])