diff --git a/Changelog.rtf b/Changelog.rtf index a81e191..2f23b11 100644 --- a/Changelog.rtf +++ b/Changelog.rtf @@ -32,4 +32,5 @@ \cf0 06/17/2012\ \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural -\cf0 -Added "Show in Browser" functionality} \ No newline at end of file +\cf0 -Added "Show in Browser" functionality\ +-Added "Get from Spotify" functionality} \ No newline at end of file diff --git a/Spotify.icns b/Spotify.icns new file mode 100644 index 0000000..a4b081f Binary files /dev/null and b/Spotify.icns differ diff --git a/de.lproj/Localizable.strings b/de.lproj/Localizable.strings index 8d28ec9..b2e7023 100644 --- a/de.lproj/Localizable.strings +++ b/de.lproj/Localizable.strings @@ -58,6 +58,11 @@ "iTunes.messages.replaceLyrics.detail" = "Beim Eretzen geht der alte Songtext vollständig verloren. Diese Aktion kann nicht wiederrufen werden."; +/* Spotify Messages */ +"Spotify.messages.noTrackPlaying.title" = "Spotify spielt zut Zeit keine Musik."; + +"Spotify.messages.noTrackPlaying.detail" = "Starten Sie die Wiedergabe in Spotify, um diese Funktion zu verwenden."; + /* Error while saving */ "messages.error.saveLyrics.title" = "Der Songtext konnte nicht gespeichert werden."; diff --git a/en.lproj/Localizable.strings b/en.lproj/Localizable.strings index 8bc5fd0..d7b0f81 100644 --- a/en.lproj/Localizable.strings +++ b/en.lproj/Localizable.strings @@ -58,6 +58,11 @@ "iTunes.messages.replaceLyrics.detail" = "If you replace the old lyrics they can not be restored anymore."; +/* Spotify Messages */ +"Spotify.messages.noTrackPlaying.title" = "Spotify does currently not play any music."; + +"Spotify.messages.noTrackPlaying.detail" = "Play a track in Spotify to use this feature."; + /* Error while saving */ "messages.error.saveLyrics.title" = "The Lyrics could not be saved."; diff --git a/iLyrics.xcodeproj/project.pbxproj b/iLyrics.xcodeproj/project.pbxproj index 51c35b2..cbd7f78 100644 --- a/iLyrics.xcodeproj/project.pbxproj +++ b/iLyrics.xcodeproj/project.pbxproj @@ -14,7 +14,7 @@ 3B20EF3F1584EA9A006C0CDF /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B20EF3E1584EA9A006C0CDF /* AppDelegate.m */; }; 3B20EF421584EA9A006C0CDF /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3B20EF401584EA9A006C0CDF /* MainMenu.xib */; }; 3B20EF491584EAA3006C0CDF /* iLyrics.icns in Resources */ = {isa = PBXBuildFile; fileRef = 3B20EF481584EAA3006C0CDF /* iLyrics.icns */; }; - 3B20EF4D1584EAAD006C0CDF /* iTunes-icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 3B20EF4A1584EAAD006C0CDF /* iTunes-icon.icns */; }; + 3B20EF4D1584EAAD006C0CDF /* iTunes.icns in Resources */ = {isa = PBXBuildFile; fileRef = 3B20EF4A1584EAAD006C0CDF /* iTunes.icns */; }; 3B20EF4E1584EAAD006C0CDF /* Diamond.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 3B20EF4B1584EAAD006C0CDF /* Diamond.tiff */; }; 3B20EF4F1584EAAD006C0CDF /* Download-icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 3B20EF4C1584EAAD006C0CDF /* Download-icon.icns */; }; 3B20EF521584EAF8006C0CDF /* MainController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B20EF511584EAF8006C0CDF /* MainController.m */; }; @@ -22,6 +22,7 @@ 3B20EF5C1584F34E006C0CDF /* SearchResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B20EF5B1584F34E006C0CDF /* SearchResult.m */; }; 3B20EF6115853345006C0CDF /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3B20EF6315853345006C0CDF /* Localizable.strings */; }; 3B2DC55B158CD31E00C004A4 /* PreferencesWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B2DC55A158CD31E00C004A4 /* PreferencesWindow.m */; }; + 3B5E8ED2158E7AC40082A769 /* Spotify.icns in Resources */ = {isa = PBXBuildFile; fileRef = 3B5E8ED1158E7AC40082A769 /* Spotify.icns */; }; 3B73010E158CDF7200D3AF26 /* AutoLyrics.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B73010D158CDF7200D3AF26 /* AutoLyrics.m */; }; 3B81D4FE1586248F00916CE3 /* ScriptingBridge.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B81D4FD1586248F00916CE3 /* ScriptingBridge.framework */; }; 3BBD9B76158C873F00A5CD2C /* Growl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BBD9B75158C873F00A5CD2C /* Growl.framework */; }; @@ -59,7 +60,7 @@ 3B20EF3E1584EA9A006C0CDF /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 3B20EF411584EA9A006C0CDF /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; 3B20EF481584EAA3006C0CDF /* iLyrics.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = iLyrics.icns; sourceTree = ""; }; - 3B20EF4A1584EAAD006C0CDF /* iTunes-icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = "iTunes-icon.icns"; sourceTree = ""; }; + 3B20EF4A1584EAAD006C0CDF /* iTunes.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = iTunes.icns; sourceTree = ""; }; 3B20EF4B1584EAAD006C0CDF /* Diamond.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Diamond.tiff; sourceTree = ""; }; 3B20EF4C1584EAAD006C0CDF /* Download-icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = "Download-icon.icns"; sourceTree = ""; }; 3B20EF501584EAF8006C0CDF /* MainController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainController.h; sourceTree = ""; }; @@ -73,6 +74,8 @@ 3B2DC558158CCE8100C004A4 /* Changelog.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = Changelog.rtf; sourceTree = SOURCE_ROOT; }; 3B2DC559158CD31E00C004A4 /* PreferencesWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PreferencesWindow.h; sourceTree = ""; }; 3B2DC55A158CD31E00C004A4 /* PreferencesWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PreferencesWindow.m; sourceTree = ""; }; + 3B5E8ECD158E788D0082A769 /* Spotify.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Spotify.h; sourceTree = ""; }; + 3B5E8ED1158E7AC40082A769 /* Spotify.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Spotify.icns; sourceTree = ""; }; 3B73010C158CDF7200D3AF26 /* AutoLyrics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoLyrics.h; sourceTree = ""; }; 3B73010D158CDF7200D3AF26 /* AutoLyrics.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AutoLyrics.m; sourceTree = ""; }; 3B81D4FD1586248F00916CE3 /* ScriptingBridge.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScriptingBridge.framework; path = System/Library/Frameworks/ScriptingBridge.framework; sourceTree = SDKROOT; }; @@ -170,6 +173,7 @@ isa = PBXGroup; children = ( 3B81D5041586298100916CE3 /* iTunes.h */, + 3B5E8ECD158E788D0082A769 /* Spotify.h */, 3B20EF331584EA9A006C0CDF /* iLyrics-Info.plist */, 3B20EF341584EA9A006C0CDF /* InfoPlist.strings */, 3B20EF371584EA9A006C0CDF /* main.m */, @@ -194,7 +198,8 @@ children = ( 3BBD9B79158C87D000A5CD2C /* Growl Registration Ticket.growlRegDict */, 3B20EF481584EAA3006C0CDF /* iLyrics.icns */, - 3B20EF4A1584EAAD006C0CDF /* iTunes-icon.icns */, + 3B5E8ED1158E7AC40082A769 /* Spotify.icns */, + 3B20EF4A1584EAAD006C0CDF /* iTunes.icns */, 3B20EF4B1584EAAD006C0CDF /* Diamond.tiff */, 3B20EF4C1584EAAD006C0CDF /* Download-icon.icns */, 3B20EF6315853345006C0CDF /* Localizable.strings */, @@ -258,11 +263,12 @@ 3B20EF3C1584EA9A006C0CDF /* Credits.rtf in Resources */, 3B20EF421584EA9A006C0CDF /* MainMenu.xib in Resources */, 3B20EF491584EAA3006C0CDF /* iLyrics.icns in Resources */, - 3B20EF4D1584EAAD006C0CDF /* iTunes-icon.icns in Resources */, + 3B20EF4D1584EAAD006C0CDF /* iTunes.icns in Resources */, 3B20EF4E1584EAAD006C0CDF /* Diamond.tiff in Resources */, 3B20EF4F1584EAAD006C0CDF /* Download-icon.icns in Resources */, 3B20EF6115853345006C0CDF /* Localizable.strings in Resources */, 3BBD9B7A158C87D000A5CD2C /* Growl Registration Ticket.growlRegDict in Resources */, + 3B5E8ED2158E7AC40082A769 /* Spotify.icns in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/iLyrics/MainController.h b/iLyrics/MainController.h index 0fbe378..cbcdac9 100644 --- a/iLyrics/MainController.h +++ b/iLyrics/MainController.h @@ -11,6 +11,7 @@ #import #import #import "iTunes.h" +#import "Spotify.h" #import "Magistrix.h" #import "SearchResult.h" #import "Lyrics.h" @@ -33,6 +34,7 @@ @property (readonly) Lyrics *currentLyrics; - (IBAction)getCurrentiTunesSong:(id)sender; +- (IBAction)getCurrentSpotifySong:(id)sender; - (IBAction)startNewSearch:(id)sender; - (IBAction)loadNextResults:(id)sender; - (IBAction)resetLoadedResults:(id)sender; diff --git a/iLyrics/MainController.m b/iLyrics/MainController.m index 0342e68..f8cecd3 100644 --- a/iLyrics/MainController.m +++ b/iLyrics/MainController.m @@ -15,6 +15,7 @@ NSInteger selectedSavePanelButton; NSURL *saveFile; iTunesApplication *iTunes; + SpotifyApplication *spotify; Lyrics *currentLyrics; int selectedRow; } @@ -35,6 +36,7 @@ -(id)init { iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; + spotify = [SBApplication applicationWithBundleIdentifier:@"com.spotify.client"]; loadedResults = [[NSMutableArray alloc] init]; currentHoster = [[Magistrix alloc] init]; return [super init]; @@ -90,6 +92,19 @@ [searchField performClick:sender]; } +- (IBAction)getCurrentSpotifySong:(id)sender { + SpotifyTrack *track = [spotify currentTrack]; + NSString *name = [track name]; + NSString *artist = [track artist]; + if (name == nil) { + NSBeginAlertSheet(NSLocalizedString(@"Spotify.messages.noTrackPlaying.title", @""), NSLocalizedString(@"OK", @""), nil, nil, window, nil, nil, nil, nil, NSLocalizedString(@"Spotify.messages.noTrackPlaying.detail", @"")); + return; + } + NSString *searchText = [NSString stringWithFormat:@"%@ - %@", name, artist]; + [searchField setStringValue:searchText]; + [searchField performClick:sender]; +} + - (IBAction)startNewSearch:(id)sender { [self resetLoadedResults:sender]; if ([[searchField stringValue] length] > 0) { @@ -260,6 +275,9 @@ if (action == @selector(getCurrentiTunesSong:)) { return [iTunes isRunning]; } + if (action == @selector(getCurrentSpotifySong:)) { + return [spotify isRunning]; + } if (action == @selector(showPreview:)) { return [resultsOutline clickedRow] >= 0; } diff --git a/iLyrics/Spotify.h b/iLyrics/Spotify.h new file mode 100644 index 0000000..b3e8e33 --- /dev/null +++ b/iLyrics/Spotify.h @@ -0,0 +1,79 @@ +/* + * Spotify.h + */ + +#import +#import + + +@class SpotifyApplication, SpotifyTrack, SpotifyApplication; + +enum SpotifyEPlS { + SpotifyEPlSStopped = 'kPSS', + SpotifyEPlSPlaying = 'kPSP', + SpotifyEPlSPaused = 'kPSp' +}; +typedef enum SpotifyEPlS SpotifyEPlS; + + + +/* + * Spotify Suite + */ + +// The Spotify application. +@interface SpotifyApplication : SBApplication + +@property (copy, readonly) SpotifyTrack *currentTrack; // The current playing track. +@property NSInteger soundVolume; // The sound output volume (0 = minimum, 100 = maximum) +@property (readonly) SpotifyEPlS playerState; // Is Spotify stopped, paused, or playing? +@property double playerPosition; // The player’s position within the currently playing track in seconds. +@property (readonly) BOOL repeatingEnabled; // Is repeating enabled in the current playback context? +@property BOOL repeating; // Is repeating on or off? +@property (readonly) BOOL shufflingEnabled; // Is shuffling enabled in the current playback context? +@property BOOL shuffling; // Is shuffling on or off? + +- (void) nextTrack; // Skip to the next track. +- (void) previousTrack; // Skip to the previous track. +- (void) playpause; // Toggle play/pause. +- (void) pause; // Pause playback. +- (void) play; // Resume playback. +- (void) playTrack:(NSString *)x inContext:(NSString *)inContext; // Start playback of a track in the given context. + +@end + +// A Spotify track. +@interface SpotifyTrack : SBObject + +@property (copy, readonly) NSString *artist; // The artist of the track. +@property (copy, readonly) NSString *album; // The album of the track. +@property (readonly) NSInteger discNumber; // The disc number of the track. +@property (readonly) NSInteger duration; // The length of the track in seconds. +@property (readonly) NSInteger playedCount; // The number of times this track has been played. +@property (readonly) NSInteger trackNumber; // The index of the track in its album. +@property (readonly) BOOL starred; // Is the track starred? +@property (readonly) NSInteger popularity; // How popular is this track? 0-100 +- (NSString *) id; // The ID of the item. +@property (copy, readonly) NSString *name; // The name of the track. +@property (copy, readonly) NSImage *artwork; // The track's album cover. +@property (copy, readonly) NSString *albumArtist; // That album artist of the track. +@property (copy) NSString *spotifyUrl; // The URL of the track. + + +@end + + + +/* + * Standard Suite + */ + +// The application's top level scripting object. +@interface SpotifyApplication (StandardSuite) + +@property (copy, readonly) NSString *name; // The name of the application. +@property (readonly) BOOL frontmost; // Is this the frontmost (active) application? +@property (copy, readonly) NSString *version; // The version of the application. + +@end + diff --git a/iLyrics/de.lproj/MainMenu.xib b/iLyrics/de.lproj/MainMenu.xib index b46ec5b..472a68d 100644 --- a/iLyrics/de.lproj/MainMenu.xib +++ b/iLyrics/de.lproj/MainMenu.xib @@ -214,7 +214,7 @@ - + YES YES @@ -224,7 +224,7 @@ - + Im Browser öffnen @@ -918,9 +918,12 @@ Suchen - + 268 {{0, 14}, {96, 22}} + + + _NS:9 YES @@ -1032,9 +1035,9 @@ Von iTunes holen - + NSImage - iTunes-icon + iTunes @@ -1054,7 +1057,29 @@ An iTunes senden - + + + + {0, 0} + {0, 0} + YES + YES + -1 + YES + 0 + + + + D907D172-E223-4708-B48A-EE062B41F68E + + Von Spotify holen + Von Spotify holen + + + + NSImage + Spotify + {0, 0} @@ -1120,15 +1145,16 @@ - + + - + @@ -1951,7 +1977,10 @@ Auto-Lyrics - + + NSImage + iTunes-icon + {0, 0} @@ -2295,7 +2324,6 @@ 268 {{389, 133}, {66, 17}} - _NS:1505 YES @@ -2315,7 +2343,6 @@ 268 {{72, 130}, {312, 22}} - _NS:9 YES @@ -2386,7 +2413,6 @@ 268 {{18, 70}, {173, 18}} - _NS:9 YES @@ -2412,8 +2438,6 @@ 268 {{75, 20}, {374, 42}} - - _NS:9 {250, 750} YES @@ -2433,7 +2457,6 @@ 268 {{75, 94}, {374, 28}} - _NS:9 {250, 750} @@ -2454,7 +2477,6 @@ 268 {{11, 133}, {59, 17}} - _NS:1505 YES @@ -2474,7 +2496,6 @@ 268 {{17, 203}, {432, 28}} - _NS:9 {250, 750} @@ -2495,7 +2516,6 @@ 266 {{122, 155}, {222, 32}} - _NS:9 YES @@ -2517,16 +2537,15 @@ {466, 251} - _NS:9 NSView - + - - + + Im Browser öffnen 2147483647 @@ -3182,7 +3201,7 @@ showLyricsInBrowser: - + 2596 @@ -3190,10 +3209,18 @@ showLyricsInBrowser: - + 2600 + + + getCurrentSpotifySong: + + + + 2602 + delegate @@ -3214,7 +3241,7 @@ menu - + 2597 @@ -3452,8 +3479,8 @@ - - + + @@ -3971,6 +3998,7 @@ + @@ -4673,27 +4701,32 @@ 2592 - + - + 2593 - - + + 2598 - + 2599 - + + + 2601 + + + @@ -4840,6 +4873,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -4921,7 +4955,7 @@ - 2600 + 2602 @@ -4996,6 +5030,7 @@ NSObject id + id id id NSOutlineView @@ -5010,6 +5045,10 @@ downloadLyrics: id + + getCurrentSpotifySong: + id + getCurrentiTunesSong: id @@ -5217,7 +5256,9 @@ {10, 3} {32, 32} {15, 15} - {512, 512} + {512, 512} + {512, 512} + {128, 128} diff --git a/iLyrics/en.lproj/MainMenu.xib b/iLyrics/en.lproj/MainMenu.xib index 7e2f12a..eb6bcec 100644 --- a/iLyrics/en.lproj/MainMenu.xib +++ b/iLyrics/en.lproj/MainMenu.xib @@ -214,7 +214,7 @@ - + YES YES @@ -224,7 +224,7 @@ - + Show in Browser @@ -918,9 +918,10 @@ Search - + 268 {{0, 14}, {96, 22}} + _NS:9 YES @@ -1032,9 +1033,9 @@ Get from iTunes - + NSImage - iTunes-icon + iTunes @@ -1054,7 +1055,29 @@ Send to iTunes - + + + + {0, 0} + {0, 0} + YES + YES + -1 + YES + 0 + + + + F19D1A15-FED6-48F9-B670-7D7F2D798C5A + + Get from Spotify + Get from Spotify + + + + NSImage + Spotify + {0, 0} @@ -1120,15 +1143,16 @@ - + + - + @@ -1732,11 +1756,11 @@ 128 YES - + - - + + Show in Browser 2147483647 @@ -1937,7 +1961,10 @@ Auto-Lyrics - + + NSImage + iTunes-icon + {0, 0} @@ -3147,7 +3174,7 @@ showLyricsInBrowser: - + 2597 @@ -3155,10 +3182,18 @@ showLyricsInBrowser: - + 2600 + + + getCurrentSpotifySong: + + + + 2602 + delegate @@ -3179,7 +3214,7 @@ menu - + 2596 @@ -3416,9 +3451,9 @@ - + - + @@ -3936,6 +3971,7 @@ + @@ -4638,27 +4674,32 @@ 2592 - + - + 2593 - - + + 2598 - + 2599 - + + + 2601 + + + @@ -4805,6 +4846,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -4886,7 +4928,7 @@ - 2600 + 2602 0 @@ -4903,7 +4945,9 @@ {10, 3} {32, 32} {15, 15} - {512, 512} + {512, 512} + {512, 512} + {128, 128} diff --git a/iTunes.icns b/iTunes.icns new file mode 100644 index 0000000..7e92888 Binary files /dev/null and b/iTunes.icns differ