Skip to content

Instantly share code, notes, and snippets.

@xorspark
Created January 3, 2025 02:28
Show Gist options
  • Save xorspark/3842bd3b039816f67f963d6ac9c5b4bc to your computer and use it in GitHub Desktop.
Save xorspark/3842bd3b039816f67f963d6ac9c5b4bc to your computer and use it in GitHub Desktop.
Silly vorbis metadata adding script for my icecast server.
#!/bin/sh
#
# Quick and dirty shell script to tag previously downloaded and untagged music from
# YT using the filename. Redownloading with --embed-metadata is a little...problematic
# with YT's latest efforts in trying to block downloaders, so this'll have to do.
# I'd go harder on splitting out the title/artist info but YT titles aren't the greatest.
# As a compromise, I record the original URLs as comments in each file.
# All of this just to show a now playing title from my silly private icecast server full
# of video game music. ¯\_(ツ)_/¯
cd /usr/home/icecast/music
for i in *;
do
yt_url="$(printf "%s" "$i" | sed 's/\(.*\)-\(.\{11\}\)\.ogg/https:\/\/youtube.com\/watch?v=\2/')"
file_name="$(printf "%s" "$i" | sed 's/\(.*\)-\(.\{11\}\)\.ogg/\1/')"
printf "language=eng\nencoder=Lavc57.107.100 libvorbis\nTITLE=%s\nCOMMENT=%s\n" "$file_name" "$yt_url" > m.txt
vorbiscomment -w -c m.txt -R "$i"
done
cd /usr/home/icecast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment