I wrote a small script that converts an m3u playlist to a k3b project.
Just save the following code snippet in a file called m3utok3b.sh, make it executable (chmod +x m3utok3b.sh) and run it (./m3utok3b.sh yourplaylist.m3u). Use it at your own risk!
echo application/x-k3b > mimetype
awk 'BEGIN{
print "<?xml version="1.0" encoding="UTF-8"?>"
print "<!DOCTYPE k3b_data_project>"
print "<k3b_data_project>"
print "<general></general>"
print "<options></options>"
print "<header></header>"
print "<files>"
}
{
if(index($0, "#") == 0) {
gsub(/&/, "&")
print "<file><url>" $0 "</url></file>"
}
}
END {
print "</files>"
print "</k3b_data_project>"
}' "$1" > maindata.xml
zip "$1.k3b" mimetype maindata.xml
rm maindata.xml
rm mimetype

0 Responses to “Script to convert a music playlist (.m3u) to a K3b project”