From 1cbd080821ca13b4b0d3bf04a951a5261b671592 Mon Sep 17 00:00:00 2001 From: Dion Date: Fri, 15 May 2026 00:00:57 +0930 Subject: [PATCH] Debugging the TEN service --- autograbber.py | 10 ++++++---- services/base.py | 18 +++++++++++++++++- services/iview.py | 4 ++-- services/ten.py | 27 +++++++++++++++------------ 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/autograbber.py b/autograbber.py index a713c98..948a273 100755 --- a/autograbber.py +++ b/autograbber.py @@ -2,6 +2,7 @@ import argparse import sys +import json from pathlib import Path from services.iview import iViewService from services.ten import TenService @@ -24,7 +25,7 @@ class AutoGrabber: self.config_dir = Path(config_dir) self.history_file = self.config_dir / "history" - self.series_file = self.config_dir / "series" + self.series_file = self.config_dir / "series.json" self.dry_run = dry_run self.mark_existing = mark_existing @@ -80,6 +81,7 @@ class AutoGrabber: def process_show(self, config): service_name = config.get("service") source_title = config.get("source_title") + source_url = config.get("source_url") if not service_name or not source_title: print(f"āŒ Skipping invalid entry: {config} (Missing service or source_title)") @@ -103,7 +105,7 @@ class AutoGrabber: print("==============================") # 3. Discovery (Ten will handle its own requirement for source_season) - seasons = service.discover_seasons(source_title, source_season=source_season) + seasons = service.discover_seasons(source_title, source_season=source_season, source_url=source_url) if not seasons: # Service will have already printed its specific error message @@ -146,8 +148,8 @@ class AutoGrabber: self.save_history() def run(self): - for service, source, output in self.series_list: - self.process_show(service, source, output) + for show_config in self.series_list: + self.process_show(show_config) print("\nāœ… Done.") # ------------------------- diff --git a/services/base.py b/services/base.py index abb0967..10c70c4 100644 --- a/services/base.py +++ b/services/base.py @@ -3,7 +3,22 @@ from pathlib import Path from abc import ABC, abstractmethod class BaseService(ABC): - # ... your existing abstract methods ... + + @abstractmethod + def name(self): + pass + + @abstractmethod + def slugify(self, text): + pass + + @abstractmethod + def discover_seasons(self, show_title, source_season=None, source_url=None): + pass + + @abstractmethod + def normalize_episode(self, source_title, output_title, entry): + pass def download_episode(self, episode, entry, download_dir): """ @@ -32,3 +47,4 @@ class BaseService(ABC): result = subprocess.run(cmd) return result.returncode == 0 + diff --git a/services/iview.py b/services/iview.py index 62664e7..9f10bc9 100644 --- a/services/iview.py +++ b/services/iview.py @@ -125,7 +125,7 @@ class iViewService(BaseService): # ------------------------- # Season discovery # ------------------------- - def discover_seasons(self, show_title): + def discover_seasons(self, show_title, source_season=None, source_url=None): slug = self.slugify(show_title) @@ -161,7 +161,7 @@ class iViewService(BaseService): # ------------------------- # Episode normalization # ------------------------- - def normalize_episode(self, show_title, entry): + def normalize_episode(self, show_title, entry, season_num): season = entry.get("season_number") or 1 episode = entry.get("episode_number") or 1 diff --git a/services/ten.py b/services/ten.py index 8afd086..da5dc92 100644 --- a/services/ten.py +++ b/services/ten.py @@ -34,12 +34,19 @@ class TenService(BaseService): print(f"āŒ Error: Ten requires 'source_season' in series.json for '{show_title}'") return None - if config.get("source_url"): - url = config["source_url"] - else: - slug = self.slugify(show_title) - # Ten URL structure: /v/show-name/season-YYYY or /v/show-name/season-X - url = f"https://10play.com.au/{slug}/episodes/season-{source_season}" + if source_url: + url = source_url + else: + slug = self.slugify(show_title) + # Ten URL structure: /v/show-name/episodes/YYYY or /v/show-name/episodes/season-X + s_str = str(source_season) + + if len(s_str) == 4: + season_path = s_str + else: + season_path = f"season-{s_str}" + + url = f"https://10play.com.au/{slug}/episodes/{season_path}" print(f"šŸ”Ž Querying Ten: {url}") data = self.run_ytdlp_json(url) @@ -72,15 +79,11 @@ class TenService(BaseService): show_clean = output_title.replace(" ", ".") title_clean = clean_title.replace(" ", ".") - filename = f"{show_clean}.S{s_val:02d}E{episode_idx:02d}.{title_clean}".strip(".") + # filename = f"{show_clean}.S{s_val:02d}E{episode_idx:02d}.{title_clean}".strip(".") # With episode title + filename = f"{show_clean}.S{s_val:02d}E{episode_idx:02d}".strip(".") # Without episode title return { "show": show_clean, "episode_id": episode_id, "filename": filename } - - def download_episode(self, episode, entry, download_dir): - # You can reuse the logic from your iViewService here - # Just ensure --netrc is included in the final subprocess call - pass