Ticket #120: directory_lookup.patch

File directory_lookup.patch, 5.2 kB (added by Stephan, 10 months ago)

patch against rev 490

  • SapphireFrappliance/SapphireMovieImporter.m

    old new  
    2626#import "SapphirePosterChooser.h" 
    2727#import <SapphireCompatClasses/SapphireFrontRowCompat.h> 
    2828#import "SapphireShowChooser.h" 
     29#import "SapphireSettings.h" 
    2930 
    3031#define VERSION_KEY                                     @"Version" 
    3132#define CURRENT_VERSION                         2 
     
    663664        /*Get path*/ 
    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; 
    671677         
     
    679685                /*There is no data menu, background import. So we can't ask user, skip*/ 
    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) 
    685691                { 
  • SapphireFrappliance/SapphireSettings.h

    old new  
    142142- (BOOL)fastSwitching; 
    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 * 
    147154 * @return The index of the last predicate used 
  • SapphireFrappliance/SapphireSettings.m

    old new  
    5050#define HIDE_UI_QUIT_KEY                        @"HideUIQuit" 
    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" 
    5556 
     
    8990                                                                                                BRLocalizedString(@"  Hide UI Quit", @"Hide the ui quitter menu item"), 
    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         
    9496        settingDescriptions=[[NSArray alloc] initWithObjects: 
     
    108110                                                                                                BRLocalizedString(@"Tells Sapphire to hide the main menu element forcing frontrow to quit.", @"Hide the ui quitter description"), 
    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                 
    113116        keys = [[NSArray alloc] initWithObjects:                @"", 
     
    126129                                                                                                        HIDE_UI_QUIT_KEY, 
    127130                                                                                                        ENABLE_FAST_SWITCHING_KEY, 
    128131                                                                                                        USE_AC3_PASSTHROUGH, 
     132                                                                                                        ENABLE_DIR_LOOKUP, 
    129133                                                                                                        DISABLE_ANON_KEY, nil]; 
    130134        SapphireTheme *theme = [SapphireTheme sharedTheme]; 
    131135        gems = [[NSArray alloc] initWithObjects:        [theme gem:IMPORT_GEM_KEY], 
     
    144148                                                                                                [theme gem:FRONTROW_GEM_KEY], 
    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         
    149154        path = [dictionaryPath retain]; 
     
    160165                [NSNumber numberWithBool:YES], HIDE_UI_QUIT_KEY, 
    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, 
    165171                nil]; 
     
    283289 
    284290} 
    285291 
     292- (BOOL)dirLookup 
     293{ 
     294        return [self boolForKey:ENABLE_DIR_LOOKUP]; 
     295         
     296} 
     297 
    286298- (int)indexOfLastPredicate 
    287299{ 
    288300        return [[self numberForKey:LAST_PREDICATE] intValue];