Changeset 451

Show
Ignore:
Timestamp:
01/10/08 11:10:56 (11 months ago)
Author:
gbooker
Message:

Two episode in a file support
Refs #14

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/SapphireBrowser.m

    r450 r451  
    353353                                /*Display episode number if availble*/ 
    354354                                int eps= [meta episodeNumber] ; 
     355                                int ep2= [meta secondEpisodeNumber] ; 
    355356                                displayName=[meta episodeTitle] ; 
    356357                                if(eps>0) 
    357358                                { 
    358                                         [SapphireFrontRowCompat setRightJustifiedText:[NSString stringWithFormat:@" %02d",eps] forMenu:result]; 
     359                                        if(ep2>0) 
     360                                                [SapphireFrontRowCompat setRightJustifiedText:[NSString stringWithFormat:@" %02d-%02d",eps, ep2] forMenu:result]; 
     361                                        else 
     362                                                [SapphireFrontRowCompat setRightJustifiedText:[NSString stringWithFormat:@" %02d",eps] forMenu:result]; 
    359363                                        rightTextSet = YES; 
    360364                                } 
  • trunk/SapphireMediaPreview.m

    r436 r451  
    212212                /*Remove the individuals so we don't display them*/ 
    213213                [allMeta removeObjectForKey:META_EPISODE_NUMBER_KEY]; 
     214                [allMeta removeObjectForKey:META_EPISODE_2_NUMBER_KEY]; 
    214215                [allMeta removeObjectForKey:META_SEASON_NUMBER_KEY]; 
    215216        } 
  • trunk/SapphireMetaData.h

    r445 r451  
    3838#define META_ABSOLUTE_EP_NUMBER_KEY             @"Episode Number" 
    3939#define META_SHOW_IDENTIFIER_KEY                @"Show ID" 
     40#define META_EPISODE_2_NUMBER_KEY               @"Episode 2" 
     41#define META_ABSOLUTE_EP_2_NUMBER_KEY   @"Episode Number 2" 
    4042 
    4143//ATV Extra Info 
     
    872874 
    873875/*! 
     876 * @brief Returns the second epsiode number of the file for a two part file 
     877 * 
     878 * @return The second episode number of the file 
     879 */ 
     880- (int)secondEpisodeNumber; 
     881 
     882/*! 
    874883 * @brief Returns the season number of the file 
    875884 * 
  • trunk/SapphireMetaData.m

    r446 r451  
    18651865} 
    18661866 
     1867- (int)secondEpisodeNumber 
     1868{ 
     1869        [self constructCombinedData]; 
     1870        return [[combinedInfo objectForKey:META_EPISODE_2_NUMBER_KEY] intValue]; 
     1871} 
     1872 
    18671873- (int)seasonNumber 
    18681874{ 
     
    20452051        int ep = [self episodeNumber]; 
    20462052        if(season != 0 && ep != 0)  
    2047                 [ret setObject:[NSString stringWithFormat:@"%@ - %d / %d",[self showName], season, ep] forKey:META_EPISODE_AND_SEASON_KEY]; 
     2053        { 
     2054                int secondEp = [self secondEpisodeNumber]; 
     2055                if(secondEp != nil) 
     2056                        [ret setObject:[NSString stringWithFormat:@"%@ - %d / %d-%d",[self showName], season, ep, secondEp] forKey:META_EPISODE_AND_SEASON_KEY]; 
     2057                else 
     2058                        [ret setObject:[NSString stringWithFormat:@"%@ - %d / %d",[self showName], season, ep] forKey:META_EPISODE_AND_SEASON_KEY]; 
     2059        } 
    20482060        return ret; 
    20492061} 
  • trunk/SapphireTVShowImporter.m

    r442 r451  
    105105         
    106106        /*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); 
    109109        regcomp(&seasonEpisodeTriple, "[\\. -][0-9]{1,3}[S0-9]{2}[\\. -]", REG_EXTENDED | REG_ICASE);    
    110110        return self; 
     
    449449} 
    450450 
     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 
    451480- (BOOL) importMetaData:(id <SapphireFileMetaDataProtocol>)metaData 
    452481{ 
     
    469498        /*Check regexes to see if this is a tv show*/ 
    470499        int index = NSNotFound; 
     500        int secondEp = -1; 
    471501        regmatch_t matches[3]; 
    472502        NSData *fileNameData = [fileName dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; 
     
    477507                index = matches[0].rm_so; 
    478508                scanString = [fileName substringFromIndex:index]; 
     509                secondEp = matches[1].rm_so; 
    479510        } 
    480511        else if(!regexec(&seasonByEpisode, theFileName, 3, matches, 0)) 
     
    482513                index = matches[0].rm_so; 
    483514                scanString = [fileName substringFromIndex:index]; 
     515                secondEp = matches[1].rm_so; 
    484516        } 
    485517        else if(!regexec(&seasonEpisodeTriple, theFileName, 3, matches, 0)) 
     
    541573                return NO; 
    542574         
     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         
    543583        /*Get the episode's info*/ 
    544         NSMutableDictionary *info = nil
     584        NSMutableDictionary *info = nil, *info2 = nil
    545585        if(ep != 0) 
     586        { 
    546587                /*Match on s/e*/ 
    547588                info = [self getInfo:show forSeason:season episode:ep]; 
     589                if(otherEp != 0) 
     590                        info2 = [self getInfo:show forSeason:season episode:otherEp]; 
     591        } 
    548592        else 
    549593        { 
     
    564608                                                                        [NSString stringWithFormat:@"Season %d",[[info objectForKey:META_SEASON_NUMBER_KEY] intValue]]]; 
    565609                                                 
    566         [[NSFileManager defaultManager]constructPath:previewArtPath]; 
     610        [[NSFileManager defaultManager] constructPath:previewArtPath]; 
    567611        /*Check for screen cap locally and on server*/ 
    568612        NSString *showInfoUrl = [info objectForKey:LINK_KEY]; 
     
    585629        } 
    586630         
     631        if(info2 != nil) 
     632                [self combine:info with:info2]; 
    587633        /*Import the info*/ 
    588634        [info removeObjectForKey:LINK_KEY];