Skip to content

Commit

Permalink
3.3.15-beta5 - Fix title correction feature
Browse files Browse the repository at this point in the history
The } brace was put in the incorrect place, so the corrected title match result was never being used, thus causing the errounous title not found.
  • Loading branch information
千代田桃 committed Feb 26, 2023
1 parent 5d06a71 commit 57e346a
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 66 deletions.
118 changes: 59 additions & 59 deletions Hachidori+Search.m
Original file line number Diff line number Diff line change
Expand Up @@ -196,83 +196,83 @@ - (NSString *)findaniid:(id)responseObject {
}
}
}
if (matchstatus == PrimaryTitleMatch || matchstatus == AlternateTitleMatch) {
if (self.detectedscrobble.DetectedTitleisMovie) {
self.detectedscrobble.DetectedEpisode = @"1"; // Usually, there is one episode in a movie.
if ([[NSString stringWithFormat:@"%@", searchentry[@"type"]] isEqualToString:@"Special"]) {
self.detectedscrobble.DetectedTitleisMovie = false;
}
}
else {
if ([[NSString stringWithFormat:@"%@", searchentry[@"type"]] isEqualToString:@"TV"]||[[NSString stringWithFormat:@"%@", searchentry[@"type"]] isEqualToString:@"ONA"]) { // Check Seasons if the title is a TV show type
// Used for Season Checking
if (self.detectedscrobble.DetectedSeason != ((NSNumber *)searchentry[@"parsed_season"]).intValue && self.detectedscrobble.DetectedSeason >= 2) { // Season detected, check to see if there is a match. If not, continue.
continue;
}
}
}
if (matchstatus == PrimaryTitleMatch || matchstatus == AlternateTitleMatch) {
if (self.detectedscrobble.DetectedTitleisMovie) {
self.detectedscrobble.DetectedEpisode = @"1"; // Usually, there is one episode in a movie.
if ([[NSString stringWithFormat:@"%@", searchentry[@"type"]] isEqualToString:@"Special"]) {
self.detectedscrobble.DetectedTitleisMovie = false;
}
}
else if (matchstatus == NoMatch) {
continue;
}
//Return titleid if episode is valid
int episodes = !searchentry[@"episodes"] ? 0 : ((NSNumber *)searchentry[@"episodes"]).intValue;
bool matchestitle = matchstatus == PrimaryTitleMatch ? [term caseInsensitiveCompare:theshowtitle] == NSOrderedSame : [term caseInsensitiveCompare:alttitle] == NSOrderedSame;
if (episodes == 0 || ((episodes >= self.detectedscrobble.DetectedEpisode.intValue) && self.detectedscrobble.DetectedEpisode.intValue > 0)) {
if (((NSNumber *)searchentry[@"parsed_season"]).intValue >= 2 && ((NSNumber *)searchentry[@"parsed_season"]).intValue != self.detectedscrobble.DetectedSeason && !matchestitle) {
continue;
}
NSLog(@"Valid Episode Count");
if (sortedArray.count == 1 || self.detectedscrobble.DetectedSeason >= 2) {
// Only Result, return
return [self foundtitle:((NSNumber *)searchentry[@"id"]).stringValue info:searchentry];
}
else if (episodes >= self.detectedscrobble.DetectedEpisode.intValue && !titlematch1 && sortedArray.count > 1 && ((term.length < theshowtitle.length+1)||(term.length< alttitle.length+1 && alttitle.length > 0 && matchstatus == AlternateTitleMatch))) {
mstatus = matchstatus;
titlematch1 = searchentry;
continue;
}
else if (titlematch1 && (episodes >= self.detectedscrobble.DetectedEpisode.intValue || episodes == 0)) {
titlematch2 = searchentry;
return titlematch1 != titlematch2 ? [self comparetitle:term match1:titlematch1 match2:titlematch2 mstatus:mstatus mstatus2:matchstatus] : [self foundtitle:[NSString stringWithFormat:@"%@",searchentry[@"id"]] info:searchentry];
}
else {
if ([NSUserDefaults.standardUserDefaults boolForKey:@"UseAnimeRelations"]) {
int newid = [self checkAnimeRelations:((NSNumber *)searchentry[@"id"]).intValue];
if (newid > 0) {
[self foundtitle:((NSNumber *)searchentry[@"id"]).stringValue info:searchentry];
return @(newid).stringValue;
if ([[NSString stringWithFormat:@"%@", searchentry[@"type"]] isEqualToString:@"TV"]||[[NSString stringWithFormat:@"%@", searchentry[@"type"]] isEqualToString:@"ONA"]) { // Check Seasons if the title is a TV show type
// Used for Season Checking
if (self.detectedscrobble.DetectedSeason != ((NSNumber *)searchentry[@"parsed_season"]).intValue && self.detectedscrobble.DetectedSeason >= 2) { // Season detected, check to see if there is a match. If not, continue.
continue;
}
}
// Only Result, return
return [self foundtitle:((NSNumber *)searchentry[@"id"]).stringValue info:searchentry];
}
}
else if (matchstatus == NoMatch) {
continue;
}
//Return titleid if episode is valid
int episodes = !searchentry[@"episodes"] ? 0 : ((NSNumber *)searchentry[@"episodes"]).intValue;
bool matchestitle = matchstatus == PrimaryTitleMatch ? [term caseInsensitiveCompare:theshowtitle] == NSOrderedSame : [term caseInsensitiveCompare:alttitle] == NSOrderedSame;
if (episodes == 0 || ((episodes >= self.detectedscrobble.DetectedEpisode.intValue) && self.detectedscrobble.DetectedEpisode.intValue > 0)) {
if (((NSNumber *)searchentry[@"parsed_season"]).intValue >= 2 && ((NSNumber *)searchentry[@"parsed_season"]).intValue != self.detectedscrobble.DetectedSeason && !matchestitle) {
continue;
}
NSLog(@"Valid Episode Count");
if (sortedArray.count == 1 || self.detectedscrobble.DetectedSeason >= 2) {
// Only Result, return
return [self foundtitle:((NSNumber *)searchentry[@"id"]).stringValue info:searchentry];
}
else if (episodes >= self.detectedscrobble.DetectedEpisode.intValue && !titlematch1 && sortedArray.count > 1 && ((term.length < theshowtitle.length+1)||(term.length< alttitle.length+1 && alttitle.length > 0 && matchstatus == AlternateTitleMatch))) {
mstatus = matchstatus;
titlematch1 = searchentry;
continue;
}
else if ((episodes < self.detectedscrobble.DetectedEpisode.intValue) && self.detectedscrobble.DetectedEpisode.intValue > 0) {
// Check Relations
else if (titlematch1 && (episodes >= self.detectedscrobble.DetectedEpisode.intValue || episodes == 0)) {
titlematch2 = searchentry;
return titlematch1 != titlematch2 ? [self comparetitle:term match1:titlematch1 match2:titlematch2 mstatus:mstatus mstatus2:matchstatus] : [self foundtitle:[NSString stringWithFormat:@"%@",searchentry[@"id"]] info:searchentry];
}
else {
if ([NSUserDefaults.standardUserDefaults boolForKey:@"UseAnimeRelations"]) {
int newid = [self checkAnimeRelations:((NSNumber *)searchentry[@"id"]).intValue];
if (newid > 0) {
[self foundtitle:((NSNumber *)searchentry[@"id"]).stringValue info:searchentry];
return @(newid).stringValue;
}
}
// Only Result, return
return [self foundtitle:((NSNumber *)searchentry[@"id"]).stringValue info:searchentry];
}
}
else if ((episodes < self.detectedscrobble.DetectedEpisode.intValue) && self.detectedscrobble.DetectedEpisode.intValue > 0) {
// Check Relations
if ([NSUserDefaults.standardUserDefaults boolForKey:@"UseAnimeRelations"]) {
int newid = [self checkAnimeRelations:((NSNumber *)searchentry[@"id"]).intValue];
if (newid > 0) {
[self foundtitle:((NSNumber *)searchentry[@"id"]).stringValue info:searchentry];
return @(newid).stringValue;
}
else {
if ([self checkAnimeRelationsForExisting:((NSNumber *)searchentry[@"id"]).intValue]) {
[self foundtitle:((NSNumber *)searchentry[@"id"]).stringValue info:searchentry];
return @(newid).stringValue;
}
else {
if ([self checkAnimeRelationsForExisting:((NSNumber *)searchentry[@"id"]).intValue]) {
[self foundtitle:((NSNumber *)searchentry[@"id"]).stringValue info:searchentry];
return @(newid).stringValue;
}
else {
continue;
}
continue;
}
}
}
else {
// Detected episodes exceed total episodes
continue;
}

}
else {
// Detected episodes exceed total episodes
continue;
}

}
}
// If one match is found and not null, then return the id.
Expand Down
5 changes: 2 additions & 3 deletions Hachidori.m
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ - (void)checkExceptions {
self.detectedscrobble.corrected = true;
self.detectedscrobble.DetectedTitle = correcttitle;
self.detectedscrobble.DetectedEpisode = [NSString stringWithFormat:@"%i", mappedepisode];
self.detectedscrobble.DetectedSeason = 0;
self.detectedscrobble.DetectedTitleisEpisodeZero = true;
found = true;
[self checkType];
Expand All @@ -727,9 +728,7 @@ - (void)checkExceptions {
if (tmpepisode > 0) {
self.detectedscrobble.DetectedEpisode = [NSString stringWithFormat:@"%i", tmpepisode];
}
if (self.detectedscrobble.DetectedSeason > 0 && i != 2) {
self.detectedscrobble.DetectedSeason = 0;
}
self.detectedscrobble.DetectedSeason = 0;
self.detectedscrobble.DetectedType = @"";
self.detectedscrobble.DetectedTitle = correcttitle;
self.detectedscrobble.DetectedTitleisEpisodeZero = false;
Expand Down
8 changes: 4 additions & 4 deletions Hachidori.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 20230221;
CURRENT_PROJECT_VERSION = 20230226;
DEVELOPMENT_TEAM = 9HDZTER525;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -1679,7 +1679,7 @@
"$(PROJECT_DIR)",
);
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = "3.3.15-beta4";
MARKETING_VERSION = "3.3.15-beta5";
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "moe.ateliershiori.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = Hachidori;
Expand All @@ -1702,7 +1702,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 20230221;
CURRENT_PROJECT_VERSION = 20230226;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 9HDZTER525;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -1727,7 +1727,7 @@
"$(PROJECT_DIR)",
);
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = "3.3.15-beta4";
MARKETING_VERSION = "3.3.15-beta5";
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "moe.ateliershiori.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = Hachidori;
Expand Down

0 comments on commit 57e346a

Please sign in to comment.