Skip to content

Instantly share code, notes, and snippets.

@rafi
Last active October 11, 2026 19:45
Show Gist options
  • Select an option

  • Save rafi/e5b8c3dfb984ac3123be to your computer and use it in GitHub Desktop.

Select an option

Save rafi/e5b8c3dfb984ac3123be to your computer and use it in GitHub Desktop.
Generate a playlist from a plain text file with songs. Using beets database to query file paths
#!/bin/bash
music_path="/mnt/media/music"
while read line
do
song=$(echo $line | sed 's/(.*)//g')
artist=$(echo ${song% - *} | sed 's/ *$//')
title=$(echo ${song#* - } | sed 's/ *$//')
if [ -n "$title" ]; then
match=$(beet ls -p artist:"$artist" title:"$title")
echo "Artist: $artist Title: $title"
if [ -n "$match" ]; then
match=${match#${music_path}/}
echo $match >> playlist_matched.m3u
else
echo $line >> playlist_missing.txt
fi
fi
done < $1
The Black Angels - Entrance Song
Caribou - Odessa
LCD Soundsystem - Dance Yrself Clean
Portugal. The Man - Evil Friends
Toro Y Moi - Still Sound
Yelle - Ce Jeu
Young the Giant - My Body
Serebro - Mi Mi Mi
@hsandt

hsandt commented Oct 11, 2026 •

Copy link
Copy Markdown

Oh, I was looking for something like this to convert AudioMuse-AI playlist output to locally usable playlist (I have troubles with my media server Navidrome, it generates empty playlists!)

I'm working on a more elaborate version to fulfil my need, you can check my fork here: https://gist.github.com/hsandt/c1acb7c3d54518cd5bed4d8e9cc285f0

I explained what I changed and my current difficulties in the comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment