diff --git a/scanner/requirments.txt b/scanner/requirments.txt new file mode 100644 index 00000000..d02be8ec --- /dev/null +++ b/scanner/requirments.txt @@ -0,0 +1 @@ +guessit diff --git a/scanner/scanner/__init__.py b/scanner/scanner/__init__.py index bdf6d95f..3f34a254 100644 --- a/scanner/scanner/__init__.py +++ b/scanner/scanner/__init__.py @@ -2,8 +2,13 @@ from .scanner import scan def main(): import os - path = os.environ.get("LIBRARY_PATH") + import logging + import sys + + path = os.environ.get("LIBRARY_ROOT") if not path: - print("Missing environment variable 'LIBRARY_PATH'.") + print("Missing environment variable 'LIBRARY_ROOT'.") exit(2) + if len(sys.argv) > 1 and sys.argv[1] == "-v": + logging.basicConfig(level=logging.INFO) return scan(path) diff --git a/scanner/scanner/scanner.py b/scanner/scanner/scanner.py index b796ba2d..8696e65d 100644 --- a/scanner/scanner/scanner.py +++ b/scanner/scanner/scanner.py @@ -1,7 +1,14 @@ from pathlib import Path +from guessit import guessit +import logging def scan(path: str): for item in Path(path).rglob("*"): if not item.is_file(): continue - print(item) + identify(item) + +def identify(path: Path): + raw = guessit(path) + logging.info("Identied %s: %s", path, raw) + # print(f'type: {raw["type"]}, title: {raw["title"]}') diff --git a/shell.nix b/shell.nix index 713b96e9..ae937d07 100644 --- a/shell.nix +++ b/shell.nix @@ -1,13 +1,18 @@ -{pkgs ? import {}}: -pkgs.mkShell { - packages = with pkgs; [ - nodejs-16_x - nodePackages.yarn - (with dotnetCorePackages; - combinePackages [ - sdk_6_0 - aspnetcore_6_0 - ]) - python3 - ]; -} +{pkgs ? import {}}: let + pythonPackages = p: + with p; [ + guessit + ]; +in + pkgs.mkShell { + packages = with pkgs; [ + nodejs-16_x + nodePackages.yarn + (with dotnetCorePackages; + combinePackages [ + sdk_6_0 + aspnetcore_6_0 + ]) + (python3.withPackages pythonPackages) + ]; + }