Change ABCService to iViewService
This commit is contained in:
+64
-13
@@ -1,29 +1,27 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from services.iview import ABCService
|
from services.iview import iViewService
|
||||||
|
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# Metadata files
|
# Metadata paths
|
||||||
# -------------------------
|
# -------------------------
|
||||||
DOWNLOAD_META = Path("./.download")
|
DOWNLOAD_META = Path("./.download")
|
||||||
|
|
||||||
HISTORY_FILE = DOWNLOAD_META / ".history"
|
HISTORY_FILE = DOWNLOAD_META / ".history"
|
||||||
SERIES_FILE = DOWNLOAD_META / ".series"
|
SERIES_FILE = DOWNLOAD_META / ".series"
|
||||||
|
|
||||||
DOWNLOAD_META.mkdir(exist_ok=True)
|
|
||||||
|
|
||||||
HISTORY_FILE.touch(exist_ok=True)
|
|
||||||
SERIES_FILE.touch(exist_ok=True)
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# Service registry
|
# Service registry
|
||||||
# -------------------------
|
# -------------------------
|
||||||
SERVICES = {
|
SERVICES = {
|
||||||
"ABC": ABCService(),
|
"IVIEW": iViewService(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -32,7 +30,10 @@ SERVICES = {
|
|||||||
# -------------------------
|
# -------------------------
|
||||||
class AutoGrabber:
|
class AutoGrabber:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, download_dir, dry_run=False):
|
||||||
|
|
||||||
|
self.download_dir = Path(download_dir)
|
||||||
|
self.dry_run = dry_run
|
||||||
|
|
||||||
self.history = self.load_history()
|
self.history = self.load_history()
|
||||||
self.series_list = self.load_series()
|
self.series_list = self.load_series()
|
||||||
@@ -44,6 +45,9 @@ class AutoGrabber:
|
|||||||
|
|
||||||
history = {}
|
history = {}
|
||||||
|
|
||||||
|
if not HISTORY_FILE.exists():
|
||||||
|
HISTORY_FILE.touch()
|
||||||
|
|
||||||
with open(HISTORY_FILE, "r") as f:
|
with open(HISTORY_FILE, "r") as f:
|
||||||
|
|
||||||
for line in f:
|
for line in f:
|
||||||
@@ -60,7 +64,6 @@ class AutoGrabber:
|
|||||||
history[ep_id.strip()] = filename.strip()
|
history[ep_id.strip()] = filename.strip()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# backwards compatibility
|
|
||||||
history[line.strip()] = None
|
history[line.strip()] = None
|
||||||
|
|
||||||
return history
|
return history
|
||||||
@@ -83,6 +86,15 @@ class AutoGrabber:
|
|||||||
# -------------------------
|
# -------------------------
|
||||||
def load_series(self):
|
def load_series(self):
|
||||||
|
|
||||||
|
if not SERIES_FILE.exists():
|
||||||
|
|
||||||
|
print(
|
||||||
|
"❌ Missing required file: "
|
||||||
|
f"{SERIES_FILE}"
|
||||||
|
)
|
||||||
|
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
series = []
|
series = []
|
||||||
|
|
||||||
with open(SERIES_FILE, "r") as f:
|
with open(SERIES_FILE, "r") as f:
|
||||||
@@ -162,11 +174,23 @@ class AutoGrabber:
|
|||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print(f"✅ {filename} → queued")
|
# dry-run mode
|
||||||
|
if self.dry_run:
|
||||||
|
|
||||||
|
print(
|
||||||
|
f"🧪 "
|
||||||
|
f"{filename} "
|
||||||
|
f"(would download)"
|
||||||
|
)
|
||||||
|
|
||||||
|
continue
|
||||||
|
|
||||||
|
print(f"✅ {filename} → downloading")
|
||||||
|
|
||||||
success = service.download_episode(
|
success = service.download_episode(
|
||||||
episode,
|
episode,
|
||||||
entry
|
entry,
|
||||||
|
self.download_dir
|
||||||
)
|
)
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
@@ -194,9 +218,36 @@ class AutoGrabber:
|
|||||||
print("\n✅ Autograbber run complete")
|
print("\n✅ Autograbber run complete")
|
||||||
|
|
||||||
|
|
||||||
|
# -------------------------
|
||||||
|
# CLI
|
||||||
|
# -------------------------
|
||||||
|
def parse_args():
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--dry-run",
|
||||||
|
action="store_true",
|
||||||
|
help="Do not download anything"
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--downloads",
|
||||||
|
default="./downloads",
|
||||||
|
help="Download directory"
|
||||||
|
)
|
||||||
|
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# Entry point
|
# Entry point
|
||||||
# -------------------------
|
# -------------------------
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
AutoGrabber().run()
|
args = parse_args()
|
||||||
|
|
||||||
|
AutoGrabber(
|
||||||
|
download_dir=args.downloads,
|
||||||
|
dry_run=args.dry_run
|
||||||
|
).run()
|
||||||
|
|||||||
Reference in New Issue
Block a user