Skip to content
This repository has been archived by the owner on Jun 23, 2019. It is now read-only.

Commit

Permalink
2.5 - Fix auto correction.
Browse files Browse the repository at this point in the history
  • Loading branch information
moyitpro committed May 7, 2018
1 parent 38bedba commit b749075
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
8 changes: 4 additions & 4 deletions AutoExceptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ + (void)updateAutoExceptions{
AFHTTPSessionManager *manager = [self manager];
NSError *error;
NSURLSessionDataTask *task;
id responseObject = [manager syncGET:@"https://exceptions.ateliershiori.moe" parameters:nil task:&task error:&error];
id responseObject = [manager syncGET:@"http://exceptions.malupdaterosx.moe/corrections/" parameters:nil task:&task error:&error];
// Get Status Code
switch (((NSHTTPURLResponse *)task.response).statusCode) {
case 200:{
Expand Down Expand Up @@ -88,7 +88,7 @@ + (void)updateAutoExceptions{
else {
// Add Entry to Auto Exceptions
obj = [NSEntityDescription
insertNewObjectForEntityForName:@"AutoExceptions"
insertNewObjectForEntityForName:@"AutoCorrection"
inManagedObjectContext: moc];
// Set values in the new record
[obj setValue:detectedtitle forKey:@"detectedTitle"];
Expand Down Expand Up @@ -117,7 +117,7 @@ + (void)clearAutoExceptions{
MAL_Updater_OS_XAppDelegate *delegate = (MAL_Updater_OS_XAppDelegate *)[NSApplication sharedApplication].delegate;
NSManagedObjectContext *moc = delegate.managedObjectContext;
NSFetchRequest *allExceptions = [[NSFetchRequest alloc] init];
allExceptions.entity = [NSEntityDescription entityForName:@"AutoExceptions" inManagedObjectContext:moc];
allExceptions.entity = [NSEntityDescription entityForName:@"AutoCorrection" inManagedObjectContext:moc];

NSError *error = nil;
NSArray *exceptions = [moc executeFetchRequest:allExceptions error:&error];
Expand All @@ -139,7 +139,7 @@ + (NSManagedObject *)checkAutoExceptionsEntry:(NSString *)ctitle
NSManagedObjectContext *moc = delegate.managedObjectContext;
NSPredicate *predicate = [NSPredicate predicateWithFormat: @"(detectedTitle ==[c] %@) AND (correctTitle == %@) AND (group ==[c] %@) AND (iszeroepisode == %i) AND (episodeOffset == %i)", ctitle,correcttitle, group, zeroepisode, offset] ;
NSFetchRequest *exfetch = [[NSFetchRequest alloc] init];
exfetch.entity = [NSEntityDescription entityForName:@"AutoExceptions" inManagedObjectContext:moc];
exfetch.entity = [NSEntityDescription entityForName:@"AutoCorrection" inManagedObjectContext:moc];
exfetch.predicate = predicate;
NSArray *exceptions = [moc executeFetchRequest:exfetch error:&error];
if (exceptions.count > 0) {
Expand Down
2 changes: 1 addition & 1 deletion MAL Updater OS XTests/MAL_Updater_OS_XTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ - (void)testScrobble {
case ScrobblerAddTitleSuccessful:
case ScrobblerConfirmNeeded:
case ScrobblerUpdateNotNeeded:
if ([expectedtitle caseInsensitiveCompare:[_MALEngine getLastScrobbledActualTitle]] == NSOrderedSame && [detectedepisode isEqualToString:[_MALEngine getLastScrobbledEpisode]]) {
if (([expectedtitle caseInsensitiveCompare:[_MALEngine getLastScrobbledActualTitle]] == NSOrderedSame || [expectedtitle isEqualToString:_MALEngine.LastScrobbledActualTitle]) && [detectedepisode isEqualToString:[_MALEngine getLastScrobbledEpisode]]) {
NSLog(@"Scrobble of %@ - %@ was sucessful with status: %i",expectedtitle,detectedepisode,status);
success++;
}
Expand Down
Binary file not shown.
Binary file not shown.
17 changes: 12 additions & 5 deletions MyAnimeList.m
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ - (void)checkExceptions{
NSManagedObjectContext *moc = self.managedObjectContext;
bool found = false;
NSPredicate *predicate;
for (int i = 0; i < 2; i++) {
for (int i = 0; i < 3; i++) {

NSFetchRequest *allExceptions = [[NSFetchRequest alloc] init];
__block NSError *error = nil;
Expand All @@ -537,14 +537,19 @@ - (void)checkExceptions{
predicate = [NSPredicate predicateWithFormat: @"(detectedTitle ==[c] %@) AND ((detectedSeason == %i) OR (detectedSeason == %i))", _DetectedTitle, 0, 1];
}
}
else if (i== 1 && [[NSUserDefaults standardUserDefaults] boolForKey:@"UseAutoExceptions"]) {
else if (i < 3 && [[NSUserDefaults standardUserDefaults] boolForKey:@"UseAutoExceptions"]) {
NSLog(@"Checking Auto Exceptions");
allExceptions.entity = [NSEntityDescription entityForName:@"AutoExceptions" inManagedObjectContext:moc];
allExceptions.entity = [NSEntityDescription entityForName:@"AutoCorrection" inManagedObjectContext:moc];
if (_DetectedSeason == 1 || _DetectedSeason == 0) {
predicate = [NSPredicate predicateWithFormat: @"(detectedTitle ==[c] %@) AND ((group == %@) OR (group == %@))", _DetectedTitle, _DetectedGroup, @"ALL"];
}
else {
predicate = [NSPredicate predicateWithFormat: @"((detectedTitle ==[c] %@) OR (detectedTitle ==[c] %@) OR (detectedTitle ==[c] %@)) AND ((group == %@) OR (group == %@))", [NSString stringWithFormat:@"%@ %i", _DetectedTitle, _DetectedSeason], [NSString stringWithFormat:@"%@ S%i", _DetectedTitle, _DetectedSeason], [NSString stringWithFormat:@"%@ %@ Season", _DetectedTitle, [Utility numbertoordinal:_DetectedSeason]], _DetectedGroup, @"ALL"];
if (i == 1) {
predicate = [NSPredicate predicateWithFormat: @"((detectedTitle ==[c] %@) OR (detectedTitle ==[c] %@) OR (detectedTitle ==[c] %@)) AND ((group == %@) OR (group == %@))", [NSString stringWithFormat:@"%@ %i", _DetectedTitle, _DetectedSeason], [NSString stringWithFormat:@"%@ S%i", _DetectedTitle, _DetectedSeason], [NSString stringWithFormat:@"%@ %@ Season", _DetectedTitle, [Utility numbertoordinal:_DetectedSeason]], _DetectedGroup, @"ALL"];
}
else {
predicate = [NSPredicate predicateWithFormat: @"(detectedTitle ==[c] %@) AND ((group == %@) OR (group == %@))", _DetectedTitle, _DetectedGroup, @"ALL"];
}
}
}
else {break;}
Expand Down Expand Up @@ -598,8 +603,10 @@ - (void)checkExceptions{
if (tmpepisode > 0) {
_DetectedEpisode = [NSString stringWithFormat:@"%i", tmpepisode];
}
if (_DetectedSeason > 0 && i != 2) {
_DetectedSeason = 0;
}
_DetectedType = @"";
_DetectedSeason = 0;
_DetectedTitleisEpisodeZero = false;
found = true;
break;
Expand Down

0 comments on commit b749075

Please sign in to comment.