Skip to content

Commit

Permalink
modificacions al script i readme
Browse files Browse the repository at this point in the history
  • Loading branch information
apuratepp committed Jan 23, 2012
1 parent ea52c9d commit 15cae38
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,18 @@ iTunes Sync Android
iTunes Sync Android is a command line utility to sync one of your iTunes playlists to any Android cell phone mounted as a disk volume on your Mac.

## Requisites
* [MacRuby]()
* [MacRuby](http://www.macruby.org/) 0.9 or later
* Mac OS X 10.6 or later
* iTunes

## Usage

```bash
macruby itunes_sync_android.rb "/Volumnes/NO NAME/Music" "Nexus One Sync"
```

For example, if you want to copy your song files from your iTunes playlist **Nexus One Sync** to your Android phone mounted via USB on **/Volumes/NO NAME/Music**

```bash
macruby itunes_sync_android.rb "/Volumnes/NO NAME/Music" "Nexus One Sync"
```
21 changes: 17 additions & 4 deletions itunes_sync_android.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,39 @@
# http://stackoverflow.com/questions/1968794/create-itunes-playlist-with-scripting-bridge

require 'fileutils'

framework 'Foundation'
framework 'ScriptingBridge'

destination_path = ARGV[0]
SOURCE = "Library"
DEFAULT_PLAYLIST = "Nexus One Sync"

if ARGV[0].nil?
destination_path = "#{Dir.home}/Desktop/#{itunes_playlist}-#{Time.now.strftime("%Y%m%d%H%M%S")}"
FileUtils.mkdir_p destination_path
else
destination_path = ARGV[0]
end
itunes_playlist = ARGV[1] || DEFAULT_PLAYLIST

itunes = SBApplication.applicationWithBundleIdentifier("com.apple.iTunes")
# playlist = itunes.sources["Library"].userPlaylists["*Nexus One Sync"]

puts "Copying files from playlist \"#{itunes_playlist}\" to path: #{destination_path}"

itunes.sources.each do |source|
library = source
if source.name == "Library"
if source.name == SOURCE
library.userPlaylists.each do |play_list|
if play_list.name == "*Nexus One Sync"
if play_list.name == itunes_playlist
play_list.fileTracks.each do |fileTrack|
path = fileTrack.location.path.to_s
filename = fileTrack.location.lastPathComponent.to_s
FileUtils.cp(path, "#{destination_path}/#{filename}")
puts "Song file... #{filename}"
end
end
end
end
end

puts "Done!"

0 comments on commit 15cae38

Please sign in to comment.