Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DVR: Add episode check to the fuzzy EPG match
  • Loading branch information
perexg committed Dec 12, 2014
1 parent a609cd2 commit c6d2a09
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions src/dvr/dvr_db.c
Expand Up @@ -331,6 +331,21 @@ dvr_entry_set_timer(dvr_entry_t *de)
}


/**
* Get episode name
*/
static char *
dvr_entry_get_episode(epg_broadcast_t *bcast, char *buf, int len)
{
if (!bcast || !bcast->episode)
return NULL;
if (epg_episode_number_format(bcast->episode,
buf, len, NULL,
"Season %d", ".", "Episode %d", "/%d"))
return buf;
return NULL;
}

/**
* Find dvr entry using 'fuzzy' search
*/
Expand All @@ -339,6 +354,7 @@ dvr_entry_fuzzy_match(dvr_entry_t *de, epg_broadcast_t *e)
{
time_t t1, t2;
const char *title1, *title2;
char buf[64];

/* Matching ID */
if (de->de_dvb_eid && de->de_dvb_eid == e->dvb_eid)
Expand All @@ -357,26 +373,19 @@ dvr_entry_fuzzy_match(dvr_entry_t *de, epg_broadcast_t *e)
return 0;

/* Outside of window */
if ( abs(e->start - de->de_start) > de->de_config->dvr_update_window )
if (abs(e->start - de->de_start) > de->de_config->dvr_update_window)
return 0;

/* Title match (or contains?) */
return strcmp(title1, title2) == 0;
}
if (strcmp(title1, title2))
return 0;

/**
* Set episode name
*/
static char *
dvr_entry_get_episode(epg_broadcast_t *bcast, char *buf, int len)
{
if (!bcast || !bcast->episode)
return NULL;
if (epg_episode_number_format(bcast->episode,
buf, len, NULL,
"Season %d", ".", "Episode %d", "/%d"))
return buf;
return NULL;
/* episode check */
if (dvr_entry_get_episode(e, buf, sizeof(buf)) && de->de_episode)
if (strcmp(buf, de->de_episode))
return 0;

return 1;
}

/**
Expand Down

0 comments on commit c6d2a09

Please sign in to comment.