Changeset 700

Show
Ignore:
Timestamp:
12/06/08 11:01:48 (1 month ago)
Author:
gbooker
Message:

More resilient to importing move data and added optional logging

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/CoreData/SapphireFrappliance/MetaDataImporting/SapphireMovieImporter.m

    r696 r700  
    559559        searchStr = [searchStr stringByReplacingAllOccurancesOf:@"-" withString:@" "]; 
    560560        NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.imdb.com/find?s=tt&site=aka&q=%@", [searchStr URLEncode]]]; 
     561        SapphireLog(SAPPHIRE_LOG_IMPORT, SAPPHIRE_LOG_LEVEL_DEBUG, @"Loading search URL: %@", url); 
    561562        NSError * error = nil; 
    562563        BOOL uniqueResult=NO ; 
     
    566567        NSXMLElement *root = [document rootElement];     
    567568        NSString *resultTitle=[[[root objectsForXQuery:@"//title" error:&error]objectAtIndex:0] stringValue]; 
     569        SapphireLog(SAPPHIRE_LOG_IMPORT, SAPPHIRE_LOG_LEVEL_DEBUG, @"Got title: %@ for document: %@", resultTitle, document); 
    568570         
    569571        if([resultTitle isEqualToString:@"IMDb Title Search"])/*Make sure we didn't get back a unique result */ 
     
    578580                results = [root objectsForXQuery:IMDB_UNIQUE_SEARCH_XPATH error:&error];                 
    579581        } 
    580                  
     582         
     583        SapphireLog(SAPPHIRE_LOG_IMPORT, SAPPHIRE_LOG_LEVEL_DETAIL, @"Got search results: %@", results); 
    581584        if([results count]) 
    582585        { 
     
    598601                                        NSString *subStr = [URLSubPath substringFromIndex:location]; 
    599602                                        count = [[subStr pathComponents] count]; 
    600                                 } 
     603                                        if(count > 3) 
     604                                        { 
     605                                                int i; 
     606                                                for(i=count; i>3; i--) 
     607                                                        URLSubPath = [URLSubPath stringByDeletingLastPathComponent]; 
     608                                                count = 3; 
     609                                        } 
     610                                } 
     611                                SapphireLog(SAPPHIRE_LOG_IMPORT, SAPPHIRE_LOG_LEVEL_DEBUG, @"URLSubPath is %@", URLSubPath); 
    601612                                if(count == 3) 
    602613                                { 
     
    665676        if([metaData importTypeValue] & IMPORT_TYPE_MOVIE_MASK) 
    666677                return IMPORT_STATE_NOT_UPDATED; 
     678        SapphireLog(SAPPHIRE_LOG_IMPORT, SAPPHIRE_LOG_LEVEL_DEBUG, @"Going to movie import %@", [metaData path]); 
    667679        id controller = [[dataMenu stack] peekController]; 
    668680        /* Check to see if we are waiting on the user to select a show title */ 
     
    673685        } 
    674686        /*Get path*/ 
     687        SapphireLog(SAPPHIRE_LOG_IMPORT, SAPPHIRE_LOG_LEVEL_DEBUG, @"Checking candidate"); 
    675688        if(![self isMovieCandidate:metaData]) 
    676689                return IMPORT_STATE_NOT_UPDATED; 
     
    689702        NSString *movieDataLink = nil ; 
    690703        /*Check to see if we know this movie*/ 
     704        SapphireLog(SAPPHIRE_LOG_IMPORT, SAPPHIRE_LOG_LEVEL_DETAIL, @"Searching for movie %@", [[lookupName lowercaseString] stringByDeletingPathExtension]); 
    691705        SapphireMovieTranslation *tran = [SapphireMovieTranslation movieTranslationWithName:[[lookupName lowercaseString] stringByDeletingPathExtension] inContext:moc]; 
    692706        if([tran IMDBLink] == nil) 
     
    697711                /*Ask the user what movie this is*/ 
    698712                NSArray *movies = [self searchResultsForMovie:lookupName]; 
     713                SapphireLog(SAPPHIRE_LOG_IMPORT, SAPPHIRE_LOG_LEVEL_DETAIL, @"Found results: %@", movies); 
    699714                /* No need to prompt the user for an empty set */ 
    700715                if(movies==nil)