diff --git a/.gitignore b/.gitignore index 6a3758ec..82506be8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ build junk sparkle_private.pem -Plugins/Amazon/Access +Plugins/Amazon/Access.h diff --git a/App/src/AppController.m b/App/src/AppController.m index aa3be440..8623a4c1 100644 --- a/App/src/AppController.m +++ b/App/src/AppController.m @@ -207,6 +207,7 @@ - (void)updateSearchMenu NSMenu* menu = [[NSMenu alloc] initWithTitle: NSLocalizedString(@"Search terms", @"Search menu title")]; [menu addItemWithTitle:[menu title] action:nil keyEquivalent:@""]; + /* if([profile mainTag]) { MZTag* tag = [MZTag tagForIdentifier:[profile mainTag]]; @@ -214,6 +215,7 @@ - (void)updateSearchMenu [mainItem setState:NSOnState]; [mainItem setIndentationLevel:1]; } + */ NSInteger i = 0; for(NSString* tagId in [profile tags]) { @@ -334,8 +336,8 @@ - (IBAction)startSearch:(id)sender; NSString* term = [[searchField stringValue] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceCharacterSet]]; - NSMutableDictionary* dict = [activeProfile searchTerms]; - [dict setObject:term forKey:[activeProfile mainTag]]; + NSMutableDictionary* dict = [activeProfile searchTerms:term]; + //[dict setObject:term forKey:[activeProfile mainTag]]; [searchIndicator startAnimation:searchField]; [searchController setSortDescriptors:nil]; searches++; diff --git a/App/src/SearchProfile.h b/App/src/SearchProfile.h index 38dfa291..ea61b120 100644 --- a/App/src/SearchProfile.h +++ b/App/src/SearchProfile.h @@ -29,6 +29,6 @@ - (void)setCheckObject:(id)obj withPrefix:(NSString *)prefix; - (void)switchItem:(NSMenuItem *)sender; -- (NSMutableDictionary *)searchTerms; +- (NSMutableDictionary *)searchTerms:(NSString *)mainTerm; @end diff --git a/App/src/SearchProfile.m b/App/src/SearchProfile.m index a8074bee..8d6b5503 100644 --- a/App/src/SearchProfile.m +++ b/App/src/SearchProfile.m @@ -28,14 +28,14 @@ + (SearchProfile*)unknownTypeProfile { return [self profileWithIdentifier:@"unknown" mainTag:MZTitleTagIdent tag:[NSArray arrayWithObjects: - MZChaptersTagIdent, nil]]; + MZTitleTagIdent, MZChaptersTagIdent, nil]]; } + (SearchProfile*)tvShowProfile { return [self profileWithIdentifier:@"tvShow" mainTag:MZTitleTagIdent tag:[NSArray arrayWithObjects: - MZVideoTypeTagIdent, MZTVShowTagIdent, + MZTitleTagIdent, MZVideoTypeTagIdent, MZTVShowTagIdent, MZTVSeasonTagIdent, MZTVEpisodeTagIdent, MZChaptersTagIdent, nil]]; } @@ -43,7 +43,7 @@ + (SearchProfile*)movieProfile { return [self profileWithIdentifier:@"movie" mainTag:MZTitleTagIdent tag:[NSArray arrayWithObjects: - MZVideoTypeTagIdent, MZChaptersTagIdent, nil]]; + MZTitleTagIdent, MZVideoTypeTagIdent, MZChaptersTagIdent, nil]]; } + (id)profileWithIdentifier:(NSString *)ident mainTag:(NSString *)main tag:(NSArray *)tags; @@ -130,14 +130,18 @@ - (void)alterState:(NSMenuItem *)sender [sender setState:(state.state ? NSOnState : NSOffState)]; } -- (NSMutableDictionary *)searchTerms +- (NSMutableDictionary *)searchTerms:(NSString *)mainTerm { NSMutableDictionary* dict = [NSMutableDictionary dictionary]; for(ProfileState* state in tags) { if(state.state) { - id value = [self valueForUndefinedKey:state.tag]; + id value; + if([state.tag isEqual:mainTag]) + value = mainTerm; + else + value = [self valueForUndefinedKey:state.tag]; if(value != nil && value != [NSNull null] && value != NSNoSelectionMarker && value != NSMultipleValuesMarker && value != NSNotApplicableMarker) { diff --git a/Framework/src/MZRESTSearch.h b/Framework/src/MZRESTSearch.h index 265b9e44..a0da6bc4 100644 --- a/Framework/src/MZRESTSearch.h +++ b/Framework/src/MZRESTSearch.h @@ -21,6 +21,8 @@ BOOL isFinished; BOOL isExecuting; } ++ (Class)restWrapper; + @property(assign) BOOL isFinished; @property(assign) BOOL isExecuting; diff --git a/Framework/src/MZRESTSearch.m b/Framework/src/MZRESTSearch.m index c507f9b9..c91c499a 100644 --- a/Framework/src/MZRESTSearch.m +++ b/Framework/src/MZRESTSearch.m @@ -10,6 +10,12 @@ #import "MZSearchProvider.h" @implementation MZRESTSearch + ++ (Class)restWrapper +{ + return [MZRESTWrapper class]; +} + @synthesize isFinished; @synthesize isExecuting; @@ -23,7 +29,7 @@ - (id)initWithProvider:(id)theProvider delegate:(id)th parameters = [params retain]; provider = [theProvider retain]; delegate = [theDelegate retain]; - wrapper = [[MZRESTWrapper alloc] init]; + wrapper = [[[[self class] restWrapper] alloc] init]; wrapper.delegate = self; } return self; diff --git a/MetaZ.xcodeproj/project.pbxproj b/MetaZ.xcodeproj/project.pbxproj index f7740f6b..7ea1c7b1 100644 --- a/MetaZ.xcodeproj/project.pbxproj +++ b/MetaZ.xcodeproj/project.pbxproj @@ -73,6 +73,7 @@ 1B11A02510457B76004C93D3 /* rb_main.rb in Resources */ = {isa = PBXBuildFile; fileRef = 1B11A02410457B76004C93D3 /* rb_main.rb */; }; 1B11A02710457FB2004C93D3 /* AtomicParsleyWrapper.rb in Resources */ = {isa = PBXBuildFile; fileRef = 1B11A02610457FB2004C93D3 /* AtomicParsleyWrapper.rb */; }; 1B11A28B104DF1EC004C93D3 /* FilesTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B11A28A104DF1EC004C93D3 /* FilesTableView.m */; }; + 1B15A60E10B608D100EC0FBF /* AmazonSearch.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B15A60D10B608D100EC0FBF /* AmazonSearch.m */; }; 1B20209B10B36EC200EE548A /* VideoType.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1B20209910B36EC200EE548A /* VideoType.strings */; }; 1B5AC76F10532E5200F9CE36 /* MetaEditPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B5AC76E10532E5200F9CE36 /* MetaEditPanel.m */; }; 1B6E43C810845F8200DFE165 /* TCSearch.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B6E43C710845F8200DFE165 /* TCSearch.m */; }; @@ -384,6 +385,9 @@ 1B11A28A104DF1EC004C93D3 /* FilesTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FilesTableView.m; sourceTree = ""; }; 1B11A47C104E627F004C93D3 /* MZConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MZConstants.h; sourceTree = ""; }; 1B11A47D104E627F004C93D3 /* MZConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MZConstants.m; sourceTree = ""; }; + 1B15A60C10B608D100EC0FBF /* AmazonSearch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AmazonSearch.h; sourceTree = ""; }; + 1B15A60D10B608D100EC0FBF /* AmazonSearch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AmazonSearch.m; sourceTree = ""; }; + 1B15A62610B6316000EC0FBF /* Access.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Access.h; path = Plugins/Amazon/Access.h; sourceTree = SOURCE_ROOT; }; 1B20209A10B36EC200EE548A /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = Framework/English.lproj/VideoType.strings; sourceTree = ""; }; 1B5AC76D10532E5200F9CE36 /* MetaEditPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MetaEditPanel.h; sourceTree = ""; }; 1B5AC76E10532E5200F9CE36 /* MetaEditPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MetaEditPanel.m; sourceTree = ""; }; @@ -674,6 +678,7 @@ 1B032F5510B0BDC000B28E3A /* Classes */ = { isa = PBXGroup; children = ( + 1B15A62610B6316000EC0FBF /* Access.h */, 1B03307C10B0FA4800B28E3A /* AmazonPlugin.h */, 1B03307D10B0FA4800B28E3A /* AmazonPlugin.m */, 1B032F5610B0BDEE00B28E3A /* SignedAwsSearchRequest.h */, @@ -694,6 +699,8 @@ 1B82684F10B3EE0300DF101B /* AmazonRequest.m */, 1B8268A310B3F82400DF101B /* AmazonSearchProvider.h */, 1B8268A410B3F82400DF101B /* AmazonSearchProvider.m */, + 1B15A60C10B608D100EC0FBF /* AmazonSearch.h */, + 1B15A60D10B608D100EC0FBF /* AmazonSearch.m */, ); name = Classes; path = Plugins/Amazon/src; @@ -1303,7 +1310,7 @@ ); inputPaths = ( "$(SRCROOT)/Release/next_release", - "$(SRCROOT)/Plugins/Amazon/Access", + "$(SRCROOT)/Plugins/Amazon/Access.h", ); outputPaths = ( "$(TARGET_BUILD_DIR)/include/PlistMacros.h", @@ -1311,7 +1318,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "set -o errexit\n\nPATH=$PATH:/usr/local/bin:/usr/bin:/sw/bin:/opt/local/bin\nbuildid=`/opt/local/bin/git log -n1 --pretty=oneline --format=%h`\nrelease=`cat $SCRIPT_INPUT_FILE_0`\n\necho \"#define BUILDID $buildid\" > $SCRIPT_OUTPUT_FILE_0\necho \"#define BUILDDATE `date +%y.%m.%d.%H`\" >> $SCRIPT_OUTPUT_FILE_0\necho \"#define WHOAMI `whoami`\" >> $SCRIPT_OUTPUT_FILE_0\necho \"#define RELEASE $release\" >> $SCRIPT_OUTPUT_FILE_0 \ncat $SCRIPT_OUTPUT_FILE_1 >> $SCRIPT_OUTPUT_FILE_0 \n\n# Delete the intermediate Info.plist so that Xcode re-preprocesses the Info.plist with our updated macros.\n# Use -f because after a clean build, this file doesn't exist yet, so a plain rm would fail and stop the build.\nrm -f \"${CONFIGURATION_TEMP_DIR}/MetaZ.build/Preprocessed-Info.plist\"\n"; + shellScript = "set -o errexit\n\nPATH=$PATH:/usr/local/bin:/usr/bin:/sw/bin:/opt/local/bin\nbuildid=`/opt/local/bin/git log -n1 --pretty=oneline --format=%h`\nrelease=`cat $SCRIPT_INPUT_FILE_0`\n\necho \"#define BUILDID $buildid\" > $SCRIPT_OUTPUT_FILE_0\necho \"#define BUILDDATE `date +%y.%m.%d.%H`\" >> $SCRIPT_OUTPUT_FILE_0\necho \"#define WHOAMI `whoami`\" >> $SCRIPT_OUTPUT_FILE_0\necho \"#define RELEASE $release\" >> $SCRIPT_OUTPUT_FILE_0 \ncat $SCRIPT_INPUT_FILE_1 >> $SCRIPT_OUTPUT_FILE_0 \n\n# Delete the intermediate Info.plist so that Xcode re-preprocesses the Info.plist with our updated macros.\n# Use -f because after a clean build, this file doesn't exist yet, so a plain rm would fail and stop the build.\nrm -f \"${CONFIGURATION_TEMP_DIR}/MetaZ.build/Preprocessed-Info.plist\"\n"; }; 1B8262A710B39DE400DF101B /* Make Disk Image */ = { isa = PBXShellScriptBuildPhase; @@ -1380,6 +1387,7 @@ 1B032FDE10B0C62800B28E3A /* sha2.c in Sources */, 1B82685010B3EE0300DF101B /* AmazonRequest.m in Sources */, 1B8268A510B3F82400DF101B /* AmazonSearchProvider.m in Sources */, + 1B15A60E10B608D100EC0FBF /* AmazonSearch.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Plugins/Amazon/src/AmazonPlugin.m b/Plugins/Amazon/src/AmazonPlugin.m index 0b699741..3271da32 100644 --- a/Plugins/Amazon/src/AmazonPlugin.m +++ b/Plugins/Amazon/src/AmazonPlugin.m @@ -7,7 +7,7 @@ // #import "AmazonPlugin.h" - +#import "AmazonSearchProvider.h" @implementation AmazonPlugin @@ -26,11 +26,8 @@ - (id)init self = [super init]; if(self) { - /* - TCSearchProvider* a = [[[TCSearchProvider alloc] init] autorelease]; + AmazonSearchProvider* a = [[[AmazonSearchProvider alloc] init] autorelease]; searchProviders = [[NSArray arrayWithObject:a] retain]; - */ - searchProviders = [[NSArray array] retain]; } return self; } diff --git a/Plugins/Amazon/src/AmazonSearch.h b/Plugins/Amazon/src/AmazonSearch.h new file mode 100644 index 00000000..9a444525 --- /dev/null +++ b/Plugins/Amazon/src/AmazonSearch.h @@ -0,0 +1,21 @@ +// +// AmazonSearch.h +// MetaZ +// +// Created by Brian Olsen on 20/11/09. +// Copyright 2009 Maven-Group. All rights reserved. +// + +#import +#import +#import "AmazonPlugin.h" + +@interface AmazonSearch : MZRESTSearch +{ + NSDictionary* mapping; + +} + +- (id)initWithProvider:(id)provider delegate:(id)delegate url:(NSURL *)url parameters:(NSDictionary *)params; + +@end diff --git a/Plugins/Amazon/src/AmazonSearch.m b/Plugins/Amazon/src/AmazonSearch.m new file mode 100644 index 00000000..37bc9631 --- /dev/null +++ b/Plugins/Amazon/src/AmazonSearch.m @@ -0,0 +1,155 @@ +// +// AmazonSearch.m +// MetaZ +// +// Created by Brian Olsen on 20/11/09. +// Copyright 2009 Maven-Group. All rights reserved. +// + +#import "AmazonSearch.h" +#import "Access.h" +#import "AmazonRequest.h" + +@implementation AmazonSearch + ++ (Class)restWrapper +{ + return [AmazonRequest class]; +} + +- (id)initWithProvider:(id)theProvider delegate:(id)theDelegate url:(NSURL *)url parameters:(NSDictionary *)params; +{ + self = [super initWithProvider:theProvider delegate:theDelegate url:url usingVerb:@"GET" parameters:params]; + if(self) + { + NSArray* tags = [NSArray arrayWithObjects: + MZTitleTagIdent, + MZDirectorTagIdent, MZProducerTagIdent, + MZScreenwriterTagIdent, MZActorsTagIdent, + MZShortDescriptionTagIdent, + ASINTagIdent, + + MZLongDescriptionTagIdent, + MZAdvisoryTagIdent, MZCopyrightTagIdent, + MZCommentTagIdent, MZArtistTagIdent, + MZTVShowTagIdent, MZTVSeasonTagIdent, + MZTVEpisodeTagIdent, MZTVNetworkTagIdent, + MZSortTitleTagIdent, MZSortAlbumArtistTagIdent, + MZSortAlbumTagIdent, MZSortTVShowTagIdent, + MZGenreTagIdent, + nil]; + NSArray* keys = [NSArray arrayWithObjects: + @"ItemAttributes/Title", + @"ItemAttributes/Director", @"ItemAttributes/Creator[@Role='Producer']", + @"ItemAttributes/Creator[@Role='Writer']", @"ItemAttributes/Actor", + @"ItemAttributes/Feature", + @"ASIN", + + @"movieTags/info/longDescription", + @"movieTags/info/advisory", @"movieTags/info/copyright", + @"movieTags/info/comments", @"movieTags/info/artist/artistName", + @"movieTags/television/showName", @"movieTags/television/season", + @"movieTags/television/episode", @"movieTags/television/network", + @"movieTags/sorting/name", @"movieTags/sorting/albumArtist", + @"movieTags/sorting/album", @"movieTags/sorting/show", + @"movieTags/info/genre", + nil]; + mapping = [[NSDictionary alloc] initWithObjects:tags forKeys:keys]; + [wrapper setAccessKeyId:AMAZON_ACCESS_ID]; + [wrapper setSecretAccessKey:AMAZON_ACCESS_KEY]; + } + return self; +} + +- (void)dealloc +{ + [mapping release]; + [super dealloc]; +} + +#pragma mark - MZRESTWrapperDelegate + +- (void)wrapper:(MZRESTWrapper *)theWrapper didRetrieveData:(NSData *)data +{ + //NSLog(@"Got amazon response:\n%@", [theWrapper responseAsText]); + NSXMLDocument* doc = [theWrapper responseAsXml]; + + NSString* errorMessage = [doc stringForXPath:@"/ItemSearchResponse/Items/Request/Errors/Error/Code" error:NULL]; + if(![errorMessage isEqual:@""]) + NSLog(@"Amazon error: %@", errorMessage); + + NSString* totalResults = [doc stringForXPath:@"/ItemSearchResponse/Items/TotalResults" error:NULL]; + NSString* totalPages = [doc stringForXPath:@"/ItemSearchResponse/Items/TotalPages" error:NULL]; + + NSArray* items = [doc nodesForXPath:@"/ItemSearchResponse/Items/Item" error:NULL]; + NSMutableArray* results = [NSMutableArray array]; + NSLog(@"Got results %d", [items count]); + for(NSXMLElement* item in items) + { + NSMutableDictionary* dict = [NSMutableDictionary dictionary]; + for(NSString* xpath in [mapping allKeys]) + { + NSString* tagId = [mapping objectForKey:xpath]; + MZTag* tag = [MZTag tagForIdentifier:tagId]; + NSString* value = [item stringForXPath:xpath error:NULL]; + if([value length] > 0) + { + id obj = [tag objectFromString:value]; + if(obj) + [dict setObject:obj forKey:tagId]; + } + } + + NSString* asin = [dict objectForKey:ASINTagIdent]; + + NSArray* reviews = [item nodesForXPath:@"EditorialReviews/EditorialReview/Content" error:NULL]; + if([reviews count] > 0) + { + NSString* review = [[reviews objectAtIndex:0] stringValue]; + [dict setObject:review forKey:MZLongDescriptionTagIdent]; + } + + MZTag* ratingTag = [MZTag tagForIdentifier:MZRatingTagIdent]; + NSString* rating = [item stringForXPath:@"ItemAttributes/AudienceRating" error:NULL]; + NSNumber* ratingNr = [ratingTag objectFromString:rating]; + if([ratingNr intValue] != MZNoRating) + [dict setObject:ratingNr forKey:MZRatingTagIdent]; + /* + NSInteger ratingNr = [ratingNames indexOfObject:rating]; + if(ratingNr != NSNotFound) + { + [dict setObject:[NSNumber numberWithInt:ratingNr] forKey:MZRatingTagIdent]; + } + */ + + + NSString* coverArtLarge = [item stringForXPath:@"LargeImage/URL" error:NULL]; + if([coverArtLarge length] > 0) + { + /* + NSLog(@"ASIN %@", asin); + NSLog(@"Image large url: %@", coverArtLarge); + */ + NSURL* url = [NSURL URLWithString:coverArtLarge]; + MZRemoteData* data = [MZRemoteData dataWithURL:url]; + [dict setObject:data forKey:MZPictureTagIdent]; + if([NSThread mainThread] != [NSThread currentThread]) + [data performSelectorOnMainThread:@selector(loadData) withObject:nil waitUntilDone:NO]; + else + [data loadData]; + } + + MZSearchResult* result = [MZSearchResult resultWithOwner:provider dictionary:dict]; + [results addObject:result]; + } + + NSLog(@"Parsed results %d", [results count]); + [delegate searchProvider:provider result:results]; + + // TODO Make more requests for other pages + [delegate searchFinished]; + self.isExecuting = NO; + self.isFinished = YES; +} + +@end diff --git a/Plugins/Amazon/src/AmazonSearchProvider.h b/Plugins/Amazon/src/AmazonSearchProvider.h index 49439efa..09d57f8f 100644 --- a/Plugins/Amazon/src/AmazonSearchProvider.h +++ b/Plugins/Amazon/src/AmazonSearchProvider.h @@ -8,9 +8,11 @@ #import #import +#import "AmazonSearch.h" @interface AmazonSearchProvider : NSObject { + AmazonSearch* search; NSImage* icon; NSArray* supportedSearchTags; NSMenu* menu; diff --git a/Plugins/Amazon/src/AmazonSearchProvider.m b/Plugins/Amazon/src/AmazonSearchProvider.m index 9aea3d9e..d904a082 100644 --- a/Plugins/Amazon/src/AmazonSearchProvider.m +++ b/Plugins/Amazon/src/AmazonSearchProvider.m @@ -7,7 +7,6 @@ // #import "AmazonSearchProvider.h" -#import "PlistMacros.h" @implementation AmazonSearchProvider @@ -48,4 +47,83 @@ - (NSArray *)supportedSearchTags return supportedSearchTags; } +- (NSMenu *)menuForResult:(MZSearchResult *)result +{ + if(!menu) + { + menu = [[NSMenu alloc] initWithTitle:@"Amazon"]; + NSMenuItem* item = [menu addItemWithTitle:@"View in Browser" action:@selector(view:) keyEquivalent:@""]; + [item setTarget:self]; + } + for(NSMenuItem* item in [menu itemArray]) + [item setRepresentedObject:result]; + return menu; +} + +- (void)view:(id)sender +{ + MZSearchResult* result = [sender representedObject]; + NSString* asin = [result valueForKey:ASINTagIdent]; + + NSString* str = [[NSString stringWithFormat: + @"http://amzn.com/%@", + asin] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + NSURL* url = [NSURL URLWithString:str]; + [[NSWorkspace sharedWorkspace] openURL:url]; +} + +- (BOOL)searchWithData:(NSDictionary *)data delegate:(id)delegate; +{ + NSURL* searchURL = [NSURL URLWithString:@"http://ecs.amazonaws.com/onca/xml"]; + NSMutableDictionary* params = [NSMutableDictionary dictionary]; + [params setObject:@"ItemSearch" forKey:@"Operation"]; + [params setObject:@"DVD" forKey:@"SearchIndex"]; + [params setObject:@"Images,ItemAttributes,Request,Small,EditorialReview" forKey:@"ResponseGroup"]; + [params setObject:@"25" forKey:@"Count"]; + + BOOL reallyDoSearch = NO; + NSString* title = [data objectForKey:MZTitleTagIdent]; + if(title && [title length] > 0) + { + [params setObject:title forKey:@"Title"]; + reallyDoSearch = YES; + } + else + { + NSNumber* videoKindObj = [data objectForKey:MZVideoTypeTagIdent]; + if([videoKindObj intValue] == MZTVShowVideoType) + { + NSString* title = [data objectForKey:MZTVShowTagIdent]; + if(title) + { + NSNumber* season = [data objectForKey:MZTVSeasonTagIdent]; + if(season) + { + title = [NSString stringWithFormat:@"%@ season %d", title, [season intValue]]; + } + [params setObject:title forKey:@"Title"]; + reallyDoSearch = YES; + } + } + } + + if(search) + { + // Finish last search; + [search cancel]; + [search release]; + search = nil; + } + + if(!reallyDoSearch) + return NO; + + NSLog(@"Sent request to Amazon:"); + for(NSString* key in [params allKeys]) + NSLog(@" '%@' -> '%@'", key, [params objectForKey:key]); + search = [[AmazonSearch alloc] initWithProvider:self delegate:delegate url:searchURL parameters:params]; + [search start]; + return YES; +} + @end diff --git a/Plugins/TagChimp/src/TCSearchProvider.m b/Plugins/TagChimp/src/TCSearchProvider.m index f5b99e1f..5561a1d9 100644 --- a/Plugins/TagChimp/src/TCSearchProvider.m +++ b/Plugins/TagChimp/src/TCSearchProvider.m @@ -152,7 +152,7 @@ - (BOOL)searchWithData:(NSDictionary *)data delegate:(id '%@'", key, [params objectForKey:key]); search = [[TCSearch alloc] initWithProvider:self delegate:delegate url:searchURL parameters:params];