mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-26 01:01:25 +01:00
Compare commits
5 Commits
065340088c
...
eec17abd84
Author | SHA1 | Date | |
---|---|---|---|
|
eec17abd84 | ||
|
b338b39244 | ||
|
a201e444b6 | ||
|
a02f6ae586 | ||
|
6e609fbd38 |
|
@ -50,6 +50,7 @@ from ..utils import (
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
parse_qs,
|
parse_qs,
|
||||||
qualities,
|
qualities,
|
||||||
|
remove_end,
|
||||||
remove_start,
|
remove_start,
|
||||||
smuggle_url,
|
smuggle_url,
|
||||||
str_or_none,
|
str_or_none,
|
||||||
|
@ -515,6 +516,8 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||||
_YT_HANDLE_RE = r'@[\w.-]{3,30}' # https://support.google.com/youtube/answer/11585688?hl=en
|
_YT_HANDLE_RE = r'@[\w.-]{3,30}' # https://support.google.com/youtube/answer/11585688?hl=en
|
||||||
_YT_CHANNEL_UCID_RE = r'UC[\w-]{22}'
|
_YT_CHANNEL_UCID_RE = r'UC[\w-]{22}'
|
||||||
|
|
||||||
|
_NETRC_MACHINE = 'youtube'
|
||||||
|
|
||||||
def ucid_or_none(self, ucid):
|
def ucid_or_none(self, ucid):
|
||||||
return self._search_regex(rf'^({self._YT_CHANNEL_UCID_RE})$', ucid, 'UC-id', default=None)
|
return self._search_regex(rf'^({self._YT_CHANNEL_UCID_RE})$', ucid, 'UC-id', default=None)
|
||||||
|
|
||||||
|
@ -573,10 +576,19 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||||
self._initialize_consent()
|
self._initialize_consent()
|
||||||
self._check_login_required()
|
self._check_login_required()
|
||||||
|
|
||||||
|
def _perform_login(self, username, password):
|
||||||
|
if username.startswith('oauth'):
|
||||||
|
raise ExtractorError(
|
||||||
|
f'Login with OAuth is no longer supported. {self._youtube_login_hint}', expected=True)
|
||||||
|
|
||||||
|
self.report_warning(
|
||||||
|
f'Login with password is not supported for YouTube. {self._youtube_login_hint}')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _youtube_login_hint(self):
|
def _youtube_login_hint(self):
|
||||||
return (f'{self._login_hint(method="cookies")}. '
|
return (f'{self._login_hint(method="cookies")}. Also see '
|
||||||
'See https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies for help with cookies')
|
'https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies '
|
||||||
|
'for tips on effectively exporting YouTube cookies')
|
||||||
|
|
||||||
def _check_login_required(self):
|
def _check_login_required(self):
|
||||||
if self._LOGIN_REQUIRED and not self.is_authenticated:
|
if self._LOGIN_REQUIRED and not self.is_authenticated:
|
||||||
|
@ -851,11 +863,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||||
for alert_type, alert_message in (warnings + errors[:-1]):
|
for alert_type, alert_message in (warnings + errors[:-1]):
|
||||||
self.report_warning(f'YouTube said: {alert_type} - {alert_message}', only_once=only_once)
|
self.report_warning(f'YouTube said: {alert_type} - {alert_message}', only_once=only_once)
|
||||||
if errors:
|
if errors:
|
||||||
msg = errors[-1][1]
|
raise ExtractorError(f'YouTube said: {errors[-1][1]}', expected=expected)
|
||||||
if msg and 'sign in' in msg.lower():
|
|
||||||
expected = True
|
|
||||||
msg += '\n' + self._youtube_login_hint
|
|
||||||
raise ExtractorError(f'YouTube said: {msg}', expected=expected)
|
|
||||||
|
|
||||||
def _extract_and_report_alerts(self, data, *args, **kwargs):
|
def _extract_and_report_alerts(self, data, *args, **kwargs):
|
||||||
return self._report_alerts(self._extract_alerts(data), *args, **kwargs)
|
return self._report_alerts(self._extract_alerts(data), *args, **kwargs)
|
||||||
|
@ -4454,6 +4462,9 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||||
self.raise_geo_restricted(subreason, countries, metadata_available=True)
|
self.raise_geo_restricted(subreason, countries, metadata_available=True)
|
||||||
reason += f'. {subreason}'
|
reason += f'. {subreason}'
|
||||||
if reason:
|
if reason:
|
||||||
|
if 'sign in' in reason.lower():
|
||||||
|
reason = remove_end(reason, 'This helps protect our community. Learn more')
|
||||||
|
reason = f'{remove_end(reason.strip(), ".")}. {self._youtube_login_hint}'
|
||||||
self.raise_no_formats(reason, expected=True)
|
self.raise_no_formats(reason, expected=True)
|
||||||
|
|
||||||
keywords = get_first(video_details, 'keywords', expected_type=list) or []
|
keywords = get_first(video_details, 'keywords', expected_type=list) or []
|
||||||
|
@ -6973,7 +6984,7 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||||
raise ExtractorError('Unable to recognize tab page')
|
raise ExtractorError('Unable to recognize tab page')
|
||||||
|
|
||||||
|
|
||||||
class YoutubePlaylistIE(InfoExtractor):
|
class YoutubePlaylistIE(YoutubeBaseInfoExtractor):
|
||||||
IE_DESC = 'YouTube playlists'
|
IE_DESC = 'YouTube playlists'
|
||||||
_VALID_URL = r'''(?x)(?:
|
_VALID_URL = r'''(?x)(?:
|
||||||
(?:https?://)?
|
(?:https?://)?
|
||||||
|
@ -7087,7 +7098,7 @@ class YoutubePlaylistIE(InfoExtractor):
|
||||||
return self.url_result(url, ie=YoutubeTabIE.ie_key(), video_id=playlist_id)
|
return self.url_result(url, ie=YoutubeTabIE.ie_key(), video_id=playlist_id)
|
||||||
|
|
||||||
|
|
||||||
class YoutubeYtBeIE(InfoExtractor):
|
class YoutubeYtBeIE(YoutubeBaseInfoExtractor):
|
||||||
IE_DESC = 'youtu.be'
|
IE_DESC = 'youtu.be'
|
||||||
_VALID_URL = rf'https?://youtu\.be/(?P<id>[0-9A-Za-z_-]{{11}})/*?.*?\blist=(?P<playlist_id>{YoutubeBaseInfoExtractor._PLAYLIST_ID_RE})'
|
_VALID_URL = rf'https?://youtu\.be/(?P<id>[0-9A-Za-z_-]{{11}})/*?.*?\blist=(?P<playlist_id>{YoutubeBaseInfoExtractor._PLAYLIST_ID_RE})'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
|
@ -7138,7 +7149,7 @@ class YoutubeYtBeIE(InfoExtractor):
|
||||||
}), ie=YoutubeTabIE.ie_key(), video_id=playlist_id)
|
}), ie=YoutubeTabIE.ie_key(), video_id=playlist_id)
|
||||||
|
|
||||||
|
|
||||||
class YoutubeLivestreamEmbedIE(InfoExtractor):
|
class YoutubeLivestreamEmbedIE(YoutubeBaseInfoExtractor):
|
||||||
IE_DESC = 'YouTube livestream embeds'
|
IE_DESC = 'YouTube livestream embeds'
|
||||||
_VALID_URL = r'https?://(?:\w+\.)?youtube\.com/embed/live_stream/?\?(?:[^#]+&)?channel=(?P<id>[^&#]+)'
|
_VALID_URL = r'https?://(?:\w+\.)?youtube\.com/embed/live_stream/?\?(?:[^#]+&)?channel=(?P<id>[^&#]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
|
@ -7153,7 +7164,7 @@ class YoutubeLivestreamEmbedIE(InfoExtractor):
|
||||||
ie=YoutubeTabIE.ie_key(), video_id=channel_id)
|
ie=YoutubeTabIE.ie_key(), video_id=channel_id)
|
||||||
|
|
||||||
|
|
||||||
class YoutubeYtUserIE(InfoExtractor):
|
class YoutubeYtUserIE(YoutubeBaseInfoExtractor):
|
||||||
IE_DESC = 'YouTube user videos; "ytuser:" prefix'
|
IE_DESC = 'YouTube user videos; "ytuser:" prefix'
|
||||||
IE_NAME = 'youtube:user'
|
IE_NAME = 'youtube:user'
|
||||||
_VALID_URL = r'ytuser:(?P<id>.+)'
|
_VALID_URL = r'ytuser:(?P<id>.+)'
|
||||||
|
@ -7440,7 +7451,7 @@ class YoutubeMusicSearchURLIE(YoutubeTabBaseInfoExtractor):
|
||||||
return self.playlist_result(self._search_results(query, params, default_client='web_music'), title, title)
|
return self.playlist_result(self._search_results(query, params, default_client='web_music'), title, title)
|
||||||
|
|
||||||
|
|
||||||
class YoutubeFeedsInfoExtractor(InfoExtractor):
|
class YoutubeFeedsInfoExtractor(YoutubeBaseInfoExtractor):
|
||||||
"""
|
"""
|
||||||
Base class for feed extractors
|
Base class for feed extractors
|
||||||
Subclasses must re-define the _FEED_NAME property.
|
Subclasses must re-define the _FEED_NAME property.
|
||||||
|
@ -7457,7 +7468,7 @@ class YoutubeFeedsInfoExtractor(InfoExtractor):
|
||||||
f'https://www.youtube.com/feed/{self._FEED_NAME}', ie=YoutubeTabIE.ie_key())
|
f'https://www.youtube.com/feed/{self._FEED_NAME}', ie=YoutubeTabIE.ie_key())
|
||||||
|
|
||||||
|
|
||||||
class YoutubeWatchLaterIE(InfoExtractor):
|
class YoutubeWatchLaterIE(YoutubeBaseInfoExtractor):
|
||||||
IE_NAME = 'youtube:watchlater'
|
IE_NAME = 'youtube:watchlater'
|
||||||
IE_DESC = 'Youtube watch later list; ":ytwatchlater" keyword (requires cookies)'
|
IE_DESC = 'Youtube watch later list; ":ytwatchlater" keyword (requires cookies)'
|
||||||
_VALID_URL = r':ytwatchlater'
|
_VALID_URL = r':ytwatchlater'
|
||||||
|
@ -7511,7 +7522,7 @@ class YoutubeHistoryIE(YoutubeFeedsInfoExtractor):
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
|
||||||
class YoutubeShortsAudioPivotIE(InfoExtractor):
|
class YoutubeShortsAudioPivotIE(YoutubeBaseInfoExtractor):
|
||||||
IE_DESC = 'YouTube Shorts audio pivot (Shorts using audio of a given video)'
|
IE_DESC = 'YouTube Shorts audio pivot (Shorts using audio of a given video)'
|
||||||
IE_NAME = 'youtube:shorts:pivot:audio'
|
IE_NAME = 'youtube:shorts:pivot:audio'
|
||||||
_VALID_URL = r'https?://(?:www\.)?youtube\.com/source/(?P<id>[\w-]{11})/shorts'
|
_VALID_URL = r'https?://(?:www\.)?youtube\.com/source/(?P<id>[\w-]{11})/shorts'
|
||||||
|
@ -7535,7 +7546,7 @@ class YoutubeShortsAudioPivotIE(InfoExtractor):
|
||||||
ie=YoutubeTabIE)
|
ie=YoutubeTabIE)
|
||||||
|
|
||||||
|
|
||||||
class YoutubeTruncatedURLIE(InfoExtractor):
|
class YoutubeTruncatedURLIE(YoutubeBaseInfoExtractor):
|
||||||
IE_NAME = 'youtube:truncated_url'
|
IE_NAME = 'youtube:truncated_url'
|
||||||
IE_DESC = False # Do not list
|
IE_DESC = False # Do not list
|
||||||
_VALID_URL = r'''(?x)
|
_VALID_URL = r'''(?x)
|
||||||
|
@ -7694,7 +7705,7 @@ class YoutubeConsentRedirectIE(YoutubeBaseInfoExtractor):
|
||||||
return self.url_result(redirect_url)
|
return self.url_result(redirect_url)
|
||||||
|
|
||||||
|
|
||||||
class YoutubeTruncatedIDIE(InfoExtractor):
|
class YoutubeTruncatedIDIE(YoutubeBaseInfoExtractor):
|
||||||
IE_NAME = 'youtube:truncated_id'
|
IE_NAME = 'youtube:truncated_id'
|
||||||
IE_DESC = False # Do not list
|
IE_DESC = False # Do not list
|
||||||
_VALID_URL = r'https?://(?:www\.)?youtube\.com/watch\?v=(?P<id>[0-9A-Za-z_-]{1,10})$'
|
_VALID_URL = r'https?://(?:www\.)?youtube\.com/watch\?v=(?P<id>[0-9A-Za-z_-]{1,10})$'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user