Skip to content

Instantly share code, notes, and snippets.

@cassava
Created June 27, 2019 08:28
Show Gist options
  • Save cassava/d03dbf1ddb20934b8adc6e28566abc2e to your computer and use it in GitHub Desktop.
Save cassava/d03dbf1ddb20934b8adc6e28566abc2e to your computer and use it in GitHub Desktop.
Script to use lackey and convert to create low-quality music library.
#!/bin/sh
musicsource=/home/media/music
update_music2go() {
# Make source library read-only so I know I'm not fucking up somehow...
musicsource_tmp=${musicsource}_readonly
if [ -d ${musicsource_tmp} ]; then
echo "Something wrong here!"
exit 1
else
sudo mkdir ${musicsource_tmp}
sudo mount -o bind,ro ${musicsource} ${musicsource_tmp}
if [ $? -ne 0 ]; then
echo "Not able to mount read-only music directory..."
exit 1
fi
fi
lackey -L ${musicsource_tmp} sync -m -e cover.jpg -d --bitrate 128k --opus --use-ogg-extension /home/media/music2go
# Delete all images that are not named "cover.jpg"
cd /home/media/music2go || exit 1;
find -name "cover.jpg" | while read file; do
read -r -a info <<< "$(imginfo -f "$file" | cut -d' ' -f3,4)"
if [[ ${info[0]} -gt 500 || ${info[1]} -gt 500 ]] ; then
echo "convert $file"
convert "$file" -resize 500x500 -quality 60% "$file"
fi
done
sudo umount ${musicsource_tmp}
sudo rmdir ${musicsource_tmp}
}
update_music2go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment