From: Jaroslav Kysela Date: Mon, 25 May 2015 07:35:34 +0000 (+0200) Subject: DVR: Add delimiters format strings (-_.,;) to $t,$s,$e,$c, fixes #2885 X-Git-Tag: v4.2.1~2476 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b232b48b2f3a0a7edf5caf0745191fbd0f8e9d47;p=thirdparty%2Ftvheadend.git DVR: Add delimiters format strings (-_.,;) to $t,$s,$e,$c, fixes #2885 --- diff --git a/docs/html/config_dvr.html b/docs/html/config_dvr.html index ff130d40f..75188ea64 100644 --- a/docs/html/config_dvr.html +++ b/docs/html/config_dvr.html @@ -134,7 +134,9 @@ $t$n.$xDefault format (title, unique number, extension)Tenis - Wimbledon-1.mkv
$tEvent title nameTenis - Wimbledon + $sEvent subtitle nameSport $eEvent episode nameS02-E06 + $cChannel nameSkySport $nUnique number added when the file already exists    -1 $xFilename extension (from the active stream muxermkv
@@ -142,6 +144,11 @@ %RThe time in 24-hour notation14:12 + The format strings $t,$s,%e,$c have also delimiter variants like + $ t (space after the dolar character), $-t, $_t, + $.t, $,t, $;t, . In this case, the delimiter is applied + only when the substituted string is not empty. +


Subdirectory Options diff --git a/src/dvr/dvr_config.c b/src/dvr/dvr_config.c index 565182519..007204f4f 100644 --- a/src/dvr/dvr_config.c +++ b/src/dvr/dvr_config.c @@ -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; } @@ -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); diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index c72e63810..900903a80 100644 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include /* basename */ @@ -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); @@ -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) @@ -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 } };