utility to sync an itunes playlist to a directory (like a mounted sd card/phone)
at master 56 lines 2.7 kB view raw view rendered
1A couple scripts for maintaining a directory of music files (probably located 2on a USB music player or SD card) from an iTunes playlist. 3 4Requires the `appscript` gem. 5 6###itunes-rsync.rb 7Query a given iTunes playlist, build a scratch directory symlinking all files 8of that playlist into it, then run `rsync` from the scratch directory to the 9path given. 10 11**Note:** `rsync`'s `--delete` option is used, so it will delete any files in 12the given path that are not found in the playlist. 13 14Usage: `ruby itunes-rsync.rb "ipod (auto)" /Volumes/music/iTunes/` 15 16###playlist_album_shuffle.rb 17Query a given iTunes playlist, organize all tracks into albums, shuffle the 18albums, and then print the filename of each track in each album (in its 19original track order) to STDOUT, relative to the path given. 20 21Mimics the album shuffle functionality of iTunes and older iPods and can be 22used to create a few album-shuffled `.pls` playlists of a given list of tracks 23for players that don't natively support album shuffle. 24 25**Note:** The path for the second argument is the path relative to all media as 26it would be mounted by the player. Nothing is saved to that path and the 27output is all done to STDOUT. 28 29Usage: `ruby playlist_album_shuffle.rb "ipod (auto)" /mnt/SD1/iTunes/ > /Volumes/AK100/album\ shuffle\ 1.pls` 30 31###License 32 33Copyright (c) 2009, 2012, 2013 joshua stein <jcs@jcs.org> 34 35Redistribution and use in source and binary forms, with or without 36modification, are permitted provided that the following conditions 37are met: 38 391. Redistributions of source code must retain the above copyright 40 notice, this list of conditions and the following disclaimer. 412. Redistributions in binary form must reproduce the above copyright 42 notice, this list of conditions and the following disclaimer in the 43 documentation and/or other materials provided with the distribution. 443. The name of the author may not be used to endorse or promote products 45 derived from this software without specific prior written permission. 46 47THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 48IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 49OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 50IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 51INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 52NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 53DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 54THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 55(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 56THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.