Add TEN service, change series config format to JSON
This commit is contained in:
+48
-20
@@ -4,12 +4,15 @@ import argparse
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from services.iview import iViewService
|
||||
from services.ten import TenService
|
||||
|
||||
|
||||
# -------------------------
|
||||
# Service registry
|
||||
# -------------------------
|
||||
SERVICES = {
|
||||
"IVIEW": iViewService(),
|
||||
"TEN": TenService(),
|
||||
}
|
||||
|
||||
class AutoGrabber:
|
||||
@@ -56,45 +59,70 @@ class AutoGrabber:
|
||||
f.write(f"{ep_id} | {filename}\n" if filename else f"{ep_id}\n")
|
||||
|
||||
def load_series(self):
|
||||
self.series_file = self.config_dir / "series.json"
|
||||
|
||||
if not self.series_file.exists():
|
||||
print(f"❌ Error: Series file not found at {self.series_file}")
|
||||
print(f"Please ensure your series list is in {self.config_dir}/series")
|
||||
print(f"Please ensure your series list is in {self.config_dir}/series.json")
|
||||
sys.exit(1)
|
||||
|
||||
series = []
|
||||
with open(self.series_file, "r") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line or "/" not in line: continue
|
||||
try:
|
||||
with open(self.series_file, "r") as f:
|
||||
return json.load(f)
|
||||
except json.JSONDecodeError as e:
|
||||
print(f"❌ Failed to parse series.json: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
service_name, remainder = line.split("/", 1)
|
||||
if "|" in remainder:
|
||||
source_title, output_title = remainder.split("|", 1)
|
||||
else:
|
||||
source_title = output_title = remainder
|
||||
def run(self):
|
||||
for show_config in self.series_list:
|
||||
self.process_show(show_config)
|
||||
|
||||
series.append((service_name.strip(), source_title.strip(), output_title.strip()))
|
||||
return series
|
||||
def process_show(self, config):
|
||||
service_name = config.get("service")
|
||||
source_title = config.get("source_title")
|
||||
|
||||
if not service_name or not source_title:
|
||||
print(f"❌ Skipping invalid entry: {config} (Missing service or source_title)")
|
||||
return
|
||||
|
||||
def process_show(self, service_name, source_title, output_title):
|
||||
service = SERVICES.get(service_name.upper())
|
||||
if not service:
|
||||
print(f"❌ Unknown service: {service_name}")
|
||||
return
|
||||
|
||||
print(f"\n📺 Show: {output_title} ({service_name})")
|
||||
seasons = service.discover_seasons(source_title)
|
||||
# 2. Setup Defaults for Output Fields
|
||||
output_title = config.get("output_title") or source_title
|
||||
|
||||
source_season = config.get("source_season")
|
||||
# If output_season isn't provided, use source_season (if it exists)
|
||||
output_season = config.get("output_season") or source_season
|
||||
|
||||
print(f"\n==============================")
|
||||
print(f"📺 Show: {output_title}")
|
||||
print(f"📡 Service: {service_name}")
|
||||
print("==============================")
|
||||
|
||||
# 3. Discovery (Ten will handle its own requirement for source_season)
|
||||
seasons = service.discover_seasons(source_title, source_season=source_season)
|
||||
|
||||
if not seasons:
|
||||
print("⚠️ No seasons found")
|
||||
# Service will have already printed its specific error message
|
||||
return
|
||||
|
||||
for season_data in seasons:
|
||||
season_num = season_data["season"]
|
||||
print(f"📦 Season {season_num}")
|
||||
# We use the resolved output_season (either from JSON or fallback)
|
||||
# If discovery found a season number and we have no override, we use that.
|
||||
final_season = output_season or season_data.get("season")
|
||||
|
||||
print(f"\n📦 Processing Season {final_season}")
|
||||
|
||||
|
||||
for entry in season_data["data"]["entries"]:
|
||||
episode = service.normalize_episode(output_title, entry)
|
||||
episode = service.normalize_episode(
|
||||
output_title,
|
||||
entry,
|
||||
season_num=final_season
|
||||
)
|
||||
ep_id = episode["episode_id"]
|
||||
filename = episode["filename"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user