Changeset 225

Show
Ignore:
Timestamp:
09/17/07 17:04:44 (1 year ago)
Author:
pmerrill
Message:
  • Movie Importer will now filter out (skip) any file extention that isn't a member of videoExtentions.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/SapphireMovieChooser.h

    r219 r225  
    77// 
    88 
    9 #define MOVIE_CHOOSE_CANCEL -2 
    10 #define MOVIE_CHOOSE_NOT_MOVIE -1 
     9#define MOVIE_CHOOSE_CANCEL             -4 
     10#define MOVIE_CHOOSE_TV_SHOW    -3 
     11#define MOVIE_CHOOSE_OTHER              -2 
     12#define MOVIE_CHOOSE_NOT_MOVIE  -1 
    1113 
    1214@interface SapphireMovieChooser : BRCenteredMenuController { 
  • trunk/SapphireMovieChooser.m

    r219 r225  
    6969        movies = [movieList retain]; 
    7070        [[self list] reload]; 
    71         [[self list] addDividerAtIndex:1]; 
     71        [[self list] addDividerAtIndex:3]; 
    7272        [[self scene] renderScene]; 
    7373} 
     
    113113- (int)selection 
    114114{ 
    115         return selection - 1
     115        return selection - 3
    116116} 
    117117 
    118118- (long) itemCount 
    119119{ 
    120         return [movies count] + 1
     120        return [movies count] + 3
    121121} 
    122122 
     
    125125        BRAdornedMenuItemLayer *result = [BRAdornedMenuItemLayer adornedMenuItemWithScene:[self scene]]; 
    126126         
    127         if(row == 0) 
    128                 /*Put in the special "this is not a movie"*/ 
    129                 [[result textItem] setTitle:BRLocalizedString(@"<This is not a Movie>", @"Mark a file that is not a movie in the movie chooser")]; 
     127        if(row == 0)/*Put in the special "this is not a movie"*/ 
     128                [[result textItem] setTitle:BRLocalizedString(@"<This is NOT a Movie>", @"Mark a file that is not a movie in the movie chooser")]; 
     129        else if(row==1)/*Put in the special "this is something else"*/ 
     130                        [[result textItem] setTitle:BRLocalizedString(@"<This is something else>", @"Mark a file that something else in the movie chooser")]; 
     131        else if(row==2)/*Put in the special "this is a tv show"*/ 
     132                [[result textItem] setTitle:BRLocalizedString(@"<This is a TV Show>", @"Mark a file that is tv show in the movie chooser")]; 
    130133        else 
    131                 /*Put in the movie*/ 
    132                 [[result textItem] setTitle:[[movies objectAtIndex:row-1] objectForKey:@"name"]]; 
     134                /*Put in the movie results*/ 
     135                [[result textItem] setTitle:[[movies objectAtIndex:row-3] objectForKey:@"name"]]; 
    133136         
    134137        return result; 
     
    140143                return nil; 
    141144         
    142         if(row == 0) 
    143                 /*Put in the special "this is not a movie"*/ 
    144                 return BRLocalizedString(@"<This is not a Movie>", @"Mark a file that is not a movie in the movie chooser"); 
     145        if(row == 0)/*Put in the special "this is not a movie"*/ 
     146                return BRLocalizedString(@"<This is NOT a Movie>", @"Mark a file that is not a movie in the movie chooser"); 
     147        else if(row==1)/*Put in the special "this is something else"*/ 
     148                return BRLocalizedString(@"<This is something else>", @"Mark a file that is something else in the movie chooser"); 
     149        else if(row==2)/*Put in the special "this is a tv show"*/ 
     150                return BRLocalizedString(@"<This is a TV Show>", @"Mark a file that is a tv show in the movie chooser"); 
    145151        else 
    146152                /*Put in the movie*/ 
    147                 return [[movies objectAtIndex:row-1] objectForKey:@"name"]; 
     153                return [[movies objectAtIndex:row-3] objectForKey:@"name"]; 
    148154} 
    149155 
  • trunk/SapphireMovieImporter.m

    r224 r225  
    126126        NSString *movieTitle= [[document objectsForXQuery:@"//div[@id='tn15title']/h1/replace(string(), '\n', '')" error:&error] objectAtIndex:0]; 
    127127        /* Dump XML document to disk (Dev Only) */ 
    128         NSString *documentPath =[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/Sapphire/XML"]; 
    129         [[document XMLDataWithOptions:NSXMLNodePrettyPrint] writeToFile:[NSString stringWithFormat:@"/%@/%@_title_result.xml",documentPath,movieTitle] atomically:YES] ; 
     128        //NSString *documentPath =[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/Sapphire/XML"]; 
     129        //[[document XMLDataWithOptions:NSXMLNodePrettyPrint] writeToFile:[NSString stringWithFormat:@"/%@/%@_title_result.xml",documentPath,movieTitle] atomically:YES] ; 
    130130                 
    131131 
     
    175175        NSXMLDocument *document = [[NSXMLDocument alloc] initWithContentsOfURL:url options:NSXMLDocumentTidyHTML error:&error]; 
    176176        /* Dump XML document to disk (Dev Only) */ 
    177         NSString *documentPath =[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/Sapphire/XML"]; 
    178         [[document XMLDataWithOptions:NSXMLNodePrettyPrint] writeToFile:[NSString stringWithFormat:@"%@/%@_search_result.xml",documentPath,searchStr] atomically:YES] ; 
     177        //NSString *documentPath =[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/Sapphire/XML"]; 
     178        //[[document XMLDataWithOptions:NSXMLNodePrettyPrint] writeToFile:[NSString stringWithFormat:@"%@/%@_search_result.xml",documentPath,searchStr] atomically:YES] ; 
    179179         
    180180        NSXMLElement *root = [document rootElement]; 
     
    225225} 
    226226 
     227 
    227228/*! 
    228229* @brief Write our setings out 
     
    234235                nil]; 
    235236        [settings writeToFile:settingsPath atomically:YES]; 
     237} 
     238 
     239/*! 
     240* @brief verify file extention of a file 
     241 * 
     242 * @param filePAth The file's path  
     243 * @return YES if candidate, NO otherwise 
     244 */ 
     245- (BOOL)isMovieCandidate:(NSString*)fileExt 
     246{ 
     247        if([[SapphireMetaData videoExtensions] member:fileExt]) 
     248                return YES; 
     249        else return NO ; 
    236250} 
    237251 
     
    250264        /*Get path*/ 
    251265        NSString *path = [metaData path]; 
     266        if(![self isMovieCandidate:[path pathExtension]]) 
     267                return NO; 
    252268        /*Get fineName*/ 
    253269        NSString *fileName = [path lastPathComponent]; 
     270         
     271        if([metaData fileClass]==FILE_CLASS_TV_SHOW) /* File is a TV Show - skip it */ 
     272                return NO ; 
    254273         
    255274        /*Get the movie title*/ 
     
    345364- (void) wasExhumedByPoppingController: (BRLayerController *) controller 
    346365{ 
    347         /*See if it was a show chooser*/ 
     366        /*See if it was a movie chooser*/ 
    348367        if(![controller isKindOfClass:[SapphireMovieChooser class]]) 
    349368                return; 
     
    359378                /*They said it is not a movie, so put in empty data so they are not asked again*/ 
    360379                [currentData importInfo:[NSMutableDictionary dictionary] fromSource:META_IMDB_IMPORT_KEY withTime:[[NSDate date] timeIntervalSince1970]]; 
    361                 if ([currentData fileClass] == FILE_CLASS_MOVIE && [currentData fileClass] != FILE_CLASS_TV_SHOW)//check to make sure it's not already a tv show? 
     380                if ([currentData fileClass] != FILE_CLASS_TV_SHOW) 
    362381                        [currentData setFileClass:FILE_CLASS_UNKNOWN]; 
    363382        } 
     383        else if(selection==MOVIE_CHOOSE_OTHER) 
     384        { 
     385                [currentData importInfo:[NSMutableDictionary dictionary] fromSource:META_IMDB_IMPORT_KEY withTime:[[NSDate date] timeIntervalSince1970]]; 
     386                [currentData setFileClass:FILE_CLASS_OTHER] ; 
     387        } 
     388        else if(selection==MOVIE_CHOOSE_TV_SHOW) 
     389        { 
     390                [currentData importInfo:[NSMutableDictionary dictionary] fromSource:META_IMDB_IMPORT_KEY withTime:[[NSDate date] timeIntervalSince1970]]; 
     391                [currentData setFileClass:FILE_CLASS_TV_SHOW] ;  
     392        } 
    364393        else 
    365394        { 
    366                 /*They selected a show, save the translation and write it*/ 
     395                /*They selected a movie title, save the translation and write it*/ 
    367396                NSDictionary *movie = [[chooser movies] objectAtIndex:selection]; 
    368397                [movieTranslations setObject:[movie objectForKey:@"link"] forKey:[[chooser searchStr] lowercaseString]];