Class: PossibleDuplicateTrack
- Inherits:
-
Object
- Object
- PossibleDuplicateTrack
- Defined in:
- lib/itunes_dup_handler.rb
Instance Attribute Summary collapse
-
#database_id ⇒ Object
track is the iTunes track object that will be moved or deleted.
-
#md5 ⇒ Object
track is the iTunes track object that will be moved or deleted.
-
#unix_path ⇒ Object
track is the iTunes track object that will be moved or deleted.
Instance Method Summary collapse
- #delete! ⇒ Object
- #delete_file ⇒ Object
-
#initialize(itunesTrack, md5) ⇒ PossibleDuplicateTrack
constructor
A new instance of PossibleDuplicateTrack.
- #remove_from_itunes ⇒ Object
Constructor Details
#initialize(itunesTrack, md5) ⇒ PossibleDuplicateTrack
Returns a new instance of PossibleDuplicateTrack.
34 35 36 37 38 |
# File 'lib/itunes_dup_handler.rb', line 34 def initialize(itunesTrack, md5) @database_id = itunesTrack.databaseID.to_i @unix_path = unixify_path( itunesTrack.location.to_s ) @md5 = md5 end |
Instance Attribute Details
#database_id ⇒ Object
track is the iTunes track object that will be moved or deleted
32 33 34 |
# File 'lib/itunes_dup_handler.rb', line 32 def database_id @database_id end |
#md5 ⇒ Object
track is the iTunes track object that will be moved or deleted
32 33 34 |
# File 'lib/itunes_dup_handler.rb', line 32 def md5 @md5 end |
#unix_path ⇒ Object
track is the iTunes track object that will be moved or deleted
32 33 34 |
# File 'lib/itunes_dup_handler.rb', line 32 def unix_path @unix_path end |
Instance Method Details
#delete! ⇒ Object
62 63 64 65 66 67 |
# File 'lib/itunes_dup_handler.rb', line 62 def delete! puts "Deleting: #@unix_path" if remove_from_itunes delete_file end end |
#delete_file ⇒ Object
57 58 59 60 |
# File 'lib/itunes_dup_handler.rb', line 57 def delete_file rm @unix_path puts " Deleted from file system." end |
#remove_from_itunes ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/itunes_dup_handler.rb', line 40 def remove_from_itunes predicate = OSX::NSPredicate.predicateWithFormat("databaseID == #{@database_id}") #library_track = Itunes.sources.first.playlists[1].tracks.filteredArrayUsingPredicate(predicate).first library_track = Itunes.sources.first.playlists.first.tracks.filteredArrayUsingPredicate(predicate).first if library_track library_track.delete puts " Removed from iTunes." return true else puts " ERROR trying to remove this track from iTunes. Please handle manually." # NOTE This is probably a podcast puts " Continuing..." sleep 2 return false end end |