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

Commit b749075

Browse files
committed
2.5 - Fix auto correction.
1 parent 38bedba commit b749075

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

AutoExceptions.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ + (void)updateAutoExceptions{
5959
AFHTTPSessionManager *manager = [self manager];
6060
NSError *error;
6161
NSURLSessionDataTask *task;
62-
id responseObject = [manager syncGET:@"https://exceptions.ateliershiori.moe" parameters:nil task:&task error:&error];
62+
id responseObject = [manager syncGET:@"http://exceptions.malupdaterosx.moe/corrections/" parameters:nil task:&task error:&error];
6363
// Get Status Code
6464
switch (((NSHTTPURLResponse *)task.response).statusCode) {
6565
case 200:{
@@ -88,7 +88,7 @@ + (void)updateAutoExceptions{
8888
else {
8989
// Add Entry to Auto Exceptions
9090
obj = [NSEntityDescription
91-
insertNewObjectForEntityForName:@"AutoExceptions"
91+
insertNewObjectForEntityForName:@"AutoCorrection"
9292
inManagedObjectContext: moc];
9393
// Set values in the new record
9494
[obj setValue:detectedtitle forKey:@"detectedTitle"];
@@ -117,7 +117,7 @@ + (void)clearAutoExceptions{
117117
MAL_Updater_OS_XAppDelegate *delegate = (MAL_Updater_OS_XAppDelegate *)[NSApplication sharedApplication].delegate;
118118
NSManagedObjectContext *moc = delegate.managedObjectContext;
119119
NSFetchRequest *allExceptions = [[NSFetchRequest alloc] init];
120-
allExceptions.entity = [NSEntityDescription entityForName:@"AutoExceptions" inManagedObjectContext:moc];
120+
allExceptions.entity = [NSEntityDescription entityForName:@"AutoCorrection" inManagedObjectContext:moc];
121121

122122
NSError *error = nil;
123123
NSArray *exceptions = [moc executeFetchRequest:allExceptions error:&error];
@@ -139,7 +139,7 @@ + (NSManagedObject *)checkAutoExceptionsEntry:(NSString *)ctitle
139139
NSManagedObjectContext *moc = delegate.managedObjectContext;
140140
NSPredicate *predicate = [NSPredicate predicateWithFormat: @"(detectedTitle ==[c] %@) AND (correctTitle == %@) AND (group ==[c] %@) AND (iszeroepisode == %i) AND (episodeOffset == %i)", ctitle,correcttitle, group, zeroepisode, offset] ;
141141
NSFetchRequest *exfetch = [[NSFetchRequest alloc] init];
142-
exfetch.entity = [NSEntityDescription entityForName:@"AutoExceptions" inManagedObjectContext:moc];
142+
exfetch.entity = [NSEntityDescription entityForName:@"AutoCorrection" inManagedObjectContext:moc];
143143
exfetch.predicate = predicate;
144144
NSArray *exceptions = [moc executeFetchRequest:exfetch error:&error];
145145
if (exceptions.count > 0) {

MAL Updater OS XTests/MAL_Updater_OS_XTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ - (void)testScrobble {
8484
case ScrobblerAddTitleSuccessful:
8585
case ScrobblerConfirmNeeded:
8686
case ScrobblerUpdateNotNeeded:
87-
if ([expectedtitle caseInsensitiveCompare:[_MALEngine getLastScrobbledActualTitle]] == NSOrderedSame && [detectedepisode isEqualToString:[_MALEngine getLastScrobbledEpisode]]) {
87+
if (([expectedtitle caseInsensitiveCompare:[_MALEngine getLastScrobbledActualTitle]] == NSOrderedSame || [expectedtitle isEqualToString:_MALEngine.LastScrobbledActualTitle]) && [detectedepisode isEqualToString:[_MALEngine getLastScrobbledEpisode]]) {
8888
NSLog(@"Scrobble of %@ - %@ was sucessful with status: %i",expectedtitle,detectedepisode,status);
8989
success++;
9090
}

MyAnimeList.m

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ - (void)checkExceptions{
523523
NSManagedObjectContext *moc = self.managedObjectContext;
524524
bool found = false;
525525
NSPredicate *predicate;
526-
for (int i = 0; i < 2; i++) {
526+
for (int i = 0; i < 3; i++) {
527527

528528
NSFetchRequest *allExceptions = [[NSFetchRequest alloc] init];
529529
__block NSError *error = nil;
@@ -537,14 +537,19 @@ - (void)checkExceptions{
537537
predicate = [NSPredicate predicateWithFormat: @"(detectedTitle ==[c] %@) AND ((detectedSeason == %i) OR (detectedSeason == %i))", _DetectedTitle, 0, 1];
538538
}
539539
}
540-
else if (i== 1 && [[NSUserDefaults standardUserDefaults] boolForKey:@"UseAutoExceptions"]) {
540+
else if (i < 3 && [[NSUserDefaults standardUserDefaults] boolForKey:@"UseAutoExceptions"]) {
541541
NSLog(@"Checking Auto Exceptions");
542-
allExceptions.entity = [NSEntityDescription entityForName:@"AutoExceptions" inManagedObjectContext:moc];
542+
allExceptions.entity = [NSEntityDescription entityForName:@"AutoCorrection" inManagedObjectContext:moc];
543543
if (_DetectedSeason == 1 || _DetectedSeason == 0) {
544544
predicate = [NSPredicate predicateWithFormat: @"(detectedTitle ==[c] %@) AND ((group == %@) OR (group == %@))", _DetectedTitle, _DetectedGroup, @"ALL"];
545545
}
546546
else {
547-
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"];
547+
if (i == 1) {
548+
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"];
549+
}
550+
else {
551+
predicate = [NSPredicate predicateWithFormat: @"(detectedTitle ==[c] %@) AND ((group == %@) OR (group == %@))", _DetectedTitle, _DetectedGroup, @"ALL"];
552+
}
548553
}
549554
}
550555
else {break;}
@@ -598,8 +603,10 @@ - (void)checkExceptions{
598603
if (tmpepisode > 0) {
599604
_DetectedEpisode = [NSString stringWithFormat:@"%i", tmpepisode];
600605
}
606+
if (_DetectedSeason > 0 && i != 2) {
607+
_DetectedSeason = 0;
608+
}
601609
_DetectedType = @"";
602-
_DetectedSeason = 0;
603610
_DetectedTitleisEpisodeZero = false;
604611
found = true;
605612
break;

0 commit comments

Comments
 (0)