From 69566061ba79c96286b3493215e2efcd16e5d742 Mon Sep 17 00:00:00 2001 From: lambda <> Date: Thu, 26 Mar 2026 12:07:57 +0100 Subject: [PATCH] NBLA: Extract episode numbers from label --- NBLA/__init__.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/NBLA/__init__.py b/NBLA/__init__.py index 4fee102..f177e7d 100644 --- a/NBLA/__init__.py +++ b/NBLA/__init__.py @@ -109,6 +109,7 @@ class NBLA(Service): VIDEO_RE = r"https?://(?:www\.)?nebula\.tv/videos/(?P.+)" CHANNEL_RE = r"^https?://(?:www\.)?nebula\.tv/(?P.+)" + 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()