NBLA: Extract episode numbers from label

This commit is contained in:
lambda 2026-03-26 12:07:57 +01:00
parent f372e27978
commit 69566061ba

View File

@ -109,6 +109,7 @@ class NBLA(Service):
VIDEO_RE = r"https?://(?:www\.)?nebula\.tv/videos/(?P<slug>.+)"
CHANNEL_RE = r"^https?://(?:www\.)?nebula\.tv/(?P<slug>.+)"
EPISODE_LABEL_RE = re.compile("^Episode ([0-9]+)$")
@staticmethod
@click.command(name="NBLA", short_help="https://nebula.tv", help=__doc__)
@ -198,9 +199,8 @@ class NBLA(Service):
def get_chapters(self, title: Union[Episode, Movie]) -> list[Chapter]:
return []
def search(self) -> Generator[SearchResult, None, None]:
pass
return
#self.title
r = self.session.get(self.config["endpoints"]["search"], params=params)
r.raise_for_status()
@ -226,12 +226,19 @@ class NBLA(Service):
# Specials episode numbers will then likely be off, use caution and
# check TMDB for manual corrections.
season_number = 0
self.log.warn(f"Could not extract season information, guessing season {season_number}")
self.log.warn(f"Could not extract season information from {season['label']}, guessing season {season_number}")
for episode_number, episode in enumerate(season["episodes"], start=1):
if not episode["video"] or (video_id_filter and video_id_filter != episode["video"]["id"]):
continue
# Episodic content usually has a label like "Episode 1". Try to use that to
# fetch the episode number. Alternatively, fall back to just the enumerated
# numbers (these usually work well enough, but sometimes content is listed
# in reverse order)
if match := self.EPISODE_LABEL_RE.match(episode['label']):
episode_number = int(match.group(1))
yield Episode(
id_=episode["video"]["id"],
service=self.__class__,
@ -242,8 +249,6 @@ class NBLA(Service):
number=episode_number,
)
def get_content(self, slug, video_id_filter=None):
r = self.session.get(self.config["endpoints"]["content"].format(slug=slug))
content = r.json()