Ticket #145: ripped-tv-shows.diff
| File ripped-tv-shows.diff, 5.3 kB (added by anonymous, 8 months ago) |
|---|
-
SapphireMetaData.h
old new 862 862 * 863 863 * @return The file size 864 864 */ 865 - ( long long)size;865 - (unsigned long long)size; 866 866 867 867 /*! 868 868 * @brief Returns the file's duration in seconds -
SapphireMetaData.m
old new 1611 1611 [self combinedDataChanged]; 1612 1612 } 1613 1613 1614 /*! 1615 * 1616 */ 1617 static id totalFileSize(NSString *path, NSDictionary *props) 1618 { 1619 unsigned long long size = [[props objectForKey:NSFileSize] unsignedLongLongValue]; 1620 1621 /* Our file may be a directory containing VIDEO_TS */ 1622 if( [props objectForKey:NSFileType] == NSFileTypeDirectory ) 1623 { 1624 NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:path]; 1625 NSString *content; 1626 1627 while( content = [enumerator nextObject] ) 1628 { 1629 NSDictionary *subprops = [[NSFileManager defaultManager] fileAttributesAtPath:[path stringByAppendingPathComponent:content] traverseLink:NO]; 1630 size += [[subprops objectForKey:NSFileSize] unsignedLongLongValue]; 1631 } 1632 } 1633 1634 return [NSNumber numberWithUnsignedLongLong:size]; 1635 } 1636 1614 1637 BOOL updateMetaData(id <SapphireFileMetaDataProtocol> file) 1615 1638 { 1616 1639 BOOL updated =FALSE; … … 1624 1647 NSDictionary *props = [[NSFileManager defaultManager] fileAttributesAtPath:path traverseLink:YES]; 1625 1648 int modTime = [[props objectForKey:NSFileModificationDate] timeIntervalSince1970]; 1626 1649 /*Set modified, size, and version*/ 1650 id num = totalFileSize(path, props); 1627 1651 [fileMeta setObject:[NSNumber numberWithInt:modTime] forKey:MODIFIED_KEY]; 1628 [fileMeta setObject: [props objectForKey:NSFileSize]forKey:SIZE_KEY];1652 [fileMeta setObject:num forKey:SIZE_KEY]; 1629 1653 [fileMeta setObject:[NSNumber numberWithInt:META_FILE_VERSION] forKey:META_VERSION_KEY]; 1630 1654 1631 1655 if([file fileContainerType] == FILE_CONTAINER_TYPE_QT_MOVIE) … … 1813 1837 [metaData setObject:join forKey:JOINED_FILE_KEY]; 1814 1838 } 1815 1839 1816 - ( long long)size1840 - (unsigned long long)size 1817 1841 { 1818 return [[metaData objectForKey:SIZE_KEY] longLongValue];1842 return [[metaData objectForKey:SIZE_KEY] unsignedLongLongValue]; 1819 1843 } 1820 1844 1821 1845 - (float)duration -
SapphireTVShowImporter.m
old new 477 477 [tdict release]; 478 478 } 479 479 480 -(NSMutableString *) createShortDesc:(NSMutableDictionary *)info 481 { 482 /* Get the first sentence */ 483 /* NSString *desc = [[info objectForKey:META_DESCRIPTION_KEY] substringToIndex:[[info objectForKey:META_DESCRIPTION_KEY] rangeOfString:@"."].location+1]; */ 484 485 return [NSMutableString stringWithFormat:@"%@ / ", [info objectForKey:META_TITLE_KEY]]; 486 } 487 488 /* 489 * Combine the meta data from multiple episodes into the first episode given. 490 * 491 * This will change the episode name to "Episode X - Y" and the summary 492 * will contain the episode names. 493 */ 494 - (void)combine:(NSMutableDictionary *)info withMultipleEpisodes:(NSMutableArray *)episodes 495 { 496 NSEnumerator *enumerator = [episodes objectEnumerator]; 497 NSMutableString *shortDesc = [self createShortDesc:info]; 498 id episode; 499 500 while( episode = [enumerator nextObject] ) 501 { 502 [self combine:info with:episode]; 503 [shortDesc appendString:[self createShortDesc:episode]]; 504 } 505 506 // lose the last " /" on the short description. 507 NSRange truncate; 508 truncate.location = [shortDesc length] - 3; 509 truncate.length = 3; 510 [shortDesc deleteCharactersInRange:truncate]; 511 512 /* If there is more than one extra episode the title and description 513 * become unreadable - make nicer versions of these */ 514 if( [episodes count] > 1 ) 515 { 516 int fromEp = [[info objectForKey:META_EPISODE_NUMBER_KEY] intValue]; 517 int toEp = [[info objectForKey:META_EPISODE_2_NUMBER_KEY] intValue]; 518 519 [info setObject:[NSString stringWithFormat:@"Episodes %d - %d", fromEp, toEp] forKey:META_TITLE_KEY]; 520 [info setObject:shortDesc forKey:META_DESCRIPTION_KEY]; 521 } 522 } 523 480 524 - (ImportState) importMetaData:(id <SapphireFileMetaDataProtocol>)metaData 481 525 { 482 526 currentData = metaData; … … 592 636 otherEp = overriddenEpisode; 593 637 594 638 /*Get the episode's info*/ 595 NSMutableDictionary *info = nil, *info2 = nil; 639 NSMutableDictionary *info = nil; 640 NSMutableArray *otherEpisodes = nil; 596 641 if(ep != 0) 597 642 { 598 643 /*Match on s/e*/ 599 644 info = [self getInfo:show forSeason:season episode:ep]; 600 645 if(otherEp != 0) 601 info2 = [self getInfo:show forSeason:season episode:otherEp]; 646 { 647 otherEpisodes = [[NSMutableArray alloc] init]; 648 int idx = 0; 649 650 for(idx = 1; idx <= otherEp - ep; ++idx) 651 [otherEpisodes addObject:[self getInfo:show forSeason:season episode:ep+idx]]; 652 } 602 653 } 603 654 else 604 655 { … … 638 689 [[NSURLDownload alloc] initWithRequest:request delegate:myDelegate]; 639 690 [myDelegate release]; 640 691 } 641 642 if(info2 != nil) 643 [self combine:info with:info2]; 692 693 if(otherEpisodes != nil) 694 [self combine:info withMultipleEpisodes:otherEpisodes]; 695 [otherEpisodes release]; 644 696 /*Import the info*/ 645 697 [info removeObjectForKey:LINK_KEY]; 646 698 [metaData importInfo:info fromSource:META_TVRAGE_IMPORT_KEY withTime:[[NSDate date] timeIntervalSince1970]];
