Commit b4c0372b authored by Felix Paul Kühne's avatar Felix Paul Kühne

media library: rework the ingest process wrt to queueing, improve queue pausing on hide/exit

parent 4d58a0c8
...@@ -599,17 +599,6 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles"; ...@@ -599,17 +599,6 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles";
file.hasFetchedInfo = @YES; file.hasFetchedInfo = @YES;
} }
- (void)addAudioContentWithInfo:(NSDictionary *)audioContentInfo andFile:(MLFile *)file
{
file.type = kMLFileTypeAudio;
file.title = audioContentInfo[VLCMetaInformationTitle];
/* all further meta data is set by the FileParserQueue */
file.hasFetchedInfo = @YES;
}
/** /**
* MLFile auto detection * MLFile auto detection
*/ */
...@@ -646,13 +635,6 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles"; ...@@ -646,13 +635,6 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles";
{ {
APLog(@"Fetching meta data for %@", file.title); APLog(@"Fetching meta data for %@", file.title);
[[MLFileParserQueue sharedFileParserQueue] addFile:file];
if (!_allowNetworkAccess) {
// Automatically compute the thumbnail
[self computeThumbnailForFile:file];
}
NSDictionary *tvShowEpisodeInfo = [MLTitleDecrapifier tvShowEpisodeInfoFromString:file.title]; NSDictionary *tvShowEpisodeInfo = [MLTitleDecrapifier tvShowEpisodeInfoFromString:file.title];
if (tvShowEpisodeInfo) { if (tvShowEpisodeInfo) {
file.type = kMLFileTypeTVShowEpisode; file.type = kMLFileTypeTVShowEpisode;
...@@ -660,14 +642,6 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles"; ...@@ -660,14 +642,6 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles";
return; return;
} }
if ([file isKindOfType:kMLFileTypeAudio]) {
NSDictionary *audioContentInfo = [MLTitleDecrapifier audioContentInfoFromFile:file];
if (audioContentInfo && ![file videoTrack]) {
[self addAudioContentWithInfo:audioContentInfo andFile:file];
return;
}
}
if (!_allowNetworkAccess) if (!_allowNetworkAccess)
return; return;
...@@ -714,13 +688,11 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles"; ...@@ -714,13 +688,11 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles";
APLog(@"Adding Path %@", filePath); APLog(@"Adding Path %@", filePath);
NSURL *url = [NSURL fileURLWithPath:filePath]; NSURL *url = [NSURL fileURLWithPath:filePath];
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];
NSString *title = [filePath lastPathComponent]; NSString *title = [filePath lastPathComponent];
#if !TARGET_OS_IPHONE #if !TARGET_OS_IPHONE
NSDate *openedDate = nil; // FIXME kMDItemLastUsedDate NSDate *openedDate = nil; // FIXME kMDItemLastUsedDate
NSDate *modifiedDate = nil; // FIXME [result valueForAttribute:@"kMDItemFSContentChangeDate"]; NSDate *modifiedDate = nil; // FIXME [result valueForAttribute:@"kMDItemFSContentChangeDate"];
#endif #endif
NSNumber *size = attributes[NSFileSize]; // FIXME [result valueForAttribute:@"kMDItemFSSize"];
MLFile *file = [self createObjectForEntity:@"File"]; MLFile *file = [self createObjectForEntity:@"File"];
file.url = url; file.url = url;
...@@ -748,12 +720,7 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles"; ...@@ -748,12 +720,7 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles";
else else
file.title = [title stringByDeletingPathExtension]; file.title = [title stringByDeletingPathExtension];
if ([size longLongValue] < 150000000) /* 150 MB */ [[MLFileParserQueue sharedFileParserQueue] addFile:file];
file.type = kMLFileTypeClip;
else
file.type = kMLFileTypeMovie;
[self fetchMetaDataForFile:file];
} }
- (void)addFilePaths:(NSArray *)filepaths - (void)addFilePaths:(NSArray *)filepaths
...@@ -811,8 +778,6 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles"; ...@@ -811,8 +778,6 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles";
} }
#endif #endif
- (void)updateMediaDatabase - (void)updateMediaDatabase
{ {
[self libraryDidDisappear]; [self libraryDidDisappear];
...@@ -887,7 +852,7 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles"; ...@@ -887,7 +852,7 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles";
[request setPredicate:[NSPredicate predicateWithFormat:@"isOnDisk == YES"]]; [request setPredicate:[NSPredicate predicateWithFormat:@"isOnDisk == YES"]];
results = [moc executeFetchRequest:request error:nil]; results = [moc executeFetchRequest:request error:nil];
for (MLFile *file in results) { for (MLFile *file in results) {
if (!file.computedThumbnail) if (!file.computedThumbnail && ![file isKindOfType:kMLFileTypeAudio])
[self computeThumbnailForFile:file]; [self computeThumbnailForFile:file];
} }
return; return;
...@@ -897,16 +862,19 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles"; ...@@ -897,16 +862,19 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles";
request = [self fetchRequestForEntity:@"File"]; request = [self fetchRequestForEntity:@"File"];
[request setPredicate:[NSPredicate predicateWithFormat:@"isOnDisk == YES && hasFetchedInfo == 1 && artworkURL == nil"]]; [request setPredicate:[NSPredicate predicateWithFormat:@"isOnDisk == YES && hasFetchedInfo == 1 && artworkURL == nil"]];
results = [moc executeFetchRequest:request error:nil]; results = [moc executeFetchRequest:request error:nil];
for (MLFile *file in results) for (MLFile *file in results) {
if (!file.computedThumbnail) if (!file.computedThumbnail) {
[self computeThumbnailForFile:file]; if (!file.albumTrack && ![file isKindOfType:kMLFileTypeAudio])
[self computeThumbnailForFile:file];
}
}
// Get to fetch meta data // Get to fetch meta data
request = [self fetchRequestForEntity:@"File"]; request = [self fetchRequestForEntity:@"File"];
[request setPredicate:[NSPredicate predicateWithFormat:@"isOnDisk == YES && hasFetchedInfo == 0"]]; [request setPredicate:[NSPredicate predicateWithFormat:@"isOnDisk == YES && hasFetchedInfo == 0"]];
results = [moc executeFetchRequest:request error:nil]; results = [moc executeFetchRequest:request error:nil];
for (MLFile *file in results) for (MLFile *file in results)
[self fetchMetaDataForFile:file]; [[MLFileParserQueue sharedFileParserQueue] addFile:file];
// Get to fetch show info // Get to fetch show info
request = [self fetchRequestForEntity:@"Show"]; request = [self fetchRequestForEntity:@"Show"];
...@@ -936,24 +904,28 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles"; ...@@ -936,24 +904,28 @@ static NSString *kDecrapifyTitles = @"MLDecrapifyTitles";
- (void)applicationWillExit - (void)applicationWillExit
{ {
[[MLFileParserQueue sharedFileParserQueue] stop];
[[MLCrashPreventer sharedPreventer] cancelAllFileParse]; [[MLCrashPreventer sharedPreventer] cancelAllFileParse];
} }
- (void)applicationWillStart - (void)applicationWillStart
{ {
[[MLCrashPreventer sharedPreventer] markCrasherFiles]; [[MLCrashPreventer sharedPreventer] markCrasherFiles];
[[MLFileParserQueue sharedFileParserQueue] resume];
} }
- (void)libraryDidDisappear - (void)libraryDidDisappear
{ {
// Stop expansive work // Stop expansive work
[[MLThumbnailerQueue sharedThumbnailerQueue] stop]; [[MLThumbnailerQueue sharedThumbnailerQueue] stop];
[[MLFileParserQueue sharedFileParserQueue] stop];
} }
- (void)libraryDidAppear - (void)libraryDidAppear
{ {
// Resume our work // Resume our work
[[MLThumbnailerQueue sharedThumbnailerQueue] resume]; [[MLThumbnailerQueue sharedThumbnailerQueue] resume];
[[MLFileParserQueue sharedFileParserQueue] resume];
} }
#pragma mark - migrations #pragma mark - migrations
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment