]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Add '[ ] Remove all unsafe characters from filename' checkbox for DVR recordings.
authorAndreas Öman <andreas@lonelycoder.com>
Thu, 19 Aug 2010 19:40:25 +0000 (19:40 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Thu, 19 Aug 2010 19:40:25 +0000 (19:40 +0000)
Good if you are on a CIFS share or anything else from the 1980's

Ticket #231

src/dvr/dvr.h
src/dvr/dvr_db.c
src/webui/extjs.c
src/webui/static/app/dvr.js

index 9413a0c6f1dbdc89f31f5ca37edc0644acee972a..5d08abc2b8f5cca611c7ad9dc56b2166207e919e 100644 (file)
@@ -42,6 +42,7 @@ extern struct dvr_entry_list dvrentries;
 #define DVR_WHITESPACE_IN_TITLE        0x20
 #define DVR_DIR_PER_TITLE      0x40
 #define DVR_EPISODE_IN_TITLE   0x80
+#define DVR_CLEAN_TITLE        0x100
 
 typedef enum {
   DVR_PRIO_IMPORTANT,
index 2ffa3c34991025c60c08ee9bfd009dd6598fff13..7b12410265e842b7558a5461da3e4df320e11947 100644 (file)
@@ -154,6 +154,7 @@ dvr_make_title(char *output, size_t outlen, dvr_entry_t *de)
 {
   struct tm tm;
   char buf[40];
+  int i;
 
   if(dvr_flags & DVR_CHANNEL_IN_TITLE)
     snprintf(output, outlen, "%s-", de->de_channel->ch_name);
@@ -187,6 +188,19 @@ dvr_make_title(char *output, size_t outlen, dvr_entry_t *de)
               ".E%02d",
               de->de_episode.ee_episode);
   }
+
+  if(dvr_flags & DVR_CLEAN_TITLE) {
+        for (i=0;i<strlen(output);i++) {
+                if (
+                        output[i]<32 ||
+                        output[i]>122 ||
+                        output[i]==34 ||
+                        output[i]==39 ||
+                        output[i]==92 ||
+                        output[i]==58
+                        ) output[i]='_';
+        }
+  }
 }
 
 
index b22e88c25c78618be789a5e77ad81545f767816c..b7276d97b728f73e33ded1f8539a7672cf7130f7 100644 (file)
@@ -820,6 +820,7 @@ extjs_dvr(http_connection_t *hc, const char *remain, void *opaque)
     htsmsg_add_u32(r, "whitespaceInTitle", !!(dvr_flags & DVR_WHITESPACE_IN_TITLE));
     htsmsg_add_u32(r, "titleDirs", !!(dvr_flags & DVR_DIR_PER_TITLE));
     htsmsg_add_u32(r, "episodeInTitle", !!(dvr_flags & DVR_EPISODE_IN_TITLE));
+    htsmsg_add_u32(r, "cleanTitle", !!(dvr_flags & DVR_CLEAN_TITLE));
 
     out = json_single_record(r, "dvrSettings");
 
@@ -846,6 +847,8 @@ extjs_dvr(http_connection_t *hc, const char *remain, void *opaque)
       flags |= DVR_DIR_PER_CHANNEL;
     if(http_arg_get(&hc->hc_req_args, "channelInTitle") != NULL)
       flags |= DVR_CHANNEL_IN_TITLE;
+    if(http_arg_get(&hc->hc_req_args, "cleanTitle") != NULL)
+      flags |= DVR_CLEAN_TITLE;
     if(http_arg_get(&hc->hc_req_args, "dateInTitle") != NULL)
       flags |= DVR_DATE_IN_TITLE;
     if(http_arg_get(&hc->hc_req_args, "timeInTitle") != NULL)
index 7121138f7a88695e81b16d929689fdfe820dcf21..5b58ba13763b73f519fbb5033b3acfa9a141bab3 100644 (file)
@@ -566,7 +566,7 @@ tvheadend.dvrsettings = function() {
        'channelDirs','channelInTitle',
        'dateInTitle','timeInTitle',
        'preExtraTime', 'postExtraTime', 'whitespaceInTitle', 
-       'titleDirs', 'episodeInTitle']);
+       'titleDirs', 'episodeInTitle','cleanTitle']);
 
     var confpanel = new Ext.FormPanel({
        title:'Digital Video Recorder',
@@ -610,6 +610,9 @@ tvheadend.dvrsettings = function() {
        }), new Ext.form.Checkbox({
            fieldLabel: 'Include channel name in filename',
            name: 'channelInTitle'
+       }), new Ext.form.Checkbox({
+           fieldLabel: 'Remove all unsafe characters from filename',
+           name: 'cleanTitle'
        }), new Ext.form.Checkbox({
            fieldLabel: 'Include date in filename',
            name: 'dateInTitle'