Changeset 451 for trunk/SapphireTVShowImporter.m
- Timestamp:
- 01/10/08 11:10:56 (4 years ago)
- Files:
-
- 1 modified
-
trunk/SapphireTVShowImporter.m (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/SapphireTVShowImporter.m
r442 r451 105 105 106 106 /*Initialize the regexes*/ 107 regcomp(&letterMarking, "[\\. -]?S[0-9]+E[S0-9]+ ", REG_EXTENDED | REG_ICASE);108 regcomp(&seasonByEpisode, "[\\. -]?[0-9]+x[S0-9]+ ", REG_EXTENDED | REG_ICASE);107 regcomp(&letterMarking, "[\\. -]?S[0-9]+E[S0-9]+(-E[0-9]+)?", REG_EXTENDED | REG_ICASE); 108 regcomp(&seasonByEpisode, "[\\. -]?[0-9]+x[S0-9]+(-[0-9]+)?", REG_EXTENDED | REG_ICASE); 109 109 regcomp(&seasonEpisodeTriple, "[\\. -][0-9]{1,3}[S0-9]{2}[\\. -]", REG_EXTENDED | REG_ICASE); 110 110 return self; … … 449 449 } 450 450 451 - (void)combine:(NSMutableDictionary *)info with:(NSMutableDictionary *)info2 452 { 453 NSMutableDictionary *tdict = [info2 mutableCopy]; 454 [tdict addEntriesFromDictionary:info]; 455 NSString *secname = [info2 objectForKey:META_TITLE_KEY]; 456 NSString *origname = [info objectForKey:META_TITLE_KEY]; 457 if(secname != nil && origname != nil) 458 [tdict setObject:[NSString stringWithFormat:@"%@ / %@", origname, secname] forKey:META_TITLE_KEY]; 459 460 if([info objectForKey:META_EPISODE_NUMBER_KEY] != nil) 461 { 462 NSNumber *secondEp = [info2 objectForKey:META_EPISODE_NUMBER_KEY]; 463 [tdict setObject:secondEp forKey:META_EPISODE_2_NUMBER_KEY]; 464 } 465 NSString *secdesc = [info2 objectForKey:META_DESCRIPTION_KEY]; 466 NSString *origdesc = [info objectForKey:META_DESCRIPTION_KEY]; 467 if(secdesc != nil && origdesc != nil) 468 [tdict setObject:[NSString stringWithFormat:@"%@ / %@", origdesc, secdesc] forKey:META_DESCRIPTION_KEY]; 469 470 if([info objectForKey:META_ABSOLUTE_EP_NUMBER_KEY] != nil) 471 { 472 NSNumber *secondEp = [info2 objectForKey:META_ABSOLUTE_EP_NUMBER_KEY]; 473 [tdict setObject:secondEp forKey:META_ABSOLUTE_EP_2_NUMBER_KEY]; 474 } 475 476 [info addEntriesFromDictionary:tdict]; 477 [tdict release]; 478 } 479 451 480 - (BOOL) importMetaData:(id <SapphireFileMetaDataProtocol>)metaData 452 481 { … … 469 498 /*Check regexes to see if this is a tv show*/ 470 499 int index = NSNotFound; 500 int secondEp = -1; 471 501 regmatch_t matches[3]; 472 502 NSData *fileNameData = [fileName dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; … … 477 507 index = matches[0].rm_so; 478 508 scanString = [fileName substringFromIndex:index]; 509 secondEp = matches[1].rm_so; 479 510 } 480 511 else if(!regexec(&seasonByEpisode, theFileName, 3, matches, 0)) … … 482 513 index = matches[0].rm_so; 483 514 scanString = [fileName substringFromIndex:index]; 515 secondEp = matches[1].rm_so; 484 516 } 485 517 else if(!regexec(&seasonEpisodeTriple, theFileName, 3, matches, 0)) … … 541 573 return NO; 542 574 575 int otherEp = 0; 576 if(secondEp != -1) 577 { 578 [scanner setScanLocation:secondEp - index]; 579 [scanner scanUpToCharactersFromSet:digits intoString:nil]; 580 [scanner scanInt:&otherEp]; 581 } 582 543 583 /*Get the episode's info*/ 544 NSMutableDictionary *info = nil ;584 NSMutableDictionary *info = nil, *info2 = nil; 545 585 if(ep != 0) 586 { 546 587 /*Match on s/e*/ 547 588 info = [self getInfo:show forSeason:season episode:ep]; 589 if(otherEp != 0) 590 info2 = [self getInfo:show forSeason:season episode:otherEp]; 591 } 548 592 else 549 593 { … … 564 608 [NSString stringWithFormat:@"Season %d",[[info objectForKey:META_SEASON_NUMBER_KEY] intValue]]]; 565 609 566 [[NSFileManager defaultManager] constructPath:previewArtPath];610 [[NSFileManager defaultManager] constructPath:previewArtPath]; 567 611 /*Check for screen cap locally and on server*/ 568 612 NSString *showInfoUrl = [info objectForKey:LINK_KEY]; … … 585 629 } 586 630 631 if(info2 != nil) 632 [self combine:info with:info2]; 587 633 /*Import the info*/ 588 634 [info removeObjectForKey:LINK_KEY];
