Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DVR: Add delimiters format strings (<space>-_.,;) to $t,$s,$e,$c, fix…
…es #2885
  • Loading branch information
perexg committed May 25, 2015
1 parent 86dd49d commit b232b48
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 16 deletions.
7 changes: 7 additions & 0 deletions docs/html/config_dvr.html
Expand Up @@ -134,14 +134,21 @@
<tr><td>$t$n.$x</td><td>Default format (title, unique number, extension)</td><td>Tenis - Wimbledon-1.mkv</td></tr>
<br>
<tr><td>$t</td><td>Event title name</td><td>Tenis - Wimbledon</td></tr>
<tr><td>$s</td><td>Event subtitle name</td><td>Sport</td></tr>
<tr><td>$e</td><td>Event episode name</td><td>S02-E06</td></tr>
<tr><td>$c</td><td>Channel name</td><td>SkySport</td></tr>
<tr><td>$n</td><td>Unique number added when the file already exists&nbsp;&nbsp;&nbsp;&nbsp;</td><td>-1</td></tr>
<tr><td>$x</td><td>Filename extension (from the active stream muxer</td><td>mkv</td></tr>
<br>
<tr><td>%F</td><td>ISO 8601 date format</td><td>2011-03-19</td></tr>
<tr><td>%R</td><td>The time in 24-hour notation</td><td>14:12</td></tr>
</table>

The format strings <i>$t,$s,%e,$c</i> have also delimiter variants like
<i>$ t</i> (space after the dolar character), <i>$-t</i>, <i>$_t</i>,
<i>$.t</i>, <i>$,t</i>, <i>$;t</i>, . In this case, the delimiter is applied
only when the substituted string is not empty.

<br><br>
<hr>
<b>Subdirectory Options</b>
Expand Down
12 changes: 6 additions & 6 deletions src/dvr/dvr_config.c
Expand Up @@ -431,11 +431,11 @@ dvr_update_pathname_from_fmtstr(dvr_config_t *cfg)
cfg->dvr_channel_dir = dvr_match_fmtstr(cfg, "$c/") >= 0;
cfg->dvr_title_dir = dvr_match_fmtstr(cfg, "$t/") >= 0;

cfg->dvr_channel_in_title = dvr_match_fmtstr_nodir(cfg, "$c-") >= 0;
cfg->dvr_channel_in_title = dvr_match_fmtstr_nodir(cfg, "$-c") >= 0;
cfg->dvr_date_in_title = dvr_match_fmtstr_nodir(cfg, "%F") >= 0;
cfg->dvr_time_in_title = dvr_match_fmtstr_nodir(cfg, "%R") >= 0;
cfg->dvr_episode_in_title = dvr_match_fmtstr_nodir(cfg, "$e") >= 0;
cfg->dvr_subtitle_in_title = dvr_match_fmtstr_nodir(cfg, ".$s") >= 0;
cfg->dvr_episode_in_title = dvr_match_fmtstr_nodir(cfg, "$-e") >= 0;
cfg->dvr_subtitle_in_title = dvr_match_fmtstr_nodir(cfg, "$.s") >= 0;

cfg->dvr_omit_title = dvr_match_fmtstr_nodir(cfg, "$t") < 0;
}
Expand All @@ -460,11 +460,11 @@ dvr_update_pathname_from_booleans(dvr_config_t *cfg)
dvr_insert_fmtstr_before_extension(cfg, "$t");
}

dvr_match_and_insert_or_remove(cfg, "$c-", cfg->dvr_channel_in_title, -1);
dvr_match_and_insert_or_remove(cfg, ".$s", cfg->dvr_subtitle_in_title, -1);
dvr_match_and_insert_or_remove(cfg, "$-c", cfg->dvr_channel_in_title, -1);
dvr_match_and_insert_or_remove(cfg, "$.s", cfg->dvr_subtitle_in_title, -1);
dvr_match_and_insert_or_remove(cfg, "%F", cfg->dvr_date_in_title, -1);
dvr_match_and_insert_or_remove(cfg, "%R", cfg->dvr_time_in_title, -1);
dvr_match_and_insert_or_remove(cfg, "$e", cfg->dvr_episode_in_title, -1);
dvr_match_and_insert_or_remove(cfg, "$-e", cfg->dvr_episode_in_title, -1);

dvr_match_and_insert_or_remove(cfg, "$t/", cfg->dvr_title_dir, 0);
dvr_match_and_insert_or_remove(cfg, "$c/", cfg->dvr_channel_dir, 0);
Expand Down
57 changes: 47 additions & 10 deletions src/dvr/dvr_rec.c
Expand Up @@ -20,6 +20,7 @@
#include <pthread.h>
#include <assert.h>
#include <string.h>
#include <ctype.h>
#include <sys/stat.h>
#include <libgen.h> /* basename */

Expand Down Expand Up @@ -89,7 +90,7 @@ dvr_rec_subscribe(dvr_entry_t *de)
tvherror("dvr", "unable to find access (owner '%s', creator '%s')",
de->de_owner, de->de_creator);
return -1;
}
}

if (aa->aa_conn_limit) {
rec_count = dvr_usage_count(aa);
Expand Down Expand Up @@ -220,15 +221,28 @@ cleanup_filename(dvr_config_t *cfg, char *s)
/**
*
*/
static const char *dvr_do_prefix(const char *id, const char *s)
{
static char buf[128];

if (s == NULL)
s = "";
if (s[0] && !isalpha(id[0])) {
snprintf(buf, sizeof(buf), "%c%s", id[0], s);
return buf;
}
return s;
}


static const char *dvr_sub_title(const char *id, const void *aux)
{
return lang_str_get(((dvr_entry_t *)aux)->de_title, NULL) ?: "";
return dvr_do_prefix(id, lang_str_get(((dvr_entry_t *)aux)->de_title, NULL));
}

static const char *dvr_sub_subtitle(const char *id, const void *aux)
{
return lang_str_get(((dvr_entry_t *)aux)->de_subtitle, NULL) ?: "";
return dvr_do_prefix(id, lang_str_get(((dvr_entry_t *)aux)->de_subtitle, NULL));
}

static const char *dvr_sub_episode(const char *id, const void *aux)
Expand All @@ -241,20 +255,43 @@ static const char *dvr_sub_episode(const char *id, const void *aux)
epg_episode_number_format(de->de_bcast->episode,
buf, sizeof(buf),
".", "S%02d", NULL, "E%02d", NULL);
return buf;
return dvr_do_prefix(id, buf);
}

static const char *dvr_sub_channel(const char *id, const void *aux)
{
return DVR_CH_NAME((dvr_entry_t *)aux);
return dvr_do_prefix(id, DVR_CH_NAME((dvr_entry_t *)aux));
}


static str_substitute_t dvr_subs_entry[] = {
{ .id = "t", .getval = dvr_sub_title },
{ .id = "s", .getval = dvr_sub_subtitle },
{ .id = "e", .getval = dvr_sub_episode },
{ .id = "c", .getval = dvr_sub_channel },
{ .id = "t", .getval = dvr_sub_title },
{ .id = " t", .getval = dvr_sub_title },
{ .id = "-t", .getval = dvr_sub_title },
{ .id = "_t", .getval = dvr_sub_title },
{ .id = ".t", .getval = dvr_sub_title },
{ .id = ",t", .getval = dvr_sub_title },
{ .id = ";t", .getval = dvr_sub_title },
{ .id = "s", .getval = dvr_sub_subtitle },
{ .id = " s", .getval = dvr_sub_subtitle },
{ .id = "-s", .getval = dvr_sub_subtitle },
{ .id = "_s", .getval = dvr_sub_subtitle },
{ .id = ".s", .getval = dvr_sub_subtitle },
{ .id = ",s", .getval = dvr_sub_subtitle },
{ .id = ";s", .getval = dvr_sub_subtitle },
{ .id = "e", .getval = dvr_sub_episode },
{ .id = " e", .getval = dvr_sub_episode },
{ .id = "-e", .getval = dvr_sub_episode },
{ .id = "_e", .getval = dvr_sub_episode },
{ .id = ".e", .getval = dvr_sub_episode },
{ .id = ",e", .getval = dvr_sub_episode },
{ .id = ";e", .getval = dvr_sub_episode },
{ .id = "c", .getval = dvr_sub_channel },
{ .id = " c", .getval = dvr_sub_channel },
{ .id = "-c", .getval = dvr_sub_channel },
{ .id = "_c", .getval = dvr_sub_channel },
{ .id = ".c", .getval = dvr_sub_channel },
{ .id = ",c", .getval = dvr_sub_channel },
{ .id = ";c", .getval = dvr_sub_channel },
{ .id = NULL, .getval = NULL }
};

Expand Down

0 comments on commit b232b48

Please sign in to comment.