Changeset 700
- Timestamp:
- 12/06/08 11:01:48 (1 month ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/CoreData/SapphireFrappliance/MetaDataImporting/SapphireMovieImporter.m
r696 r700 559 559 searchStr = [searchStr stringByReplacingAllOccurancesOf:@"-" withString:@" "]; 560 560 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); 561 562 NSError * error = nil; 562 563 BOOL uniqueResult=NO ; … … 566 567 NSXMLElement *root = [document rootElement]; 567 568 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); 568 570 569 571 if([resultTitle isEqualToString:@"IMDb Title Search"])/*Make sure we didn't get back a unique result */ … … 578 580 results = [root objectsForXQuery:IMDB_UNIQUE_SEARCH_XPATH error:&error]; 579 581 } 580 582 583 SapphireLog(SAPPHIRE_LOG_IMPORT, SAPPHIRE_LOG_LEVEL_DETAIL, @"Got search results: %@", results); 581 584 if([results count]) 582 585 { … … 598 601 NSString *subStr = [URLSubPath substringFromIndex:location]; 599 602 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); 601 612 if(count == 3) 602 613 { … … 665 676 if([metaData importTypeValue] & IMPORT_TYPE_MOVIE_MASK) 666 677 return IMPORT_STATE_NOT_UPDATED; 678 SapphireLog(SAPPHIRE_LOG_IMPORT, SAPPHIRE_LOG_LEVEL_DEBUG, @"Going to movie import %@", [metaData path]); 667 679 id controller = [[dataMenu stack] peekController]; 668 680 /* Check to see if we are waiting on the user to select a show title */ … … 673 685 } 674 686 /*Get path*/ 687 SapphireLog(SAPPHIRE_LOG_IMPORT, SAPPHIRE_LOG_LEVEL_DEBUG, @"Checking candidate"); 675 688 if(![self isMovieCandidate:metaData]) 676 689 return IMPORT_STATE_NOT_UPDATED; … … 689 702 NSString *movieDataLink = nil ; 690 703 /*Check to see if we know this movie*/ 704 SapphireLog(SAPPHIRE_LOG_IMPORT, SAPPHIRE_LOG_LEVEL_DETAIL, @"Searching for movie %@", [[lookupName lowercaseString] stringByDeletingPathExtension]); 691 705 SapphireMovieTranslation *tran = [SapphireMovieTranslation movieTranslationWithName:[[lookupName lowercaseString] stringByDeletingPathExtension] inContext:moc]; 692 706 if([tran IMDBLink] == nil) … … 697 711 /*Ask the user what movie this is*/ 698 712 NSArray *movies = [self searchResultsForMovie:lookupName]; 713 SapphireLog(SAPPHIRE_LOG_IMPORT, SAPPHIRE_LOG_LEVEL_DETAIL, @"Found results: %@", movies); 699 714 /* No need to prompt the user for an empty set */ 700 715 if(movies==nil)
