Skip to content

Commit

Permalink
[nebula] change to new API URL
Browse files Browse the repository at this point in the history
* fix up tests
* keep zype_id as archive ID if it exists

Original Patch by @Lamieur on issue yt-dlp#7017
  • Loading branch information
rohieb committed Jun 11, 2023
1 parent 93e12ed commit f3e0a33
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions yt_dlp/extractor/nebula.py
Expand Up @@ -3,7 +3,11 @@
import urllib.error

from .common import InfoExtractor
from ..utils import ExtractorError, parse_iso8601
from ..utils import (
ExtractorError,
parse_iso8601,
make_archive_id
)

_BASE_URL_RE = r'https?://(?:www\.|beta\.)?(?:watchnebula\.com|nebula\.app|nebula\.tv)'

Expand Down Expand Up @@ -65,7 +69,7 @@ def _fetch_nebula_bearer_token(self):
return response['token']

def _fetch_video_formats(self, slug):
stream_info = self._call_nebula_api(f'https://content.watchnebula.com/video/{slug}/stream/',
stream_info = self._call_nebula_api(f'https://content.api.nebula.app/video/{slug}/stream/',
video_id=slug,
auth_type='bearer',
note='Fetching video stream info')
Expand All @@ -76,8 +80,12 @@ def _build_video_info(self, episode):
fmts, subs = self._fetch_video_formats(episode['slug'])
channel_slug = episode['channel_slug']
channel_title = episode['channel_title']
if episode['zype_id']:
zype_id = episode['zype_id']
else:
zype_id = None
return {
'id': episode['zype_id'],
'id': episode['id'].replace('video_episode:', ''),
'display_id': episode['slug'],
'formats': fmts,
'subtitles': subs,
Expand All @@ -99,6 +107,7 @@ def _build_video_info(self, episode):
'uploader_url': f'https://nebula.tv/{channel_slug}',
'series': channel_title,
'creator': channel_title,
'_old_archive_ids': [make_archive_id(self, zype_id)] if zype_id else None,
}

def _perform_login(self, username=None, password=None):
Expand All @@ -113,7 +122,7 @@ class NebulaIE(NebulaBaseIE):
'url': 'https://nebula.tv/videos/that-time-disney-remade-beauty-and-the-beast',
'md5': '14944cfee8c7beeea106320c47560efc',
'info_dict': {
'id': '5c271b40b13fd613090034fd',
'id': '84ed544d-4afd-4723-8cd5-2b95261f0abf',
'ext': 'mp4',
'title': 'That Time Disney Remade Beauty and the Beast',
'description': 'Note: this video was originally posted on YouTube with the sponsor read included. We weren’t able to remove it without reducing video quality, so it’s presented here in its original context.',
Expand All @@ -137,30 +146,30 @@ class NebulaIE(NebulaBaseIE):
'url': 'https://nebula.tv/videos/the-logistics-of-d-day-landing-craft-how-the-allies-got-ashore',
'md5': 'd05739cf6c38c09322422f696b569c23',
'info_dict': {
'id': '5e7e78171aaf320001fbd6be',
'id': '7e623145-1b44-4ca3-aa0b-ed25a247ea34',
'ext': 'mp4',
'title': 'Landing Craft - How The Allies Got Ashore',
'description': r're:^In this episode we explore the unsung heroes of D-Day, the landing craft.',
'upload_date': '20200327',
'timestamp': 1585348140,
'channel': 'Real Engineering',
'channel_id': 'realengineering',
'uploader': 'Real Engineering',
'uploader_id': 'realengineering',
'series': 'Real Engineering',
'channel': 'Real Engineering — The Logistics of D-Day',
'channel_id': 'd-day',
'uploader': 'Real Engineering — The Logistics of D-Day',
'uploader_id': 'd-day',
'series': 'Real Engineering — The Logistics of D-Day',
'display_id': 'the-logistics-of-d-day-landing-craft-how-the-allies-got-ashore',
'creator': 'Real Engineering',
'creator': 'Real Engineering — The Logistics of D-Day',
'duration': 841,
'channel_url': 'https://nebula.tv/realengineering',
'uploader_url': 'https://nebula.tv/realengineering',
'channel_url': 'https://nebula.tv/d-day',
'uploader_url': 'https://nebula.tv/d-day',
'thumbnail': r're:https://\w+\.cloudfront\.net/[\w-]+\.jpeg?.*',
},
},
{
'url': 'https://nebula.tv/videos/money-episode-1-the-draw',
'md5': 'ebe28a7ad822b9ee172387d860487868',
'info_dict': {
'id': '5e779ebdd157bc0001d1c75a',
'id': 'b96c5714-9e2b-4ec3-b3f1-20f6e89cc553',
'ext': 'mp4',
'title': 'Episode 1: The Draw',
'description': r'contains:There’s free money on offer… if the players can all work together.',
Expand Down Expand Up @@ -190,7 +199,7 @@ class NebulaIE(NebulaBaseIE):
]

def _fetch_video_metadata(self, slug):
return self._call_nebula_api(f'https://content.watchnebula.com/video/{slug}/',
return self._call_nebula_api(f'https://content.api.nebula.app/video/{slug}/',
video_id=slug,
auth_type='bearer',
note='Fetching video meta data')
Expand Down

0 comments on commit f3e0a33

Please sign in to comment.