Add ability to mark existing episodes at source as already downloaded without downloading
This commit is contained in:
+35
-5
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
@@ -11,10 +12,10 @@ from services.iview import iViewService
|
|||||||
# -------------------------
|
# -------------------------
|
||||||
# Metadata paths
|
# Metadata paths
|
||||||
# -------------------------
|
# -------------------------
|
||||||
DOWNLOAD_META = Path("./.download")
|
DOWNLOAD_META = Path("./.config")
|
||||||
|
|
||||||
HISTORY_FILE = DOWNLOAD_META / ".history"
|
HISTORY_FILE = DOWNLOAD_META / "history"
|
||||||
SERIES_FILE = DOWNLOAD_META / ".series"
|
SERIES_FILE = DOWNLOAD_META / "series"
|
||||||
|
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
@@ -30,10 +31,16 @@ SERVICES = {
|
|||||||
# -------------------------
|
# -------------------------
|
||||||
class AutoGrabber:
|
class AutoGrabber:
|
||||||
|
|
||||||
def __init__(self, download_dir, dry_run=False):
|
def __init__(
|
||||||
|
self,
|
||||||
|
download_dir,
|
||||||
|
dry_run=False,
|
||||||
|
mark_existing=False
|
||||||
|
):
|
||||||
|
|
||||||
self.download_dir = Path(download_dir)
|
self.download_dir = Path(download_dir)
|
||||||
self.dry_run = dry_run
|
self.dry_run = dry_run
|
||||||
|
self.mark_existing = mark_existing
|
||||||
|
|
||||||
self.history = self.load_history()
|
self.history = self.load_history()
|
||||||
self.series_list = self.load_series()
|
self.series_list = self.load_series()
|
||||||
@@ -197,6 +204,22 @@ class AutoGrabber:
|
|||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# mark-existing mode
|
||||||
|
if self.mark_existing:
|
||||||
|
|
||||||
|
print(
|
||||||
|
f"📝 "
|
||||||
|
f"{filename} "
|
||||||
|
f"(added to history)"
|
||||||
|
)
|
||||||
|
|
||||||
|
self.history[ep_id] = filename
|
||||||
|
self.save_history()
|
||||||
|
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
# normal download mode
|
||||||
print(f"✅ {filename} → downloading")
|
print(f"✅ {filename} → downloading")
|
||||||
|
|
||||||
success = service.download_episode(
|
success = service.download_episode(
|
||||||
@@ -254,6 +277,12 @@ def parse_args():
|
|||||||
help="Download directory"
|
help="Download directory"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--mark-existing",
|
||||||
|
action="store_true",
|
||||||
|
help="Add all available episodes to history without downloading"
|
||||||
|
)
|
||||||
|
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
@@ -266,5 +295,6 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
AutoGrabber(
|
AutoGrabber(
|
||||||
download_dir=args.downloads,
|
download_dir=args.downloads,
|
||||||
dry_run=args.dry_run
|
dry_run=args.dry_run,
|
||||||
|
mark_existing=args.mark_existing
|
||||||
).run()
|
).run()
|
||||||
|
|||||||
Reference in New Issue
Block a user