Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions DSM_5_cache_installation.md
Original file line number Diff line number Diff line change
@@ -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
```

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
## QuickStart
### Installation



```bash
git clone https://github.com/Olezhich/AudioTagLoader.git

Expand All @@ -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
Expand All @@ -46,5 +50,5 @@ autag fba "The Artist Name" .

# Final step: set tags into tracks

autag set
auset
```
11 changes: 8 additions & 3 deletions audiotagloader/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from .redis import redis_client

import typer

UPDATE_CACHE = False


Expand Down Expand Up @@ -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())
Expand All @@ -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"
Expand All @@ -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

Expand Down
8 changes: 7 additions & 1 deletion audiotagloader/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from .models import Album, Image, Tracklist

import typer


def track_tags_to_output(func) -> Callable:
@wraps(func)
Expand Down Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@


if __name__ == "__main__":
audiotagloader.cli.cli_app()
try:
audiotagloader.cli.cli_app()
except KeyboardInterrupt:
print("Program terminates")
2 changes: 1 addition & 1 deletion scripts/kid3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading