Add guessit

This commit is contained in:
Zoe Roux 2023-03-17 12:58:58 +09:00
parent 42adf023d9
commit 7427de1bb4
4 changed files with 34 additions and 16 deletions

1
scanner/requirments.txt Normal file
View File

@ -0,0 +1 @@
guessit

View File

@ -2,8 +2,13 @@ from .scanner import scan
def main(): def main():
import os import os
path = os.environ.get("LIBRARY_PATH") import logging
import sys
path = os.environ.get("LIBRARY_ROOT")
if not path: if not path:
print("Missing environment variable 'LIBRARY_PATH'.") print("Missing environment variable 'LIBRARY_ROOT'.")
exit(2) exit(2)
if len(sys.argv) > 1 and sys.argv[1] == "-v":
logging.basicConfig(level=logging.INFO)
return scan(path) return scan(path)

View File

@ -1,7 +1,14 @@
from pathlib import Path from pathlib import Path
from guessit import guessit
import logging
def scan(path: str): def scan(path: str):
for item in Path(path).rglob("*"): for item in Path(path).rglob("*"):
if not item.is_file(): if not item.is_file():
continue 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"]}')

View File

@ -1,13 +1,18 @@
{pkgs ? import <nixpkgs> {}}: {pkgs ? import <nixpkgs> {}}: let
pkgs.mkShell { pythonPackages = p:
packages = with pkgs; [ with p; [
nodejs-16_x guessit
nodePackages.yarn ];
(with dotnetCorePackages; in
combinePackages [ pkgs.mkShell {
sdk_6_0 packages = with pkgs; [
aspnetcore_6_0 nodejs-16_x
]) nodePackages.yarn
python3 (with dotnetCorePackages;
]; combinePackages [
} sdk_6_0
aspnetcore_6_0
])
(python3.withPackages pythonPackages)
];
}