diff --git a/DSM_5_cache_installation.md b/DSM_5_cache_installation.md new file mode 100644 index 0000000..b9b2bdc --- /dev/null +++ b/DSM_5_cache_installation.md @@ -0,0 +1,28 @@ +# DSM 5 cache installation + +> It is necessary to create an image `redis:7-alpine` for the required architecture, for example through Scopeo and install it into docker + +Connect to your dsm via `ssh` + +```bash +# create target dir +mkdir -m cache/data + +cd cache + +# copy redis dump into data if it exists + +# copy redis conf into . + +docker run -d \ + --name AudioTagLoader \ + --restart always \ + -p 6379:6379 \ + -v /volume1/docker/Containers/AudioTagLoader/data:/data \ + -v /volume1/docker/Containers/AudioTagLoader/redis.conf:/redis.conf \ + redis:7-alpine \ + redis-server /redis.conf --requirepass REDIS_PASSWORD + +# change "/volume1/docker/Containers/AudioTagLoader" to your path to cache +``` + diff --git a/README.md b/README.md index 1753e93..ca40611 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ ## QuickStart ### Installation + + ```bash git clone https://github.com/Olezhich/AudioTagLoader.git @@ -32,6 +34,8 @@ docker-compose -f cache/docker-compose.yml up -d You also may add `autag` script into `$PATH`. +[DSM 5 cache installation](DSM_5_cache_installation.md) + ### Uisng ```bash @@ -46,5 +50,5 @@ autag fba "The Artist Name" . # Final step: set tags into tracks -autag set +auset ``` \ No newline at end of file diff --git a/audiotagloader/cache.py b/audiotagloader/cache.py index 119df09..952e664 100644 --- a/audiotagloader/cache.py +++ b/audiotagloader/cache.py @@ -7,6 +7,8 @@ from .redis import redis_client +import typer + UPDATE_CACHE = False @@ -42,7 +44,9 @@ def wrapper(*args, **kwargs) -> Any: else: arg_type = get_args(return_type) current_type = arg_type[0] - print("load from redis") + typer.secho( + "Load from Redis cache", fg=typer.colors.GREEN, bold=True + ) return [ current_type.model_validate(item) for item in json.loads(data.decode()) @@ -51,7 +55,7 @@ def wrapper(*args, **kwargs) -> Any: raise e res = func(*args, **kwargs) - print("load from api") + typer.secho("Load from Discogs api", fg=typer.colors.YELLOW, bold=True) try: serialized = "null" @@ -63,7 +67,8 @@ def wrapper(*args, **kwargs) -> Any: serialized = json.dumps([item.model_dump() for item in res]) redis_client.set(key, serialized.encode()) - print("dump to redis") + + typer.secho("Dump to Redis cache", fg=typer.colors.GREEN, bold=True) except Exception as e: raise e diff --git a/audiotagloader/output.py b/audiotagloader/output.py index a402621..7058f06 100644 --- a/audiotagloader/output.py +++ b/audiotagloader/output.py @@ -3,6 +3,8 @@ from .models import Album, Image, Tracklist +import typer + def track_tags_to_output(func) -> Callable: @wraps(func) @@ -36,7 +38,11 @@ def wrapper(*args, **kwargs) -> tuple[Album, Image, Tracklist]: fp.write("\n".join(table)) fp.write("\n") - print(f"{album.year} - {album.artist} - {album.title}") + typer.secho( + f"{album.year} - {album.artist} - {album.title}", + fg=typer.colors.BLUE, + bold=True, + ) return res diff --git a/main.py b/main.py index 179dba8..f038e06 100644 --- a/main.py +++ b/main.py @@ -2,4 +2,7 @@ if __name__ == "__main__": - audiotagloader.cli.cli_app() + try: + audiotagloader.cli.cli_app() + except KeyboardInterrupt: + print("Program terminates") diff --git a/scripts/kid3.sh b/scripts/kid3.sh index bdb9367..452d758 100755 --- a/scripts/kid3.sh +++ b/scripts/kid3.sh @@ -7,7 +7,7 @@ DIR="$(dirname "$1")" dsf=() while IFS= read -r -d '' file; do dsf+=("$file") -done < <(find "$DIR" -maxdepth 1 \( -iname "*.dsf" -o -iname "*.flac" \) -type f -print0 | sort -z) +done < <(find "$DIR" -maxdepth 1 \( -iname "*.dsf" -o -iname "*.flac" -o -iname "*.dff" \) -type f -print0 | sort -z) i=0 while IFS=$'\t' read -r year artist album genre track title thumb cover; do