Skip to content

Commit

Permalink
Merge pull request #1055 from wutschel/feature_hideemptytvshow
Browse files Browse the repository at this point in the history
  • Loading branch information
kambala-decapitator committed May 11, 2024
2 parents eb72b3d + 40d1d5a commit 1e9c6b7
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 5 deletions.
1 change: 1 addition & 0 deletions XBMC Remote/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
@property (nonatomic, assign) int APIpatchVersion;
@property (nonatomic, assign) BOOL isIgnoreArticlesEnabled;
@property (nonatomic, assign) BOOL isGroupSingleItemSetsEnabled;
@property (nonatomic, assign) BOOL isShowEmptyTvShowsEnabled;
@property (nonatomic, copy) NSArray *KodiSorttokens;
@property (nonatomic, strong) GlobalData *obj;

Expand Down
1 change: 1 addition & 0 deletions XBMC Remote/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -3564,6 +3564,7 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N
@"thumbnail",
@"genre",
@"studio",
@"episode",
],
}, @"parameters",
@{
Expand Down
14 changes: 10 additions & 4 deletions XBMC Remote/DetailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -4661,6 +4661,9 @@ - (void)retrieveData:(NSString*)methodToCall parameters:(NSDictionary*)parameter
// are movie sets, enable the postprocessing to ignore movies sets with only 1 movie.
BOOL ignoreSingleMovieSets = !AppDelegate.instance.isGroupSingleItemSetsEnabled && [methodToCall isEqualToString:@"VideoLibrary.GetMovieSets"];

// If the feature to list empty TV Shows is disabled and the current results are TV Shows, ignore TV Shows without any episode.
BOOL ignoreEmptyTvShows = !AppDelegate.instance.isShowEmptyTvShowsEnabled && [methodToCall isEqualToString:@"VideoLibrary.GetTVShows"];

// If we are reading PVR recordings or PVR timers, we need to filter them for the current mode in
// postprocessing. Ignore Radio recordings/timers, if we are in TV mode. Or ignore TV recordings/timers,
// if we are in Radio mode.
Expand Down Expand Up @@ -4709,12 +4712,12 @@ - (void)retrieveData:(NSString*)methodToCall parameters:(NSDictionary*)parameter

// Check if we need to ignore the current item
BOOL isRadioItem = [item[@"radio"] boolValue] ||
[item[@"isradio"] boolValue];
[item[@"isradio"] boolValue];
BOOL isTimerRule = [item[@"istimerrule"] boolValue];
BOOL ignorePvrItem = (ignoreRadioItems && isRadioItem) ||
(ignoreTvItems && !isRadioItem) ||
(ignoreTimerRulesItems && isTimerRule) ||
(ignoreTimerItems && !isTimerRule);
(ignoreTvItems && !isRadioItem) ||
(ignoreTimerRulesItems && isTimerRule) ||
(ignoreTimerItems && !isTimerRule);

// Postprocessing of movie sets lists to ignore 1-movie-sets
if (ignoreSingleMovieSets) {
Expand All @@ -4738,6 +4741,9 @@ - (void)retrieveData:(NSString*)methodToCall parameters:(NSDictionary*)parameter
else if (ignorePvrItem) {
NSLog(@"Ignore PVR item as not matching current TV/Radio mode.");
}
else if (ignoreEmptyTvShows && [item[@"episode"] intValue] == 0) {
// Do nothing
}
else {
[resultStoreArray addObject:newDict];
}
Expand Down
1 change: 1 addition & 0 deletions XBMC Remote/VersionCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

+ (BOOL)hasRecordingIdPlaylistSupport;
+ (BOOL)hasGroupSingleItemSetsSupport;
+ (BOOL)hasShowEmptyTvShowsSupport;
+ (BOOL)hasSortTokenReadSupport;
+ (BOOL)hasPvrSortSupport;
+ (BOOL)hasAlbumArtistOnlySupport;
Expand Down
7 changes: 7 additions & 0 deletions XBMC Remote/VersionCheck.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ + (BOOL)hasGroupSingleItemSetsSupport {
(AppDelegate.instance.APImajorVersion == 6 && AppDelegate.instance.APIminorVersion == 32 && AppDelegate.instance.APIpatchVersion >= 4);
}

+ (BOOL)hasShowEmptyTvShowsSupport {
// ShowEmptyTvShows is enabled (supported from API 6.32.1 on)
return (AppDelegate.instance.APImajorVersion >= 7) ||
(AppDelegate.instance.APImajorVersion == 6 && AppDelegate.instance.APIminorVersion >= 33) ||
(AppDelegate.instance.APImajorVersion == 6 && AppDelegate.instance.APIminorVersion == 32 && AppDelegate.instance.APIpatchVersion >= 1);
}

+ (BOOL)hasSortTokenReadSupport {
// Sort token can be read from API 9.5.0 on
return (AppDelegate.instance.APImajorVersion == 9 && AppDelegate.instance.APIminorVersion >= 5) ||
Expand Down
25 changes: 24 additions & 1 deletion XBMC Remote/tcpJSONRPC.m
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,12 @@ - (void)readJSONRPCAPIVersion {
AppDelegate.instance.APIpatchVersion = 0;
}
}
// Read the sorttokens
[self readSorttokens];

// Read 1-movie-set setting
[self readGroupSingleItemSets];

[self readShowEmptyTvShows];
}];
}

Expand All @@ -307,6 +309,27 @@ - (void)readGroupSingleItemSets {
}
}

- (void)readShowEmptyTvShows {
// Check if ShowEmptyTvShows is enabled
if ([VersionCheck hasShowEmptyTvShowsSupport]) {
[[Utilities getJsonRPC]
callMethod:@"Settings.GetSettingValue"
withParameters:@{@"setting": @"videolibrary.showemptytvshows"}
withTimeout: SERVER_TIMEOUT
onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) {
if (!error && !methodError && [methodResult isKindOfClass:[NSDictionary class]]) {
AppDelegate.instance.isShowEmptyTvShowsEnabled = [methodResult[@"value"] boolValue];
}
else {
AppDelegate.instance.isShowEmptyTvShowsEnabled = YES;
}
}];
}
else {
AppDelegate.instance.isShowEmptyTvShowsEnabled = YES;
}
}

- (void)readSorttokens {
NSArray *defaultTokens = @[@"The ", @"The.", @"The_"];
// Read sort token from properties
Expand Down

0 comments on commit 1e9c6b7

Please sign in to comment.