Show
Ignore:
Timestamp:
02/25/10 17:31:35 (2 years ago)
Author:
gbooker
Message:

Merged changes from the branch back to trunk

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/SapphireFrappliance/MetaData/SapphireMObjects/SapphireFileMetaData.m

    r977 r1179  
    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                        { 
     
    324324{ 
    325325        /*Check modified date*/ 
    326         NSDictionary *props = [[NSFileManager defaultManager] fileAttributesAtPath:self.path traverseLink:YES]; 
     326        NSString *path = nil; 
     327        NSFileManager *fm = [NSFileManager defaultManager]; 
     328        if([self fileContainerTypeValue] == FILE_CONTAINER_TYPE_VIDEO_TS) 
     329        { 
     330                NSString *vtsPath = [self.path stringByAppendingPathComponent:@"VIDEO_TS"]; 
     331                NSEnumerator *fileEnum = [[fm directoryContentsAtPath:vtsPath] objectEnumerator]; 
     332                NSString *file; 
     333                while((file = [fileEnum nextObject]) != nil) 
     334                { 
     335                        NSString *lowerFile = [file lowercaseString]; 
     336                        if([lowerFile hasSuffix:@".ifo"] && ![[lowerFile lastPathComponent] isEqualToString:@"video_ts.ifo"]) 
     337                        { 
     338                                path = [vtsPath stringByAppendingPathComponent:file]; 
     339                                break; 
     340                        } 
     341                } 
     342        } 
     343        else 
     344                path = self.path; 
     345        NSDictionary *props = [fm fileAttributesAtPath:path traverseLink:YES]; 
    327346        int modTime = [[props objectForKey:NSFileModificationDate] timeIntervalSince1970]; 
    328347         
     
    352371         
    353372        //Check XML 
    354         NSString *xmlFilePath=[[self.path stringByDeletingPathExtension] stringByAppendingPathExtension:@"xml"]; 
     373        NSString *xmlFilePath=[[self extensionlessPath] stringByAppendingPathExtension:@"xml"]; 
    355374        SapphireXMLData *xml = self.xmlData; 
    356375        NSDictionary *xmlProps = [fm fileAttributesAtPath:xmlFilePath traverseLink:YES]; 
     
    410429                NSMutableDictionary *fileMeta = [NSMutableDictionary dictionary]; 
    411430                NSString *path = [file path]; 
     431                NSString *modifiedPath = path; 
     432                NSFileManager *fm = [NSFileManager defaultManager]; 
    412433                 
    413                 NSDictionary *props = [[NSFileManager defaultManager] fileAttributesAtPath:path traverseLink:YES]; 
     434                if([file fileContainerTypeValue] == FILE_CONTAINER_TYPE_VIDEO_TS) 
     435                { 
     436                        NSString *vtsPath = [[file path] stringByAppendingPathComponent:@"VIDEO_TS"]; 
     437                        NSEnumerator *fileEnum = [[fm directoryContentsAtPath:vtsPath] objectEnumerator]; 
     438                        NSString *file; 
     439                        while((file = [fileEnum nextObject]) != nil) 
     440                        { 
     441                                NSString *lowerFile = [file lowercaseString]; 
     442                                if([lowerFile hasSuffix:@".ifo"] && ![[lowerFile lastPathComponent] isEqualToString:@"video_ts.ifo"]) 
     443                                { 
     444                                        modifiedPath = [vtsPath stringByAppendingPathComponent:file]; 
     445                                        break; 
     446                                } 
     447                        } 
     448                } 
     449                NSDictionary *props = [fm fileAttributesAtPath:modifiedPath traverseLink:YES]; 
    414450                int modTime = [[props objectForKey:NSFileModificationDate] timeIntervalSince1970]; 
    415451                /*Set modified, size, and version*/ 
     
    511547                { 
    512548                        SapphireVideoTsParser *dvd = [[SapphireVideoTsParser alloc] initWithPath:path]; 
    513                          
    514                         [fileMeta setObject:[dvd videoFormatsString ] forKey:META_FILE_VIDEO_DESC_KEY]; 
    515                         [fileMeta setObject:[dvd audioFormatsString ] forKey:META_FILE_AUDIO_DESC_KEY]; 
    516                         [fileMeta setObject:[dvd subtitlesString    ] forKey:META_FILE_SUBTITLES_KEY ]; 
    517                         [fileMeta setObject:[dvd mainFeatureDuration] forKey:META_FILE_DURATION_KEY  ]; 
    518                         [fileMeta setObject:[dvd totalSize          ] forKey:META_FILE_SIZE_KEY      ]; 
     549                        id description = [dvd videoFormatsString]; 
     550                        if(description) 
     551                                [fileMeta setObject:description forKey:META_FILE_VIDEO_DESC_KEY]; 
     552                        description = [dvd audioFormatsString]; 
     553                        if(description) 
     554                                [fileMeta setObject:description forKey:META_FILE_AUDIO_DESC_KEY]; 
     555                        description = [dvd mainFeatureDuration]; 
     556                        if(description) 
     557                                [fileMeta setObject:description forKey:META_FILE_DURATION_KEY]; 
     558                        description = [dvd totalSize]; 
     559                        if(description) 
     560                                [fileMeta setObject:description forKey:META_FILE_SIZE_KEY]; 
     561                        description = [dvd subtitlesString]; 
     562                        if(description) 
     563                                [fileMeta setObject:description forKey:META_FILE_SUBTITLES_KEY ]; 
    519564                         
    520565                        [dvd release]; 
     
    591636{ 
    592637        NSManagedObjectContext *moc = [self managedObjectContext]; 
    593         NSString *lowerFileName = [[self.path lastPathComponent] lowercaseString]; 
     638        NSString *lowerFileName = [[self fileName] lowercaseString]; 
    594639 
    595640        SapphireEpisode *ep = self.tvEpisode; 
     
    613658        else 
    614659                lookupName = lowerFileName; 
    615         SapphireMovieTranslation *movieTran = [SapphireMovieTranslation movieTranslationWithName:[lookupName stringByDeletingPathExtension] inContext:moc]; 
     660        SapphireMovieTranslation *movieTran = [SapphireMovieTranslation movieTranslationWithName:lookupName inContext:moc]; 
    616661        if(movieTran != nil) 
    617662        { 
     
    651696{ 
    652697        /*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]; 
     698        NSString *subPath = [self extensionlessPath]; 
    656699         
    657700        NSString *fileName = [subPath lastPathComponent]; 
     
    737780        [SapphireMetaDataSupport save:[self managedObjectContext]]; 
    738781        NSLog(@"Save done"); 
    739         NSString *extLessPath = [oldPath stringByDeletingPathExtension]; 
     782        NSString *extLessPath = [self extensionlessPath]; 
    740783        NSEnumerator *secondaryExtEnum = [secondaryFiles objectEnumerator]; 
    741784        NSString *extension; 
     785        NSString *newExtlessPath = newPath; 
     786        if(self.fileContainerTypeValue != FILE_CONTAINER_TYPE_VIDEO_TS) 
     787                newExtlessPath = [newExtlessPath stringByDeletingPathExtension]; 
    742788         
    743789        while((extension = [secondaryExtEnum nextObject]) != nil) 
     
    746792                if([fm fileExistsAtPath:secondaryPath]) 
    747793                { 
    748                         NSString *newSecondaryPath = [[newPath stringByDeletingPathExtension] stringByAppendingPathExtension:extension]; 
     794                        NSString *newSecondaryPath = [newExtlessPath stringByAppendingPathExtension:extension]; 
    749795                        if(newParent != nil) 
    750796                        { 
     
    767813        if(coverArtPath != nil) 
    768814        { 
    769                 NSString *newCoverArtPath = [[newPath stringByDeletingPathExtension] stringByAppendingPathExtension:[coverArtPath pathExtension]]; 
     815                NSString *newCoverArtPath = [newExtlessPath stringByAppendingPathExtension:[coverArtPath pathExtension]]; 
    770816                if(newParent != nil) 
    771817                { 
     
    800846                return BRLocalizedString(@"A File name should not contain any '/' characters", @"Error indicating that filenames cannot contain / characters"); 
    801847        NSString *oldPath = [self path]; 
    802         newFilename = [newFilename stringByAppendingPathExtension:[oldPath pathExtension]]; 
     848        if(self.fileContainerTypeValue != FILE_CONTAINER_TYPE_VIDEO_TS) 
     849                newFilename = [newFilename stringByAppendingPathExtension:[oldPath pathExtension]]; 
    803850        NSString *newPath = [[oldPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:newFilename]; 
    804851        if([oldPath isEqualToString:newPath]) 
     
    858905} 
    859906 
     907- (NSString *)fileName 
     908{ 
     909        NSString *ret = [self.path lastPathComponent]; 
     910        if(self.fileContainerTypeValue != FILE_CONTAINER_TYPE_VIDEO_TS) 
     911                ret = [ret stringByDeletingPathExtension]; 
     912         
     913        return ret; 
     914} 
     915 
     916- (NSString *)extensionlessPath 
     917{ 
     918        NSString *ret = self.path; 
     919        if(self.fileContainerTypeValue != FILE_CONTAINER_TYPE_VIDEO_TS) 
     920                ret = [ret stringByDeletingPathExtension]; 
     921         
     922        return ret; 
     923} 
     924 
    860925- (NSMutableDictionary *)getDisplayedMetaDataInOrder:(NSArray * *)order; 
    861926{