About fixing Bluesound playlists after CIFS migration

I recently wiped TomatoUSB and installed OpenWRT Barrier Breaker on my Linksys E3000 based router. In that process I also migrated our FLAC collection from my x86 based server edison  to the OpenWRT router. Life was good….. until my wife complained that the her Bluesound playlists had stopped working.

Luckily I have root access to my Bluesound and can fix stuff like this. Heres the issue and the fix.

After the switch to OpenWRT the world look like this as seen from the Bluesound:

[code]
root@Stue /tmp/var/data$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root               903080    342168    515040  40% /
tmpfs                   127488        48    127440   0% /tmp
tmpfs                   127488        36    127452   0% /dev
/dev/mmcblk0p3         2778768     86668   2550944   3% /tmp/var/data
shm                     127488         0    127488   0% /dev/shm
//192.168.1.254/flac 153703308  74379356  79323952  48% /tmp/var/mnt/OPENWRT-flac
[/code]

But a peek inside the playlist.db on the Bluesound shows the following

[code]
‘StoredPlaylist::files’ => ‘/var/mnt/EDISON-flac/Arvo Part – Alina/01-Spiegel im Spiegel (Version fur Violine und Klavier).flac
/var/mnt/EDISON-flac/Arvo Part – Alina/02-Fur Alina (fur Klavier).flac
/var/mnt/EDISON-flac/Arvo Part – Alina/03-Spiegel im Spiegel (Version fur Violoncello und Klavier).flac
/var/mnt/EDISON-flac/Arvo Part – Alina/04-Fur Alina (fur Klavier).flac
/var/mnt/EDISON-flac/Arvo Part – Alina/05-Spiegel im Spiegel (Version fur Violine und Klavier).flac
/var/mnt/EDISON-flac/Arvo Part – Alina/03-Spiegel im Spiegel (Version fur Violoncello und Klavier).flac’
[/code]

Notice how the name of the CIFS server is part of the playlist entry. After figuring out the format of the playlist.db, it was trivially easy to write a little perl program to convert them. I did have to take care of some latin1 to utf8 as well, but that was also easy. For anyone who cares:

[code]
#!/usr/bin/perl -w
#
# convert_playlist.pl – version 1.0 gamma. Project hours: 1
#
# —————————————————————————-
# “THE WISHLIST LICENSE” (Revision 42):
# <zensonic@zensonic.dk> wrote this file.  As long as you retain this notice you
# can do whatever you want with this stuff.
#
# If you feel it saved your world a gift from http://amzn.com/w/2Y27QA7V5FUGU
# is highly appriciated
# —————————————————————————-
#
# Copyright 2014.11.01 by Thomas S. Iversen (zensonic@zensonic.dk)

use strict;
use Storable qw(nstore retrieve);

die “$0 <path_to_playlist> <regexp_match> <regexp_replace>” if(!($#ARGV+1 == 3));
my $filename = $ARGV[0];
my $regexp_match = $ARGV[1];
my $regexp_replace = $ARGV[2];
my $storable;

die “$filename does not exist\n” if(! -f $filename);
$storable = retrieve($filename);
foreach my $playlist (@$storable) {
my $name=$playlist->{‘StoredPlaylist::name’};
print “Converting playlist ‘$name’\n”;
$playlist->{‘StoredPlaylist::files’}=~s/$regexp_match/$regexp_replace/g;

# capital danish
$playlist->{‘StoredPlaylist::files’}=~s/\xc5/\xc3\x85/g;
$playlist->{‘StoredPlaylist::files’}=~s/\xc6/\xc3\x86/g;
$playlist->{‘StoredPlaylist::files’}=~s/\xd8/\xc3\x98/g;

# lower danish
$playlist->{‘StoredPlaylist::files’}=~s/\xe5/\xc3\xA5/g;
$playlist->{‘StoredPlaylist::files’}=~s/\xe6/\xc3\xA6/g;
$playlist->{‘StoredPlaylist::files’}=~s/\xf8/\xc3\xB8/g;

# lower swedish
$playlist->{‘StoredPlaylist::files’}=~s/\xe4/\xc3\xA4/g;
$playlist->{‘StoredPlaylist::files’}=~s/\xf6/\xc3\xB6/g;

# capital swedish
$playlist->{‘StoredPlaylist::files’}=~s/\xc4/\xc3\x84/g;
$playlist->{‘StoredPlaylist::files’}=~s/\xd6/\xc3\x96/g;
}

my $filename_new=$filename . “.new”;
print “Saving playlist as $filename_new\n”;
nstore($storable, $filename_new);
[/code]

Which I then ran as

[code]
root@Stue /tmp/var/data$ ./convert_playlist.pl stored_playlists.db EDISON OPENWRT
Converting playlist ‘Svensk jul’
Converting playlist ‘Hvid januar’
Converting playlist ‘Lektier’
Converting playlist ‘Moderne salmer’
Converting playlist ‘Total afslapning’
Converting playlist ‘P�ske’
Saving playlist as stored_playlists.db.new
[/code]

And then the last part

[code]
mv playlist as stored_playlists.db.new playlist as stored_playlists.db
reboot
[/code]

And restart the Bluesound app on the phone (it caches). Happy wife 🙂

Leave a Reply

You must be logged in to post a comment.