From cb3b65de065fc4ea75890a9716d481ce9774eecf Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Wed, 1 Mar 2023 00:03:35 +0300 Subject: [PATCH] Add info about cache and cache_helper.sh script --- README.md | 6 ++++++ cache_helper.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 cache_helper.sh diff --git a/README.md b/README.md index d973200..6fcaa29 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,12 @@ Python dependencies: ```pip install -r requirements.txt``` Optional: brotli +### About cache folder +funkwhale-cli first to cache tracks before playing. Cache is persistent and You manage manually as is. +Cache structure: cache/domain.tld/[track uuid] +You can to play tracks offline, example: mpv --shuffle cache/*/* +cache_helper.sh - just useful for compression cache (lossy: vorbis 128 kbps, no thumbnail) + Also, tnx Inex for his FunkWhale instance (set by default instance) [1]**Warning:** may content _unofficial instances_ diff --git a/cache_helper.sh b/cache_helper.sh new file mode 100755 index 0000000..c6b3d25 --- /dev/null +++ b/cache_helper.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +if [ ! -n "$1" ]; then + echo 'Usage: cache_helper.sh path/to/cache' + exit 1 +fi + +total_before=0 +total_after=0 +for i in "$1"/*/*; do + if [ $(ffprobe -hide_banner -print_format json -select_streams a:0 -show_streams "$i" | jq '.streams[0].codec_name') != "vorbis" ]; then + size_before=$(stat --format=%s "$i") + total_before=$(( $total_before + $size_before )) + ffmpeg -hide_banner -loglevel error -i "$i" -vn "$i".ogg + if [ $? -eq 0 ]; then + size_after=$(stat --format=%s "$i".ogg) + total_after=$(( $total_after + $size_after )) + echo "before: $(echo $size_before | numfmt --to=iec) | after: $(echo $size_after | numfmt --to=iec)" + mv "$i".ogg "$i" + else + echo "$i convert failed" + fi + else + echo "$i already compressed good" + fi +done + +echo "Total before: $(echo $total_before | numfmt --to=iec)" +echo "Total after: $(echo $total_after | numfmt --to=iec)" +echo "Note: only included processed tracks"