Skip to content

Commit 18ff23f

Browse files
DeltaMikeCharlieFlole998
authored andcommitted
Add country and authority to HTPS messages containing rating labels.
1 parent f9d5e88 commit 18ff23f

4 files changed

Lines changed: 163 additions & 6 deletions

File tree

src/dvr/dvr.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,10 @@ typedef struct dvr_entry {
249249
//may have changed, so keep an absolute copy of the values at
250250
//the time of recording rather than pointing to a rating label
251251
//object that may no longer exist many years later.
252-
char *de_rating_label_saved; /* Saved rating label for once the recording has been completed*/
253-
char *de_rating_icon_saved; /* Saved rating icon full path (not image cache) for once the recording has been completed*/
252+
char *de_rating_label_saved; /* Saved rating label for after the recording has been completed*/
253+
char *de_rating_icon_saved; /* Saved rating icon full path (not image cache) for after the recording has been completed*/
254+
char *de_rating_country_saved; /* Saved rating country code for after the recording has been completed*/
255+
char *de_rating_authority_saved; /* Saved rating authority for after the recording has been completed*/
254256
ratinglabel_t *de_rating_label; /* 'Live' rating label object */
255257

256258
int de_pri;

src/dvr/dvr_db.c

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,15 @@ dvr_entry_create_from_htsmsg(htsmsg_t *conf, epg_broadcast_t *e)
12211221
if(e->rating_label->rl_icon){
12221222
htsmsg_add_str(conf, "rating_icon_saved", imagecache_get_propstr(e->rating_label->rl_icon, tbuf, sizeof(tbuf)));
12231223
}
1224+
1225+
if(e->rating_label->rl_country){
1226+
htsmsg_add_str(conf, "rating_country_saved", e->rating_label->rl_country);
1227+
}
1228+
1229+
if(e->rating_label->rl_authority){
1230+
htsmsg_add_str(conf, "rating_authority_saved", e->rating_label->rl_authority);
1231+
}
1232+
12241233
}
12251234
}//END rating labels enabled.
12261235

@@ -3465,6 +3474,22 @@ dvr_entry_class_rating_set(void *o, const void *v)
34653474
de->de_rating_icon_saved = strdup(rl->rl_icon);
34663475
}
34673476

3477+
if(de->de_rating_authority_saved){
3478+
free(de->de_rating_authority_saved);
3479+
}
3480+
3481+
if(rl->rl_authority){
3482+
de->de_rating_authority_saved = strdup(rl->rl_authority);
3483+
}
3484+
3485+
if(de->de_rating_country_saved){
3486+
free(de->de_rating_country_saved);
3487+
}
3488+
3489+
if(rl->rl_country){
3490+
de->de_rating_country_saved = strdup(rl->rl_country);
3491+
}
3492+
34683493
return 1;
34693494
}//END we got an RL object.
34703495

@@ -4074,6 +4099,53 @@ dvr_entry_class_rating_label_get(void *o)
40744099
return &prop_ptr;
40754100
}
40764101

4102+
static const void *
4103+
dvr_entry_class_rating_authority_get(void *o)
4104+
{
4105+
dvr_entry_t *de = (dvr_entry_t *)o;
4106+
ratinglabel_t *rl = de->de_rating_label;
4107+
if (rl == NULL) {
4108+
prop_ptr = "";
4109+
if(de->de_rating_authority_saved){
4110+
prop_ptr = de->de_rating_authority_saved;
4111+
}
4112+
} else {
4113+
if(de->de_sched_state == DVR_SCHEDULED){
4114+
prop_ptr = rl->rl_authority;
4115+
}
4116+
else
4117+
{
4118+
prop_ptr = de->de_rating_authority_saved;
4119+
}
4120+
4121+
}
4122+
return &prop_ptr;
4123+
}
4124+
4125+
static const void *
4126+
dvr_entry_class_rating_country_get(void *o)
4127+
{
4128+
dvr_entry_t *de = (dvr_entry_t *)o;
4129+
ratinglabel_t *rl = de->de_rating_label;
4130+
if (rl == NULL) {
4131+
prop_ptr = "";
4132+
if(de->de_rating_country_saved){
4133+
prop_ptr = de->de_rating_country_saved;
4134+
}
4135+
} else {
4136+
if(de->de_sched_state == DVR_SCHEDULED){
4137+
prop_ptr = rl->rl_country;
4138+
}
4139+
else
4140+
{
4141+
prop_ptr = de->de_rating_country_saved;
4142+
}
4143+
4144+
}
4145+
return &prop_ptr;
4146+
}
4147+
4148+
40774149
static const void *
40784150
dvr_entry_class_duplicate_get(void *o)
40794151
{
@@ -4791,6 +4863,22 @@ const idclass_t dvr_entry_class = {
47914863
.off = offsetof(dvr_entry_t, de_rating_icon_saved),
47924864
.opts = PO_RDONLY | PO_NOUI,
47934865
},
4866+
{
4867+
.type = PT_STR,
4868+
.id = "rating_authority_saved",
4869+
.name = N_("Saved Rating Authority"),
4870+
.desc = N_("Saved parental rating authority for once recording is complete."),
4871+
.off = offsetof(dvr_entry_t, de_rating_authority_saved),
4872+
.opts = PO_RDONLY | PO_NOUI,
4873+
},
4874+
{
4875+
.type = PT_STR,
4876+
.id = "rating_country_saved",
4877+
.name = N_("Saved Rating Country"),
4878+
.desc = N_("Saved parental rating country for once recording is complete."),
4879+
.off = offsetof(dvr_entry_t, de_rating_country_saved),
4880+
.opts = PO_RDONLY | PO_NOUI,
4881+
},
47944882
//This needs to go after the 'saved' properties because loading the RL object
47954883
//can refresh the 'saved' objects for scheduled entries.
47964884
{
@@ -4812,6 +4900,22 @@ const idclass_t dvr_entry_class = {
48124900
.get = dvr_entry_class_rating_icon_url_get,
48134901
.opts = PO_HIDDEN | PO_RDONLY | PO_NOSAVE | PO_NOUI,
48144902
},
4903+
{
4904+
.type = PT_STR,
4905+
.id = "rating_authority",
4906+
.name = N_("Rating Authority"),
4907+
.desc = N_("Rating Authority."),
4908+
.get = dvr_entry_class_rating_authority_get,
4909+
.opts = PO_HIDDEN | PO_RDONLY | PO_NOSAVE | PO_NOUI,
4910+
},
4911+
{
4912+
.type = PT_STR,
4913+
.id = "rating_country",
4914+
.name = N_("Rating Country"),
4915+
.desc = N_("Rating Country."),
4916+
.get = dvr_entry_class_rating_country_get,
4917+
.opts = PO_HIDDEN | PO_RDONLY | PO_NOSAVE | PO_NOUI,
4918+
},
48154919
{
48164920
.type = PT_STR,
48174921
.id = "rating_label",

src/htsp_server.c

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
static void *htsp_server, *htsp_server_2;
5353

54-
#define HTSP_PROTO_VERSION 40
54+
#define HTSP_PROTO_VERSION 41
5555

5656
#define HTSP_ASYNC_OFF 0x00
5757
#define HTSP_ASYNC_ON 0x01
@@ -1049,8 +1049,22 @@ htsp_build_dvrentry(htsp_connection_t *htsp, dvr_entry_t *de, const char *method
10491049
htsmsg_add_str(out, "ratingIcon", str);
10501050
}//END got an imagecache location
10511051
}//END icon not null
1052-
}
1053-
}
1052+
1053+
//The authority and country are added for Kodi's parentalRatingSource field.
1054+
//Kodi looks for the authority first and if that is not present, then it uses the country.
1055+
//There could be no label, but there could be an age. The authority &
1056+
//country could still be useful.
1057+
if (htsp->htsp_version > 40){
1058+
if(de->de_rating_label->rl_authority){
1059+
htsmsg_add_str(out, "ratingAuthority", de->de_rating_label->rl_authority);
1060+
}//END authority saved not null
1061+
1062+
if(de->de_rating_label->rl_country){
1063+
htsmsg_add_str(out, "ratingCountry", de->de_rating_label->rl_country);
1064+
}//END country saved not null
1065+
}//END ver > 40
1066+
}//END rating label not null
1067+
}//END this is a scheduled recording.
10541068
else
10551069
{
10561070
if(de->de_rating_label_saved){
@@ -1065,8 +1079,19 @@ htsp_build_dvrentry(htsp_connection_t *htsp, dvr_entry_t *de, const char *method
10651079
htsmsg_add_str(out, "ratingIcon", str);
10661080
}//END got an imagecache location
10671081
}//END icon not null
1082+
1083+
if (htsp->htsp_version > 40){
1084+
if(de->de_rating_authority_saved){
1085+
htsmsg_add_str(out, "ratingAuthority", de->de_rating_authority_saved);
1086+
}//END authority saved not null
1087+
1088+
if(de->de_rating_country_saved){
1089+
htsmsg_add_str(out, "ratingCountry", de->de_rating_country_saved);
1090+
}//END country saved not null
1091+
}//END version > 40
1092+
10681093
}
1069-
}
1094+
}//END this is not a scheduled recording.
10701095
}//END processing rating labels is enabled
10711096
}
10721097

@@ -1416,6 +1441,16 @@ htsp_build_event
14161441
htsmsg_add_str(out, "ratingIcon", str);
14171442
}//END got an imagecache location
14181443
}//END icon not null
1444+
1445+
if (htsp->htsp_version > 40){
1446+
if(e->rating_label->rl_authority){
1447+
htsmsg_add_str(out, "ratingAuthority", e->rating_label->rl_authority);
1448+
}//END authority saved not null
1449+
1450+
if(e->rating_label->rl_country){
1451+
htsmsg_add_str(out, "ratingCountry", e->rating_label->rl_country);
1452+
}//END country saved not null
1453+
}
14191454
}//END rating label not null
14201455
}//END parental labels enabled.
14211456
}//END HTSP version check

src/ratinglabels.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,22 @@ ratinglabel_class_save(idnode_t *self, char *filename, size_t fsize)
533533
de->de_rating_icon_saved = NULL;
534534
}
535535

536+
//If this RL has a country, save that, else, ensure that the recording's RL country is empty.
537+
if(rl->rl_icon){
538+
de->de_rating_country_saved = strdup(rl->rl_country);
539+
}
540+
else {
541+
de->de_rating_country_saved = NULL;
542+
}
543+
544+
//If this RL has an authority, save that, else, ensure that the recording's RL authority is empty.
545+
if(rl->rl_icon){
546+
de->de_rating_authority_saved = strdup(rl->rl_authority);
547+
}
548+
else {
549+
de->de_rating_authority_saved = NULL;
550+
}
551+
536552
dvr_entry_changed(de); //Save this recording and push it out to clients.
537553
foundCount++;
538554
}//END we matched the RL

0 commit comments

Comments
 (0)