Changeset 491

Show
Ignore:
Timestamp:
02/14/2008 08:51:37 PM (4 years ago)
Author:
gbooker
Message:

Patch to select the directory instead of the filename for movie searches. Thanks to Stephan in ticket #120
Fixes #120

Location:
trunk/SapphireFrappliance
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/SapphireFrappliance/SapphireMovieImporter.m

    r488 r491  
    2727#import <SapphireCompatClasses/SapphireFrontRowCompat.h> 
    2828#import "SapphireShowChooser.h" 
     29#import "SapphireSettings.h" 
    2930 
    3031#define VERSION_KEY                                     @"Version" 
     
    664665        if(![self isMovieCandidate:metaData]) 
    665666                return IMPORT_STATE_NOT_UPDATED; 
    666         /*Get fineName*/ 
    667667        NSString *path = [metaData path]; 
    668668        NSString *fileName = [path lastPathComponent]; 
     669        /*choose between file or directory name for lookup */ 
     670        NSString *lookupName; 
     671        if([[SapphireSettings sharedSettings] dirLookup]) 
     672                lookupName = [[path stringByDeletingLastPathComponent] lastPathComponent]; 
     673        else 
     674                lookupName = fileName; 
    669675        if([metaData fileClass]==FILE_CLASS_TV_SHOW) /* File is a TV Show - skip it */ 
    670676                return IMPORT_STATE_NOT_UPDATED; 
     
    673679        NSString *movieDataLink = nil ; 
    674680        /*Check to see if we know this movie*/ 
    675         NSMutableDictionary *dict=[movieTranslations objectForKey:[[fileName lowercaseString] stringByDeletingPathExtension]]; 
     681        NSMutableDictionary *dict=[movieTranslations objectForKey:[[lookupName lowercaseString] stringByDeletingPathExtension]]; 
    676682        if(dict == nil) 
    677683        { 
     
    680686                        return IMPORT_STATE_NOT_UPDATED; 
    681687                /*Ask the user what movie this is*/ 
    682                 NSArray *movies = [self searchResultsForMovie:fileName]; 
     688                NSArray *movies = [self searchResultsForMovie:lookupName]; 
    683689                /* No need to prompt the user for an empty set */ 
    684690                if(movies==nil) 
     
    692698                SapphireMovieChooser *chooser = [[SapphireMovieChooser alloc] initWithScene:[dataMenu scene]]; 
    693699                [chooser setMovies:movies]; 
    694                 [chooser setFileName:fileName];          
     700                [chooser setFileName:lookupName];                
    695701                [chooser setListTitle:BRLocalizedString(@"Select Movie Title", @"Prompt the user for title of movie")]; 
    696702                /*And display prompt*/ 
     
    751757                                [self downloadPosterCandidates:posters]; 
    752758                                [posterChooser setPosters:posters] ; 
    753                                 [posterChooser setFileName:fileName]; 
     759                                [posterChooser setFileName:lookupName]; 
    754760                                [posterChooser setListTitle:BRLocalizedString(@"Select Movie Poster", @"Prompt the user for poster selection")]; 
    755761                                [[dataMenu stack] pushController:posterChooser]; 
  • trunk/SapphireFrappliance/SapphireSettings.h

    r470 r491  
    143143 
    144144/*! 
     145 * @brief Returns whether to use directory based lookup 
     146 * 
     147 * @return YES if set, NO otherwise 
     148 */ 
     149- (BOOL)dirLookup; 
     150 
     151/*! 
    145152 * @brief Returns the index of the last predicate used 
    146153 * 
  • trunk/SapphireFrappliance/SapphireSettings.m

    r482 r491  
    5151#define ENABLE_FAST_SWITCHING_KEY       @"EnableFastSwitching" 
    5252#define USE_AC3_PASSTHROUGH                     @"EnableAC3Passthrough" 
     53#define ENABLE_DIR_LOOKUP                       @"EnableDirLookup" 
    5354#define DISABLE_ANON_KEY                        @"DisableAnonymousReporting" 
    5455#define LAST_PREDICATE                          @"LastPredicate" 
     
    9091                                                                                                BRLocalizedString(@"  Fast Directory Switching", @"Don't rescan directories upon entry and used cached data"), 
    9192                                                                                                BRLocalizedString(@"  Enable AC3 Passthrough", @"Enable AC3 Passthrough menu item"), 
     93                                                                                                BRLocalizedString(@"  Use Directory Lookup", @"Use directory names instead of filename for movie lookup"), 
    9294                                                                                                BRLocalizedString(@"  Disable Anonymous Reporting", @"Disable the anonymous reporting for aid in future features"), nil]; 
    9395         
     
    109111                                                                                                BRLocalizedString(@"Tells Sapphire that when using a filter, use the cached data to setup directories rather than scanning the directories themselves for new files.", @"Fast Directory Switching description"), 
    110112                                                                                                BRLocalizedString(@"Tells Sapphire that you have an AC3 decoder and to enable passthrough of the full audio information to the decoder. This is how you get 5.1 output.", @"Enable AC3 Passthrough description"), 
     113                                                                                                BRLocalizedString(@"Tells Sapphire that you want to use directory instead of filenames for movie lookup", @"Enable Directory lookup description"), 
    111114                                                                                                BRLocalizedString(@"Tells Sapphire to not report any anonymous information on how you use Sapphire. Anonymous reporting enables us to improve the plugin for future use.", @"Disable the anonymous reporting description"), nil]; 
    112115                 
     
    127130                                                                                                        ENABLE_FAST_SWITCHING_KEY, 
    128131                                                                                                        USE_AC3_PASSTHROUGH, 
     132                                                                                                        ENABLE_DIR_LOOKUP, 
    129133                                                                                                        DISABLE_ANON_KEY, nil]; 
    130134        SapphireTheme *theme = [SapphireTheme sharedTheme]; 
     
    145149                                                                                                [theme gem:FAST_GEM_KEY], 
    146150                                                                                                [theme gem:AC3_GEM_KEY], 
     151                                                                                                [theme gem:IMDB_GEM_KEY], 
    147152                                                                                                [theme gem:REPORT_GEM_KEY], nil];                
    148153         
     
    161166                [NSNumber numberWithBool:YES], ENABLE_FAST_SWITCHING_KEY, 
    162167                [NSNumber numberWithBool:NO], USE_AC3_PASSTHROUGH, 
     168                [NSNumber numberWithBool:NO], ENABLE_DIR_LOOKUP, 
    163169                [NSNumber numberWithBool:NO], DISABLE_ANON_KEY, 
    164170                [NSNumber numberWithInt:NSNotFound], LAST_PREDICATE, 
     
    282288        return [self boolForKey:ENABLE_FAST_SWITCHING_KEY]; 
    283289 
     290} 
     291 
     292- (BOOL)dirLookup 
     293{ 
     294        return [self boolForKey:ENABLE_DIR_LOOKUP]; 
     295         
    284296} 
    285297