Show
Ignore:
Timestamp:
02/23/2010 04:51:22 PM (2 years ago)
Author:
gbooker
Message:

Better handle files without extensions and preserve the lookup name better.
Fixes #283

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/PlayerFramework/SapphireFrappliance/MetaData/SapphireMObjects/SapphireFileMetaData.m

    r977 r1165  
    231231                        self.fileClassValue = FILE_CLASS_TV_SHOW; 
    232232                        NSString *epCoverPath = [[SapphireMetaDataSupport collectionArtPath] stringByAppendingPathComponent:[ep path]]; 
    233                         NSString *oldBasePath = [[epCoverPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[self.path lastPathComponent]]; 
    234                         NSString *oldCoverPath = searchCoverArtExtForPath([oldBasePath stringByDeletingPathExtension]); 
     233                        NSString *oldBasePath = [[epCoverPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[self fileName]]; 
     234                        NSString *oldCoverPath = searchCoverArtExtForPath(oldBasePath); 
    235235                        if(oldCoverPath != nil) 
    236236                        { 
     
    251251                        self.fileClassValue = FILE_CLASS_MOVIE; 
    252252                        NSString *movieCoverPath = [movie coverArtPath]; 
    253                         NSString *oldBasePath = [[[SapphireMetaDataSupport collectionArtPath] stringByAppendingPathComponent:@"@MOVIES"] stringByAppendingPathComponent:[self.path lastPathComponent]]; 
    254                         NSString *oldCoverPath = searchCoverArtExtForPath([oldBasePath stringByDeletingPathExtension]); 
     253                        NSString *oldBasePath = [[[SapphireMetaDataSupport collectionArtPath] stringByAppendingPathComponent:@"@MOVIES"] stringByAppendingPathComponent:[self fileName]]; 
     254                        NSString *oldCoverPath = searchCoverArtExtForPath(oldBasePath); 
    255255                        if(oldCoverPath != nil) 
    256256                        { 
     
    352352         
    353353        //Check XML 
    354         NSString *xmlFilePath=[[self.path stringByDeletingPathExtension] stringByAppendingPathExtension:@"xml"]; 
     354        NSString *xmlFilePath=[[self extensionlessPath] stringByAppendingPathExtension:@"xml"]; 
    355355        SapphireXMLData *xml = self.xmlData; 
    356356        NSDictionary *xmlProps = [fm fileAttributesAtPath:xmlFilePath traverseLink:YES]; 
     
    591591{ 
    592592        NSManagedObjectContext *moc = [self managedObjectContext]; 
    593         NSString *lowerFileName = [[self.path lastPathComponent] lowercaseString]; 
     593        NSString *lowerFileName = [[self fileName] lowercaseString]; 
    594594 
    595595        SapphireEpisode *ep = self.tvEpisode; 
     
    613613        else 
    614614                lookupName = lowerFileName; 
    615         SapphireMovieTranslation *movieTran = [SapphireMovieTranslation movieTranslationWithName:[lookupName stringByDeletingPathExtension] inContext:moc]; 
     615        SapphireMovieTranslation *movieTran = [SapphireMovieTranslation movieTranslationWithName:lookupName inContext:moc]; 
    616616        if(movieTran != nil) 
    617617        { 
     
    651651{ 
    652652        /*Find cover art for the current file in the "Cover Art" dir */ 
    653         NSString *subPath = [self path]; 
    654         if([self fileContainerTypeValue] != FILE_CONTAINER_TYPE_VIDEO_TS) 
    655                 subPath = [subPath stringByDeletingPathExtension]; 
     653        NSString *subPath = [self extensionlessPath]; 
    656654         
    657655        NSString *fileName = [subPath lastPathComponent]; 
     
    737735        [SapphireMetaDataSupport save:[self managedObjectContext]]; 
    738736        NSLog(@"Save done"); 
    739         NSString *extLessPath = [oldPath stringByDeletingPathExtension]; 
     737        NSString *extLessPath = [self extensionlessPath]; 
    740738        NSEnumerator *secondaryExtEnum = [secondaryFiles objectEnumerator]; 
    741739        NSString *extension; 
     740        NSString *newExtlessPath = newPath; 
     741        if(self.fileContainerTypeValue != FILE_CONTAINER_TYPE_VIDEO_TS) 
     742                newExtlessPath = [newExtlessPath stringByDeletingPathExtension]; 
    742743         
    743744        while((extension = [secondaryExtEnum nextObject]) != nil) 
     
    746747                if([fm fileExistsAtPath:secondaryPath]) 
    747748                { 
    748                         NSString *newSecondaryPath = [[newPath stringByDeletingPathExtension] stringByAppendingPathExtension:extension]; 
     749                        NSString *newSecondaryPath = [newExtlessPath stringByAppendingPathExtension:extension]; 
    749750                        if(newParent != nil) 
    750751                        { 
     
    767768        if(coverArtPath != nil) 
    768769        { 
    769                 NSString *newCoverArtPath = [[newPath stringByDeletingPathExtension] stringByAppendingPathExtension:[coverArtPath pathExtension]]; 
     770                NSString *newCoverArtPath = [newExtlessPath stringByAppendingPathExtension:[coverArtPath pathExtension]]; 
    770771                if(newParent != nil) 
    771772                { 
     
    800801                return BRLocalizedString(@"A File name should not contain any '/' characters", @"Error indicating that filenames cannot contain / characters"); 
    801802        NSString *oldPath = [self path]; 
    802         newFilename = [newFilename stringByAppendingPathExtension:[oldPath pathExtension]]; 
     803        if(self.fileContainerTypeValue != FILE_CONTAINER_TYPE_VIDEO_TS) 
     804                newFilename = [newFilename stringByAppendingPathExtension:[oldPath pathExtension]]; 
    803805        NSString *newPath = [[oldPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:newFilename]; 
    804806        if([oldPath isEqualToString:newPath]) 
     
    858860} 
    859861 
     862- (NSString *)fileName 
     863{ 
     864        NSString *ret = [self.path lastPathComponent]; 
     865        if(self.fileContainerTypeValue != FILE_CONTAINER_TYPE_VIDEO_TS) 
     866                ret = [ret stringByDeletingPathExtension]; 
     867         
     868        return ret; 
     869} 
     870 
     871- (NSString *)extensionlessPath 
     872{ 
     873        NSString *ret = self.path; 
     874        if(self.fileContainerTypeValue != FILE_CONTAINER_TYPE_VIDEO_TS) 
     875                ret = [ret stringByDeletingPathExtension]; 
     876         
     877        return ret; 
     878} 
     879 
    860880- (NSMutableDictionary *)getDisplayedMetaDataInOrder:(NSArray * *)order; 
    861881{