tag:blogger.com,1999:blog-9628557Tue, 18 Mar 2014 16:25:26 +0000musicmp3oggpythonlast.fm2007artistsautoqueuebandsblogscalendarseventsfestivalsgoogle calendarpluginsquod libetsoftwaretoolsyahoo pipesarcaudioautomationbarbipesdownloadsemailfreefungainideasjavascriptlegallightninglinuxlisplowlandsmarkovmp3blogsplayersprogrammingqueueingradioremindersrhythmboxrippingrssrsyncscriptingsimilarityspamspideringspiderssynchronisationtaggingthe netherlandsthunderbirdubiquitywgetthisblog"Look out honey, 'cause I'm using technology..."http://thisfred.blogspot.com/search/label/audionoreply@blogger.com (Eric Casteleijn)Blogger1125tag:blogger.com,1999:blog-9628557.post-7329691754046044407Wed, 20 Jun 2007 07:53:00 +00002008-01-17T04:33:07.786-08:00audiolinuxmp3musicoggrsyncsynchronisationThe Musical Gardener's Tools #3: The Kitchen SyncOne of the potential downsides of obtaining your music from a large number of mixed quality sources is that your collection will be overrun by crap if you don't aggressively cull the crap. Since I listen to music on at least 4 machines (my laptop, my work desktop, my home desktop and my iAudio M5 hard drive player) synchronisation could become nightmarish: If I delete something from my laptop and I sync with any of the other machines, I don't want the deleted crap to reappear, but I do want new stuff I downloaded to get transferred.
The way I solved this is with a few scripts using the wonderful <a href="http://en.wikipedia.org/wiki/Rsync">rsync</a> and a bit of self-discipline:
<h4>syncing between computers</h4>
I have two scripts on my work desktop called hello.sh and goodbye.sh. The former I run every day when I come into the office in the morning and this synchronizes all music from my laptop onto my desktop, including new, changed or deleted files:
<div class="code">
<code><pre>
#! /bin/sh
rsync -avz --delete laptop:~/ogg/ ~/ogg
~/ogg/mp3blogs/update
./rm_empty
rsync -avz --delete ~/ogg/ laptop:~/ogg
</pre>
</code>
</div>
where 'laptop' is the hostname of the laptop, and 'update' and 'rm_empty' are the names of the scripts mentioned in <a href="http://thisfred.blogspot.com/2007/05/new-lastfm-features-rock.html">a previous post</a>. So, the script does the following, in order:
<ol>
<li>synchronize files from laptop to desktop</li>
<li>download new files from selected mp3blogs to the desktop</li>
<li>remove any empty directories under the ogg directory on the desktop</li>
<li>synchronize files from desktop to laptop</li>
</ol>
That last step is actually redundant when I don't forget to use the accompanying 'goodbye.sh' script when I leave at night, but sometimes I do, when I have to run for a train.
The 'goodbye.sh' script is even simpler:
<div class="code">
<code>
<pre>
#! /bin/sh
./rm_empty
rsync -avz --delete ~/ogg/ laptop:~/ogg
</pre>
</code>
</div>
and does the following:
<ol>
<li>remove any empty directories under the ogg directory on the desktop</li>
<li>synchronize files from desktop to laptop</li>
</ol>
<h4>syncing between a computer and a music player</h4>
For this I wrote a little Python script, mostly because I like Python syntax much better than whatever shell script syntax (yeah, I'm new school), but it could be easily solved differently. The use case here is: all the music on any one of my computers will never fit on the puny 20GB my music player sports. That's ok, because this is only meant to hold the music I *know* I like, and to which I like to relax on the train to and from home. So the problem is we want to synchronize a subset of the music on (for instance) my desktop. I made a script that does this:
<div class="code">
<code>
<pre>
#!/usr/bin/env python
from os.path import isdir
from os import listdir, system
local = '/home/eric/ogg'
iaudio = '/media/IAUDIO/MUSIC'
localdirs = listdir(local)
iaudiodirs = listdir(iaudio)
for entry in iaudiodirs:
iaudio_path = iaudio + '/' + entry
local_path = local + '/' + entry
if isdir(iaudio_path):
if entry not in localdirs:
print "synching %s from iaudo to local" % iaudio_path
system('rsync --size-only --delete --delete-excluded \
--exclude-from= /home/eric/.rsync/exclude -avz \
--no-group %s/ %s' % (iaudio_path, local_path))
else:
print "synching %s from local to iaudo" % entry
system('rsync --size-only --delete --delete-excluded \
--exclude-from= /home/eric/.rsync/exclude -avz \
--no-group %s/ %s' % (local_path, iaudio_path))
</pre>
</code>
</div>
With small modifications, this can be made to work with any music player that behaves like an external HD under Linux (obviously paths and directory names need to be changed, I did not try to make this script generic).
What it does is run through all the artist directories on my player.
If an artist directory exists there that is not on my desktop, it copies it, under the assumption that it is a new artist that I like and picked up somewhere or other.
If the artist directory *does* exist, it does the exact reverse: it syncs from the computer *to* the player, under the assumption that I only delete or add single files on the desktop, since it's too much of a hassle to do it on the music player directly.
If either of these assumptions are not valid in your case, obviously the script wouldn't work for you without some serious modification.http://thisfred.blogspot.com/2007/05/musical-gardeners-tools-3-kitchen-sync.htmlnoreply@blogger.com (Eric Casteleijn)0