Commit 4b3d935b authored by Pierre's avatar Pierre

Add an option for no network access.

parent 0c6bfc6e
......@@ -11,6 +11,8 @@
@interface MLMediaLibrary : NSObject {
NSManagedObjectContext *_managedObjectContext;
NSManagedObjectModel *_managedObjectModel;
BOOL _allowNetworkAccess;
}
+ (id)sharedMediaLibrary;
......
......@@ -59,6 +59,9 @@
{
NSLog(@"Parsed %@ - %d tracks", media, [[_media tracksInformation] count]);
if (_media.delegate != self)
return;
_media.delegate = nil;
NSArray *tracks = [_media tracksInformation];
NSMutableSet *tracksSet = [NSMutableSet setWithCapacity:[tracks count]];
......@@ -80,7 +83,7 @@
[self.file setTracks:tracksSet];
[self.file setDuration:[[_media length] numberValue]];
[[MLFileParserQueue sharedFileParserQueue] setSuspended:NO];
[_media release];
//[_media autorelease];
_media = nil;
[self release];
}
......
......@@ -308,6 +308,8 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
- (void)fetchMetaDataForShow:(MLShow *)show
{
if (!_allowNetworkAccess)
return;
MLLog(@"Fetching show server time");
// First fetch the serverTime, so that we can update each entry.
......@@ -442,12 +444,20 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
[[MLFileParserQueue sharedFileParserQueue] addFile:file];
if (!_allowNetworkAccess) {
// Automatically compute the thumbnail
[self computeThumbnailForFile:file];
}
NSDictionary *tvShowEpisodeInfo = [MLTitleDecrapifier tvShowEpisodeInfoFromString:file.title];
if (tvShowEpisodeInfo) {
[self addTVShowEpisodeWithInfo:tvShowEpisodeInfo andFile:file];
return;
}
if (!_allowNetworkAccess)
return;
// Go online and fetch info.
// We don't care about keeping a reference to track the item during its life span
......@@ -604,6 +614,16 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
for (MLFile *file in results)
[[MLFileParserQueue sharedFileParserQueue] addFile:file];
if (!_allowNetworkAccess) {
// Always attempt to fetch
request = [self fetchRequestForEntity:@"File"];
[request setPredicate:[NSPredicate predicateWithFormat:@"isOnDisk == YES && computedThumbnail == nil"]];
results = [[self managedObjectContext] executeFetchRequest:request error:nil];
for (MLFile *file in results)
[self computeThumbnailForFile:file];
return;
}
// Get the thumbnails to compute
request = [self fetchRequestForEntity:@"File"];
[request setPredicate:[NSPredicate predicateWithFormat:@"isOnDisk == YES && hasFetchedInfo == 1 && artworkURL == nil && computedThumbnail == nil"]];
......@@ -611,6 +631,7 @@ static NSString *kLastTVDBUpdateServerTime = @"MLLastTVDBUpdateServerTime";
for (MLFile *file in results)
[self computeThumbnailForFile:file];
// Get to fetch meta data
request = [self fetchRequestForEntity:@"File"];
[request setPredicate:[NSPredicate predicateWithFormat:@"isOnDisk == YES && hasFetchedInfo == 0"]];
......
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