[O] Avoid hardcoding dirs
This commit is contained in:
+4
-2
@@ -5,6 +5,8 @@ import os
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import time
|
import time
|
||||||
|
import tomllib
|
||||||
|
from utils import DEFAULT_DL_DIR, DEFAULT_JELLYFIN_DIR
|
||||||
|
|
||||||
def run_workflow(imdb_id: str, dl_dir: str, jellyfin_dir: str, logs_dir: Path, errors_dir: Path):
|
def run_workflow(imdb_id: str, dl_dir: str, jellyfin_dir: str, logs_dir: Path, errors_dir: Path):
|
||||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||||
@@ -39,8 +41,8 @@ def run_workflow(imdb_id: str, dl_dir: str, jellyfin_dir: str, logs_dir: Path, e
|
|||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="Multithreading launcher for IMDB workflow.")
|
parser = argparse.ArgumentParser(description="Multithreading launcher for IMDB workflow.")
|
||||||
parser.add_argument("imdb_ids", nargs="+", help="The IMDb IDs to process (e.g., tt38872297 tt0903747)")
|
parser.add_argument("imdb_ids", nargs="+", help="The IMDb IDs to process (e.g., tt38872297 tt0903747)")
|
||||||
parser.add_argument("--dl-dir", type=str, default="/data/QB", help="The qBittorrent download directory")
|
parser.add_argument("--dl-dir", type=str, default=DEFAULT_DL_DIR, help="The qBittorrent download directory")
|
||||||
parser.add_argument("--jellyfin-dir", type=str, default="/data/Jellyfin", help="The base Jellyfin library directory")
|
parser.add_argument("--jellyfin-dir", type=str, default=DEFAULT_JELLYFIN_DIR, help="The base Jellyfin library directory")
|
||||||
parser.add_argument("--workers", type=int, default=4, help="Number of concurrent workers")
|
parser.add_argument("--workers", type=int, default=4, help="Number of concurrent workers")
|
||||||
parser.add_argument("--delay", type=float, default=5.0, help="Delay in seconds between starting each workflow")
|
parser.add_argument("--delay", type=float, default=5.0, help="Delay in seconds between starting each workflow")
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
import json
|
import json
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import tomllib
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
|
config = tomllib.loads(Path("config.toml").read_text(encoding="utf-8"))
|
||||||
|
DEFAULT_DL_DIR = config["paths"]["qb_download_dir"]
|
||||||
|
DEFAULT_JELLYFIN_DIR = config["paths"]["jellyfin_dir"]
|
||||||
|
|
||||||
def _disk_cache_decorator(subdir_name: str, ext: str, read_func, write_func, should_cache = None):
|
def _disk_cache_decorator(subdir_name: str, ext: str, read_func, write_func, should_cache = None):
|
||||||
"""
|
"""
|
||||||
Generic internal caching decorator handling filename hashing and io abstraction.
|
Generic internal caching decorator handling filename hashing and io abstraction.
|
||||||
|
|||||||
+4
-3
@@ -2,6 +2,7 @@ import json
|
|||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from utils import DEFAULT_DL_DIR, DEFAULT_JELLYFIN_DIR
|
||||||
from utils_mteam import (
|
from utils_mteam import (
|
||||||
mteam_imdb_info,
|
mteam_imdb_info,
|
||||||
search_mteam_torrents,
|
search_mteam_torrents,
|
||||||
@@ -82,7 +83,7 @@ def wait_for_download(qb, t_hash: str):
|
|||||||
print("Download complete!")
|
print("Download complete!")
|
||||||
|
|
||||||
|
|
||||||
def process_imdb_workflow(imdb_id: str, dl_dir: str = "/data/QB", jellyfin_base_dir: str = "/data/Jellyfin"):
|
def process_imdb_workflow(imdb_id: str, dl_dir: str = DEFAULT_DL_DIR, jellyfin_base_dir: str = DEFAULT_JELLYFIN_DIR):
|
||||||
"""
|
"""
|
||||||
Workflow to automatically find, download, and map torrents for an IMDb ID into a Jellyfin library.
|
Workflow to automatically find, download, and map torrents for an IMDb ID into a Jellyfin library.
|
||||||
"""
|
"""
|
||||||
@@ -212,8 +213,8 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Workflow to automatically find, download, and map torrents for an IMDb ID into Jellyfin.")
|
parser = argparse.ArgumentParser(description="Workflow to automatically find, download, and map torrents for an IMDb ID into Jellyfin.")
|
||||||
parser.add_argument("imdb_id", type=str, help="The IMDb ID to process (e.g., tt38872297)")
|
parser.add_argument("imdb_id", type=str, help="The IMDb ID to process (e.g., tt38872297)")
|
||||||
parser.add_argument("--dl-dir", type=str, default="/data/QB", help="The qBittorrent download directory")
|
parser.add_argument("--dl-dir", type=str, default=DEFAULT_DL_DIR, help="The qBittorrent download directory")
|
||||||
parser.add_argument("--jellyfin-dir", type=str, default="/data/Jellyfin", help="The base Jellyfin library directory")
|
parser.add_argument("--jellyfin-dir", type=str, default=DEFAULT_JELLYFIN_DIR, help="The base Jellyfin library directory")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user