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():
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)

View File

@ -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"]}')

View File

@ -1,13 +1,18 @@
{pkgs ? import <nixpkgs> {}}:
pkgs.mkShell {
packages = with pkgs; [
nodejs-16_x
nodePackages.yarn
(with dotnetCorePackages;
combinePackages [
sdk_6_0
aspnetcore_6_0
])
python3
];
}
{pkgs ? import <nixpkgs> {}}: 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)
];
}