From 61236107bf8490ce1c94e9fc086b5dabed3763bf Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Fri, 1 May 2026 12:09:57 +0300 Subject: [PATCH] music-to-mp3.bash: initial commit --- bash/.gitignore | 3 +++ bash/music-to-mp3.bash | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 bash/music-to-mp3.bash diff --git a/bash/.gitignore b/bash/.gitignore index 7aefd4f..f904195 100644 --- a/bash/.gitignore +++ b/bash/.gitignore @@ -21,3 +21,6 @@ systemd-resolv.conf-generate.bash systemd-resolv.conf-restore.bash traditional-resolv.conf-generate.bash NetworkManager-resolv.conf-restore.bash +# music-to-mp3.bash +*.flac +*.mp3 diff --git a/bash/music-to-mp3.bash b/bash/music-to-mp3.bash new file mode 100755 index 0000000..5fe23b1 --- /dev/null +++ b/bash/music-to-mp3.bash @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# This is just a quick script to get mp3 files for 200X or early 201X vinyl +# player that happens to have a USB port and mp3 logo and doesn't accept +# anything else. +# +# I accidentally plotted this in my head drinking tea outside. + +set -x + +# Without ffmpeg we are doomed to fail +if ! hash ffmpeg 2> /dev/null; then + echo "ffmpeg not found" + exit 1 +fi + +# Convert flacs +for flac in *.flac; do + if [ -f "$flac.mp3" ]; then + echo "$flac.mp3 already exists" + else + ffmpeg -i "$flac" "$flac.mp3" + fi +done + +# Convert opus files too since yt-dlp has resulted into them +for opus in *.opus; do + if [ -f "$opus.mp3" ]; then + echo "$opus.mp3 already exists" + else + ffmpeg -i "$opus" "$opus.mp3" + fi +done + +# TODO: The output have silly extensions MUSIC.{flac,opus}.mp3 + +set +x