- Timestamp:
- 02/25/10 17:31:35 (2 years ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
. (modified) (1 prop)
-
SapphireFrappliance/MetaData/SapphireMObjects/SapphireFileMetaData.m (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property
svn:mergeinfo set
to
/branches/PlayerFramework merged eligible
-
Property
svn:mergeinfo set
to
-
trunk/SapphireFrappliance/MetaData/SapphireMObjects/SapphireFileMetaData.m
r977 r1179 231 231 self.fileClassValue = FILE_CLASS_TV_SHOW; 232 232 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); 235 235 if(oldCoverPath != nil) 236 236 { … … 251 251 self.fileClassValue = FILE_CLASS_MOVIE; 252 252 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); 255 255 if(oldCoverPath != nil) 256 256 { … … 324 324 { 325 325 /*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]; 327 346 int modTime = [[props objectForKey:NSFileModificationDate] timeIntervalSince1970]; 328 347 … … 352 371 353 372 //Check XML 354 NSString *xmlFilePath=[[self .path stringByDeletingPathExtension] stringByAppendingPathExtension:@"xml"];373 NSString *xmlFilePath=[[self extensionlessPath] stringByAppendingPathExtension:@"xml"]; 355 374 SapphireXMLData *xml = self.xmlData; 356 375 NSDictionary *xmlProps = [fm fileAttributesAtPath:xmlFilePath traverseLink:YES]; … … 410 429 NSMutableDictionary *fileMeta = [NSMutableDictionary dictionary]; 411 430 NSString *path = [file path]; 431 NSString *modifiedPath = path; 432 NSFileManager *fm = [NSFileManager defaultManager]; 412 433 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]; 414 450 int modTime = [[props objectForKey:NSFileModificationDate] timeIntervalSince1970]; 415 451 /*Set modified, size, and version*/ … … 511 547 { 512 548 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 ]; 519 564 520 565 [dvd release]; … … 591 636 { 592 637 NSManagedObjectContext *moc = [self managedObjectContext]; 593 NSString *lowerFileName = [[self .path lastPathComponent] lowercaseString];638 NSString *lowerFileName = [[self fileName] lowercaseString]; 594 639 595 640 SapphireEpisode *ep = self.tvEpisode; … … 613 658 else 614 659 lookupName = lowerFileName; 615 SapphireMovieTranslation *movieTran = [SapphireMovieTranslation movieTranslationWithName: [lookupName stringByDeletingPathExtension]inContext:moc];660 SapphireMovieTranslation *movieTran = [SapphireMovieTranslation movieTranslationWithName:lookupName inContext:moc]; 616 661 if(movieTran != nil) 617 662 { … … 651 696 { 652 697 /*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]; 656 699 657 700 NSString *fileName = [subPath lastPathComponent]; … … 737 780 [SapphireMetaDataSupport save:[self managedObjectContext]]; 738 781 NSLog(@"Save done"); 739 NSString *extLessPath = [ oldPath stringByDeletingPathExtension];782 NSString *extLessPath = [self extensionlessPath]; 740 783 NSEnumerator *secondaryExtEnum = [secondaryFiles objectEnumerator]; 741 784 NSString *extension; 785 NSString *newExtlessPath = newPath; 786 if(self.fileContainerTypeValue != FILE_CONTAINER_TYPE_VIDEO_TS) 787 newExtlessPath = [newExtlessPath stringByDeletingPathExtension]; 742 788 743 789 while((extension = [secondaryExtEnum nextObject]) != nil) … … 746 792 if([fm fileExistsAtPath:secondaryPath]) 747 793 { 748 NSString *newSecondaryPath = [ [newPath stringByDeletingPathExtension]stringByAppendingPathExtension:extension];794 NSString *newSecondaryPath = [newExtlessPath stringByAppendingPathExtension:extension]; 749 795 if(newParent != nil) 750 796 { … … 767 813 if(coverArtPath != nil) 768 814 { 769 NSString *newCoverArtPath = [ [newPath stringByDeletingPathExtension]stringByAppendingPathExtension:[coverArtPath pathExtension]];815 NSString *newCoverArtPath = [newExtlessPath stringByAppendingPathExtension:[coverArtPath pathExtension]]; 770 816 if(newParent != nil) 771 817 { … … 800 846 return BRLocalizedString(@"A File name should not contain any '/' characters", @"Error indicating that filenames cannot contain / characters"); 801 847 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]]; 803 850 NSString *newPath = [[oldPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:newFilename]; 804 851 if([oldPath isEqualToString:newPath]) … … 858 905 } 859 906 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 860 925 - (NSMutableDictionary *)getDisplayedMetaDataInOrder:(NSArray * *)order; 861 926 {
