Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[extractor/nebula] Support public videos without an account and channel extractor improvements #6334

Closed
wants to merge 8 commits into from
43 changes: 40 additions & 3 deletions yt_dlp/extractor/nebula.py
Expand Up @@ -14,6 +14,9 @@ class NebulaBaseIE(InfoExtractor):
_nebula_api_token = None
_nebula_bearer_token = None

def _real_initialize(self):
self._nebula_bearer_token = self._fetch_nebula_bearer_token()

def _perform_nebula_auth(self, username, password):
if not username or not password:
self.raise_login_required(method='password')
Expand Down Expand Up @@ -41,7 +44,8 @@ def _call_nebula_api(self, url, video_id=None, method='GET', auth_type='api', no
def inner_call():
authorization = f'Token {self._nebula_api_token}' if auth_type == 'api' else f'Bearer {self._nebula_bearer_token}'
return self._download_json(
url, video_id, note=note, headers={'Authorization': authorization},
url, video_id, note=note,
headers={'Authorization': authorization} if self._nebula_api_token or self._nebula_bearer_token else {},
data=b'' if method == 'POST' else None)

try:
Expand Down Expand Up @@ -103,15 +107,13 @@ def _build_video_info(self, episode):

def _perform_login(self, username=None, password=None):
self._nebula_api_token = self._perform_nebula_auth(username, password)
self._nebula_bearer_token = self._fetch_nebula_bearer_token()


class NebulaIE(NebulaBaseIE):
_VALID_URL = rf'{_BASE_URL_RE}/videos/(?P<id>[-\w]+)'
_TESTS = [
{
'url': 'https://nebula.tv/videos/that-time-disney-remade-beauty-and-the-beast',
'md5': '14944cfee8c7beeea106320c47560efc',
'info_dict': {
'id': '5c271b40b13fd613090034fd',
'ext': 'mp4',
Expand All @@ -132,6 +134,9 @@ class NebulaIE(NebulaBaseIE):
'duration': 2212,
'thumbnail': r're:https://\w+\.cloudfront\.net/[\w-]+\.jpeg?.*',
},
'params': {
'skip_download': 'm3u8',
},
},
{
'url': 'https://nebula.tv/videos/the-logistics-of-d-day-landing-craft-how-the-allies-got-ashore',
Expand Down Expand Up @@ -182,6 +187,30 @@ class NebulaIE(NebulaBaseIE):
{
'url': 'https://watchnebula.com/videos/money-episode-1-the-draw',
'only_matching': True,
}, {
'url': 'https://nebula.tv/videos/tldrnewseu-did-the-us-really-blow-up-the-nordstream-pipelines',
'info_dict': {
'id': '63f64c74366fcd00017c1513',
'display_id': 'tldrnewseu-did-the-us-really-blow-up-the-nordstream-pipelines',
'title': 'Did the US Really Blow Up the NordStream Pipelines?',
'description': 'md5:b4e2a14e3ff08f546a3209c75261e789',
'upload_date': '20230223',
'timestamp': 1677144070,
'channel': 'TLDR News EU',
'channel_id': 'tldrnewseu',
'uploader': 'TLDR News EU',
'uploader_id': 'tldrnewseu',
'uploader_url': 'https://nebula.tv/tldrnewseu',
'duration': 524,
'channel_url': 'https://nebula.tv/tldrnewseu',
'series': 'TLDR News EU',
'thumbnail': r're:https?://.*\.jpeg',
'creator': 'TLDR News EU',
'ext': 'mp4',
},
'params': {
'skip_download': 'm3u8',
},
},
]

Expand Down Expand Up @@ -245,6 +274,14 @@ class NebulaChannelIE(NebulaBaseIE):
'description': 'Enjoy these hottest of takes on Disney, Transformers, and Musicals.',
},
'playlist_mincount': 2,
}, {
'url': 'https://nebula.tv/johnnyharris',
'info_dict': {
'id': 'johnnyharris',
'title': 'Johnny Harris',
'description': 'I make videos about maps and many other things.',
},
'playlist_mincount': 90,
},
]

Expand Down