mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-25 16:51:26 +01:00
Compare commits
No commits in common. "d0a642748c92b3c47073c072f5b86aeea3c6281e" and "6314563ce5cde9b6e9906a957d0263f87a019f0f" have entirely different histories.
d0a642748c
...
6314563ce5
|
@ -1643,7 +1643,10 @@ from .rumble import (
|
||||||
RumbleIE,
|
RumbleIE,
|
||||||
RumbleChannelIE,
|
RumbleChannelIE,
|
||||||
)
|
)
|
||||||
from .rudovideo import RudoVideoIE
|
from .rudovideo import (
|
||||||
|
RudoVideoLiveIE,
|
||||||
|
RudoVideoIE,
|
||||||
|
)
|
||||||
from .rutube import (
|
from .rutube import (
|
||||||
RutubeIE,
|
RutubeIE,
|
||||||
RutubeChannelIE,
|
RutubeChannelIE,
|
||||||
|
|
|
@ -1,10 +1,34 @@
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import ExtractorError, js_to_json, traverse_obj, update_url_query
|
from ..utils import ExtractorError, traverse_obj, js_to_json, update_url_query
|
||||||
|
|
||||||
|
|
||||||
class RudoVideoIE(InfoExtractor):
|
class RudoVideoBaseIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://rudo\.video/(?P<type>vod|podcast|live)/(?P<id>[^/?&#]+)'
|
def get_title(self, webpage):
|
||||||
_EMBED_REGEX = [r'<iframe[^>]+src=[\'"](?P<url>(?:https?:)//rudo\.video/(?:vod|podcast|live)/[^\'"]+)']
|
return self._search_regex(r'var\s+titleVideo\s*=\s*[\'"]([^\'"]+)', webpage, 'title', default=None) or self._og_search_title(webpage)
|
||||||
|
|
||||||
|
def get_thumbnail(self, webpage):
|
||||||
|
return self._search_regex(r'var\s+posterIMG\s*=\s*[\'"]([^?\'"]+)', webpage, 'thumbnail', default=None) or self._og_search_thumbnail(webpage)
|
||||||
|
|
||||||
|
def get_creator(self, webpage):
|
||||||
|
return self._search_regex(r'var\s+videoAuthor\s*=\s*[\'"]([^?\'"]+)', webpage, "videoAuthor", default=None)
|
||||||
|
|
||||||
|
def get_stream_url(self, webpage, video_id):
|
||||||
|
stream_url = self._search_regex(r'var\s+streamURL\s*=\s*[\'"]([^?\'"]+)', webpage, 'streamUrl', default=None) or self._search_regex(r'<source[^>]+src=[\'"]([^\'"]+)', webpage, 'sourceUrl', default=None)
|
||||||
|
youtube_url = self._search_regex(r'file:\s*[\'"]((?:https?:)//(?:www\.)?youtube.com[^\'"]+)', webpage, 'youtubeUrl', default=None)
|
||||||
|
if stream_url is None:
|
||||||
|
if youtube_url is None:
|
||||||
|
raise ExtractorError('Unable to extract stream url')
|
||||||
|
return self.url_result(youtube_url, display_id=video_id)
|
||||||
|
return stream_url
|
||||||
|
|
||||||
|
def check_geo_restricted(self, webpage):
|
||||||
|
if 'Streaming is not available in your area.' in webpage:
|
||||||
|
self.raise_geo_restricted()
|
||||||
|
|
||||||
|
|
||||||
|
class RudoVideoIE(RudoVideoBaseIE):
|
||||||
|
_VALID_URL = r'https?://rudo\.video/(?:vod|podcast)/(?P<id>[^/?]+)'
|
||||||
|
_EMBED_REGEX = [r'<iframe[^>]+src=[\'"](?P<url>(?:https?:)//rudo\.video/(?:vod|podcast)/[^\'"]+)']
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://rudo.video/podcast/cz2wrUy8l0o',
|
'url': 'https://rudo.video/podcast/cz2wrUy8l0o',
|
||||||
'md5': '28ed82b477708dc5e12e072da2449221',
|
'md5': '28ed82b477708dc5e12e072da2449221',
|
||||||
|
@ -33,7 +57,29 @@ class RudoVideoIE(InfoExtractor):
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'thumbnail': r're:^(?:https?:)?//.*\.(png|jpg)$',
|
'thumbnail': r're:^(?:https?:)?//.*\.(png|jpg)$',
|
||||||
},
|
},
|
||||||
}, {
|
}]
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
video_id = self._match_id(url)
|
||||||
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
|
self.check_geo_restricted(webpage)
|
||||||
|
|
||||||
|
stream_url = self.get_stream_url(webpage, video_id)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'id': video_id,
|
||||||
|
'title': self.get_title(webpage),
|
||||||
|
'formats': self._extract_m3u8_formats(stream_url, video_id, live=True),
|
||||||
|
'creator': self.get_creator(webpage),
|
||||||
|
'thumbnail': self.get_thumbnail(webpage),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class RudoVideoLiveIE(RudoVideoBaseIE):
|
||||||
|
_VALID_URL = r'https?://rudo\.video/live/(?P<id>[^/?]+)'
|
||||||
|
_EMBED_REGEX = [r'<iframe[^>]+src=[\'"](?P<url>(?:https?:)//rudo\.video/live/[^\'"]+)']
|
||||||
|
_TESTS = [{
|
||||||
'url': 'https://rudo.video/live/bbtv',
|
'url': 'https://rudo.video/live/bbtv',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'bbtv',
|
'id': 'bbtv',
|
||||||
|
@ -62,47 +108,25 @@ class RudoVideoIE(InfoExtractor):
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id, type_ = self._match_valid_url(url).group('id', 'type')
|
video_id = self._match_id(url)
|
||||||
is_live = type_ == 'live'
|
|
||||||
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
if 'Streaming is not available in your area' in webpage:
|
|
||||||
self.raise_geo_restricted()
|
|
||||||
|
|
||||||
m3u8_url = (
|
self.check_geo_restricted(webpage)
|
||||||
self._search_regex(
|
|
||||||
r'var\s+streamURL\s*=\s*[\'"]([^?\'"]+)', webpage, 'stream url', default=None)
|
|
||||||
# Source URL must be used only if streamURL is unavailable
|
|
||||||
or self._search_regex(
|
|
||||||
r'<source[^>]+src=[\'"]([^\'"]+)', webpage, 'source url', default=None))
|
|
||||||
if not m3u8_url:
|
|
||||||
youtube_url = self._search_regex(r'file:\s*[\'"]((?:https?:)//(?:www\.)?youtube\.com[^\'"]+)',
|
|
||||||
webpage, 'youtube url', default=None)
|
|
||||||
if youtube_url:
|
|
||||||
return self.url_result(youtube_url, 'Youtube')
|
|
||||||
raise ExtractorError('Unable to extract stream url')
|
|
||||||
|
|
||||||
token_array = self._search_json(
|
stream_url = self.get_stream_url(webpage, video_id)
|
||||||
r'<script>var\s+_\$_[a-zA-Z0-9]+\s*=', webpage, 'access token array', video_id,
|
token_array = self._search_json(r'<script>var\s+_\$_[a-zA-Z0-9]+\s*=', webpage, 'access token array', video_id,
|
||||||
contains_pattern=r'\[(?s:.+)\]', default=None, transform_source=js_to_json)
|
contains_pattern=r'\[(?s:.+)\]', default=None, transform_source=js_to_json)
|
||||||
if token_array:
|
if token_array:
|
||||||
if len(token_array) != 9:
|
if len(token_array) != 9:
|
||||||
raise ExtractorError('Invalid access token array')
|
raise ExtractorError('Couldnt get access token array', video_id=video_id)
|
||||||
access_token = self._download_json(token_array[0], video_id, note='Downloading access token')
|
access_token = self._download_json(token_array[0], video_id, note='Downloading access token')
|
||||||
m3u8_url = update_url_query(m3u8_url, {
|
stream_url = update_url_query(stream_url, {'auth-token': traverse_obj(access_token, ('data', 'authToken'))})
|
||||||
'auth-token': traverse_obj(access_token, ('data', 'authToken'))
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': (self._search_regex(r'var\s+titleVideo\s*=\s*[\'"]([^\'"]+)',
|
'title': self.get_title(webpage),
|
||||||
webpage, 'title', default=None)
|
'formats': self._extract_m3u8_formats(stream_url, video_id, live=True),
|
||||||
or self._og_search_title(webpage)),
|
'is_live': True,
|
||||||
'creator': self._search_regex(r'var\s+videoAuthor\s*=\s*[\'"]([^?\'"]+)',
|
'creator': self.get_creator(webpage),
|
||||||
webpage, 'videoAuthor', default=None),
|
'thumbnail': self.get_thumbnail(webpage),
|
||||||
'thumbnail': (self._search_regex(r'var\s+posterIMG\s*=\s*[\'"]([^?\'"]+)',
|
|
||||||
webpage, 'thumbnail', default=None)
|
|
||||||
or self._og_search_thumbnail(webpage)),
|
|
||||||
'formats': self._extract_m3u8_formats(m3u8_url, video_id, live=is_live),
|
|
||||||
'is_live': is_live,
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user