Last active
August 29, 2015 14:01
-
-
Save lidio601/24a0638d08288d0e9d67 to your computer and use it in GitHub Desktop.
Python script + AppScript python binding to export an iTunes Music Playlist to an Android phone directory or a car USB key.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/local/bin/python2.4 | |
from appscript import * | |
import shutil | |
import os | |
itunes = app('itunes') | |
# nome della playlist da copiare | |
playlist_name = "toUSB" | |
# directory di destinazione | |
destination_path = "/Volumes/USBKEY" | |
# gather the current playlists | |
playlists = {} | |
album_folder = False | |
# cerco la playlist | |
for playlist in itunes.playlists(): | |
playlists[playlist.name()] = playlist | |
if playlist.name() == playlist_name: | |
album_folder = playlist | |
# se la trovo scorro i file audio e | |
# li copio nella directory di destinazione | |
if album_folder: | |
tracks = album_folder.tracks() | |
for track in tracks: | |
filename = track.location().path | |
if os.path.exists(filename): | |
to = "%s/%s" % (destination_path,filename.split("/")[-1]) | |
if os.path.exists(to) == False: | |
shutil.copy2(filename,to) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment