Changeset 605

Show
Ignore:
Timestamp:
07/01/08 19:19:19 (6 months ago)
Author:
gbooker
Message:

Corrected some cases where movie importing was failing

Files:

Legend:

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

    r560 r605  
    3939 /* IMDB XPATHS */ 
    4040#define IMDB_SEARCH_XPATH                               @"//td[starts-with(a/@href,'/title')]" 
    41 #define IMDB_UNIQUE_SEARCH_XPATH                @"//a[@class='tn15more inline']/@href" 
     41#define IMDB_UNIQUE_SEARCH_XPATH                @"//a[@class='tn15more']/@href" 
    4242#define IMDB_RESULT_LINK_XPATH                  @"a/@href" 
    4343#define IMDB_POSTER_LINK_XPATH                  @"//ul/li/a/@href" 
     
    181181- (NSString *)getPosterPath:(NSString *)candidateIMDBLink 
    182182{ 
     183        NSLog(@"Getting posters for %@", candidateIMDBLink); 
    183184        NSError *error = nil ; 
    184185        NSURL * url=[NSURL URLWithString:[NSString stringWithFormat:@"http://www.imdb.com%@/posters",candidateIMDBLink]] ; 
     
    188189        /*Get the results list*/ 
    189190        NSArray *results = [root objectsForXQuery:IMDB_POSTER_LINK_XPATH error:&error]; 
     191        NSLog(@"Results is %@", results); 
    190192        if([results count]) 
    191193        { 
     
    530532        searchStr = [searchStr stringByReplacingAllOccurancesOf:@"." withString:@" "]; 
    531533        searchStr = [searchStr stringByReplacingAllOccurancesOf:@"-" withString:@" "]; 
    532         searchStr = [searchStr stringByReplacingAllOccurancesOf:@"(" withString:@" "]; 
    533         searchStr = [searchStr stringByReplacingAllOccurancesOf:@")" withString:@" "]; 
    534534        NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.imdb.com/find?s=all&site=aka&q=%@", [searchStr URLEncode]]]; 
    535535        NSError * error = nil; 
     
    551551                ret = [NSMutableArray arrayWithCapacity:1]; 
    552552                results = [root objectsForXQuery:IMDB_UNIQUE_SEARCH_XPATH error:&error];                 
    553         }       
     553        } 
    554554                 
    555555        if([results count]) 
     
    562562                        if(uniqueResult)/*Check for a unique title link*/ 
    563563                        { 
    564                                 NSURL *resultURL = [NSURL URLWithString:[[[result objectsForXQuery:IMDB_UNIQUE_SEARCH_XPATH error:&error] objectAtIndex:0] stringValue]] ; 
     564                                NSURL *resultURL = [NSURL URLWithString:[result stringValue]] ; 
    565565                                if(resultURL == nil) 
    566566                                        continue; 
    567567                                NSString *URLSubPath =[resultURL path] ; 
     568                                unsigned int location = [URLSubPath rangeOfString:@"#"].location; 
     569                                if(location != NSNotFound) 
     570                                        URLSubPath = [URLSubPath substringToIndex:location]; 
    568571                                if([URLSubPath hasSuffix:@"/releaseinfo"]) 
    569572                                {