Changeset 225
- Timestamp:
- 09/17/07 17:04:44 (1 year ago)
- Files:
-
- trunk/SapphireMovieChooser.h (modified) (1 diff)
- trunk/SapphireMovieChooser.m (modified) (4 diffs)
- trunk/SapphireMovieImporter.m (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/SapphireMovieChooser.h
r219 r225 7 7 // 8 8 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 11 13 12 14 @interface SapphireMovieChooser : BRCenteredMenuController { trunk/SapphireMovieChooser.m
r219 r225 69 69 movies = [movieList retain]; 70 70 [[self list] reload]; 71 [[self list] addDividerAtIndex: 1];71 [[self list] addDividerAtIndex:3]; 72 72 [[self scene] renderScene]; 73 73 } … … 113 113 - (int)selection 114 114 { 115 return selection - 1;115 return selection - 3; 116 116 } 117 117 118 118 - (long) itemCount 119 119 { 120 return [movies count] + 1;120 return [movies count] + 3; 121 121 } 122 122 … … 125 125 BRAdornedMenuItemLayer *result = [BRAdornedMenuItemLayer adornedMenuItemWithScene:[self scene]]; 126 126 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")]; 130 133 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"]]; 133 136 134 137 return result; … … 140 143 return nil; 141 144 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"); 145 151 else 146 152 /*Put in the movie*/ 147 return [[movies objectAtIndex:row- 1] objectForKey:@"name"];153 return [[movies objectAtIndex:row-3] objectForKey:@"name"]; 148 154 } 149 155 trunk/SapphireMovieImporter.m
r224 r225 126 126 NSString *movieTitle= [[document objectsForXQuery:@"//div[@id='tn15title']/h1/replace(string(), '\n', '')" error:&error] objectAtIndex:0]; 127 127 /* 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] ; 130 130 131 131 … … 175 175 NSXMLDocument *document = [[NSXMLDocument alloc] initWithContentsOfURL:url options:NSXMLDocumentTidyHTML error:&error]; 176 176 /* 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] ; 179 179 180 180 NSXMLElement *root = [document rootElement]; … … 225 225 } 226 226 227 227 228 /*! 228 229 * @brief Write our setings out … … 234 235 nil]; 235 236 [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 ; 236 250 } 237 251 … … 250 264 /*Get path*/ 251 265 NSString *path = [metaData path]; 266 if(![self isMovieCandidate:[path pathExtension]]) 267 return NO; 252 268 /*Get fineName*/ 253 269 NSString *fileName = [path lastPathComponent]; 270 271 if([metaData fileClass]==FILE_CLASS_TV_SHOW) /* File is a TV Show - skip it */ 272 return NO ; 254 273 255 274 /*Get the movie title*/ … … 345 364 - (void) wasExhumedByPoppingController: (BRLayerController *) controller 346 365 { 347 /*See if it was a showchooser*/366 /*See if it was a movie chooser*/ 348 367 if(![controller isKindOfClass:[SapphireMovieChooser class]]) 349 368 return; … … 359 378 /*They said it is not a movie, so put in empty data so they are not asked again*/ 360 379 [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) 362 381 [currentData setFileClass:FILE_CLASS_UNKNOWN]; 363 382 } 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 } 364 393 else 365 394 { 366 /*They selected a show, save the translation and write it*/395 /*They selected a movie title, save the translation and write it*/ 367 396 NSDictionary *movie = [[chooser movies] objectAtIndex:selection]; 368 397 [movieTranslations setObject:[movie objectForKey:@"link"] forKey:[[chooser searchStr] lowercaseString]];
