Export to Unix
Posted: Fri May 21, 2010 7:20 am
Now, here's something that I've been cooking up. I make no apology that this is for Unix users only.
I store my music on a NAS (Buffalo Link Station)
I use MediaMonkey to administer my music on the NAS
I use a Linux server to host Subsonic to stream my music
Subsoinc is a excellent package BUT I find that Subsonic's playlist handling pretty dire. The reason for this is that it follows a directory structure. This is fine if you have the elementary technique of one fodlers per album but many of us have quite complex playlists which share tracks with other playlists and exist ina hierarchy of folders. Sunsonic simply has a single folder for playlists - crunch!
My solution was
The shell script (Playlists-Subsonic-Create.sh) looks something like
Here is a beta code it case anyone is curious
I store my music on a NAS (Buffalo Link Station)
I use MediaMonkey to administer my music on the NAS
I use a Linux server to host Subsonic to stream my music
Subsoinc is a excellent package BUT I find that Subsonic's playlist handling pretty dire. The reason for this is that it follows a directory structure. This is fine if you have the elementary technique of one fodlers per album but many of us have quite complex playlists which share tracks with other playlists and exist ina hierarchy of folders. Sunsonic simply has a single folder for playlists - crunch!
My solution was
- to write a script which can export a hierarchy of MediaMonkey playlists and create Unix shell script
- run the shell script on the Linux server to create a set of folders and symbolic links that represent the playlists
The shell script (Playlists-Subsonic-Create.sh) looks something like
Code: Select all
#start 21/05/2010 12:48:05
rm -rf "/k/Playlists-Subsonic"
mkdir -p "/k/Playlists-Subsonic"
cd "/k/Playlists-Subsonic"
mkdir "Playlists"
cd "Playlists"
mkdir "A"
cd "A"
mkdir "Aerosmith"
cd "Aerosmith"
ln -s "/k/Test/a/Aerosmith/074 Don't Cry.mp3"
ln -s "/k/Test/a/Aerosmith/01 Road Runner.mp3"
ln -s "/k/Test/a/Aerosmith/02 Shame, Shame, Shame.mp3"
ln -s "/k/Test/a/Aerosmith/03 Eyesight to the Blind.mp3"
ln -s "/k/Test/a/Aerosmith/217 Sweet Emotion (Live).mp3"
cd ..
mkdir "ColdPlay"
cd "ColdPlay"
ln -s "/k/Test/c/Coldplay/08 Fix You (live).mp3"
ln -s "/k/Test/c/Coldplay/00 Life In Technicolor II.mp3"
cd ..
mkdir "Fairground"
cd "Fairground"
ln -s "/k/Test/f/Fairground Attraction/01 A Smile In A Whisper.mp3"
ln -s "/k/Test/f/Fairground Attraction/03 Moon On The Rain.mp3"
ln -s "/k/Test/f/Fairground Attraction/09 The Moon Is Mine.mp3"
Code: Select all
' read the SDB treelist building a list of children playlists
sub getSDBPlaylists( tree , node , prependParents , progress , shellpath , createroot )
dim fout
fout = fout & "#start " & now & chr(10)
fout = fout & "rm -rf """ & createroot & """" & chr(10)
fout = fout & "mkdir -p """ & createroot & """" & chr(10)
fout = fout & "cd """ & createroot & """" & chr(10)
getSDBPlaylistsR tree , node , prependParents, fout
fout = fout & "#end " & now & chr(10)
fout = fout & "#"
fout = fout & "#"
fout = fout & "#"
' write to file
dim fso : Set fso = SDB.Tools.FileSystem
dim f : Set f = fso.CreateTextFile( shellpath , True)
f.WriteLine fout
f.Close
end sub
sub getSDBPlaylistsR( tree , node , prependParents , fout )
' make sure that we see the children
node.expanded = true
' do we contain child playlists
if node.HasChildren then
fout = fout & "mkdir """ & node.caption & """" & chr(10)
fout = fout & "cd """ & node.caption & """" & chr(10)
' recurse through the children
dim n : set n = tree.FirstChildNode(node)
do while not ( n is nothing )
getSDBPlaylistsR tree , n , prependParents , fout
set n = tree.nextsiblingnode(n)
loop
fout = fout & "cd .." & chr(10)
else
dim fullName : fullName = g.convert.getFullMmName( tree , node , g.ini )
export node , fullname , fout
end if
end sub
sub export( node , fullname , fout )
dim pl : set pl = SDB.PlaylistByTitle( node.caption )
dim tracks
dim p ' as cProgress
dim path
Set tracks = pl.Tracks
set p = New cProgress
p.Init node.caption , tracks.count
if tracks.count>0 then
fout = fout & "mkdir """ & node.caption & """" & chr(10)
fout = fout & "cd """ & node.caption & """" & chr(10)
dim i : for i = 0 to pl.tracks.count - 1
path = tracks.Item(i).Path
' make into a Unix path
path = replace( path , "/" , "-" )
path = replace( path , "\" , "/" )
path = replace( path , "K:" , "/k" )
' and create the link
fout = fout & "ln -s """ & path & """" & chr(10)
p.Count
Next
fout = fout & "cd .." & chr(10)
End If
end sub
sub main ( )
If SDB.MainTree.CurrentNode Is Nothing Then Exit Sub
' get a new progress bar
dim progress : set progress = new cProgress
' create globals
createGlobal
' add/merge the SDB ones
getSDBPlaylists SDB.MainTree , SDB.MainTree.CurrentNode , g.ini.useParentNames , progress , "K:\Playlists-Subsonic-Create.sh" , "/k/Playlists-Subsonic"
' close the progress bar
progress.terminate
end sub
' routine for launching the script via the scripts menu
sub ExportToUnix
main
end sub