Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DVR: Store episode string to storage, fixes #2357
  • Loading branch information
perexg committed Nov 19, 2014
1 parent f15b8a6 commit 6ddbd16
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
1 change: 1 addition & 0 deletions src/dvr/dvr.h
Expand Up @@ -172,6 +172,7 @@ typedef struct dvr_entry {
* EPG information / links
*/
epg_broadcast_t *de_bcast;
char *de_episode;

/**
* Major State
Expand Down
60 changes: 30 additions & 30 deletions src/dvr/dvr_db.c
Expand Up @@ -253,35 +253,33 @@ dvr_make_title(char *output, size_t outlen, dvr_entry_t *de)
snprintf(output + strlen(output), outlen - strlen(output),
"%s", lang_str_get(de->de_title, NULL));

if(cfg->dvr_episode_before_date) {
if(cfg->dvr_episode_in_title) {
if(de->de_bcast && de->de_bcast->episode)
epg_episode_number_format(de->de_bcast->episode,
output + strlen(output),
outlen - strlen(output),
".", "S%02d", NULL, "E%02d", NULL);
}
if (cfg->dvr_episode_before_date) {
if (cfg->dvr_episode_in_title && de->de_bcast && de->de_bcast->episode)
epg_episode_number_format(de->de_bcast->episode,
output + strlen(output),
outlen - strlen(output),
".", "S%02d", NULL, "E%02d", NULL);
}

if(cfg->dvr_subtitle_in_title) {
if (cfg->dvr_subtitle_in_title) {
if(de->de_bcast && de->de_bcast->episode && de->de_bcast->episode->subtitle)
snprintf(output + strlen(output), outlen - strlen(output),
".%s", lang_str_get(de->de_bcast->episode->subtitle, NULL));
}

localtime_r(&de->de_start, &tm);

if(cfg->dvr_date_in_title) {
if (cfg->dvr_date_in_title) {
strftime(buf, sizeof(buf), "%F", &tm);
snprintf(output + strlen(output), outlen - strlen(output), ".%s", buf);
}

if(cfg->dvr_time_in_title) {
if (cfg->dvr_time_in_title) {
strftime(buf, sizeof(buf), "%H-%M", &tm);
snprintf(output + strlen(output), outlen - strlen(output), ".%s", buf);
}

if(!cfg->dvr_episode_before_date) {
if (!cfg->dvr_episode_before_date) {
if(cfg->dvr_episode_in_title) {
if(de->de_bcast && de->de_bcast->episode)
epg_episode_number_format(de->de_bcast->episode,
Expand Down Expand Up @@ -674,6 +672,8 @@ dvr_entry_destroy(dvr_entry_t *de, int delconf)
de->de_channel = NULL;
free(de->de_channel_name);
de->de_channel_name = NULL;
free(de->de_episode);
de->de_episode = NULL;

dvr_entry_dec_ref(de);
}
Expand Down Expand Up @@ -731,6 +731,7 @@ static dvr_entry_t *_dvr_entry_update
const char *desc, const char *lang, time_t start, time_t stop,
time_t start_extra, time_t stop_extra, dvr_prio_t pri, int retention )
{
char buf[40];
int save = 0;

if (!dvr_entry_is_editable(de))
Expand Down Expand Up @@ -801,6 +802,20 @@ static dvr_entry_t *_dvr_entry_update
de->de_bcast = e;
e->getref(e);
save = 1;

}

/* Episode */
if (de->de_bcast && de->de_bcast->episode) {
if (epg_episode_number_format(de->de_bcast->episode,
buf, sizeof(buf), NULL,
"Season %d", ".", "Episode %d", "/%d")) {
if (strcmp(de->de_episode ?: "", buf)) {
free(de->de_episode);
de->de_episode = strdup(buf);
save = 1;
}
}
}

/* Save changes */
Expand Down Expand Up @@ -861,7 +876,7 @@ dvr_event_replaced(epg_broadcast_t *e, epg_broadcast_t *new_e)
e->putref(e);
de->de_bcast = NULL;

/* If this was craeted by autorec - just remove it, it'll get recreated */
/* If this was created by autorec - just remove it, it'll get recreated */
if (de->de_autorec) {
dvr_entry_destroy(de, 1);

Expand Down Expand Up @@ -1481,21 +1496,6 @@ dvr_entry_class_disp_description_get(void *o)
return &s;
}

static const void *
dvr_entry_class_episode_get(void *o)
{
dvr_entry_t *de = (dvr_entry_t *)o;
static const char *s;
static char buf[100];
s = "";
if (de->de_bcast && de->de_bcast->episode)
if (epg_episode_number_format(de->de_bcast->episode,
buf, sizeof(buf), NULL,
"Season %d", ".", "Episode %d", "/%d"))
s = buf;
return &s;
}

static const void *
dvr_entry_class_url_get(void *o)
{
Expand Down Expand Up @@ -1870,8 +1870,8 @@ const idclass_t dvr_entry_class = {
.type = PT_STR,
.id = "episode",
.name = "Episode",
.get = dvr_entry_class_episode_get,
.opts = PO_RDONLY | PO_NOSAVE | PO_HIDDEN,
.off = offsetof(dvr_entry_t, de_episode),
.opts = PO_RDONLY | PO_HIDDEN,
},
{
.type = PT_STR,
Expand Down

0 comments on commit 6ddbd16

Please sign in to comment.