diff options
Diffstat (limited to 'src/vdr-plugin')
-rw-r--r-- | src/vdr-plugin/common.c | 15 | ||||
-rw-r--r-- | src/vdr-plugin/common.h | 10 | ||||
-rw-r--r-- | src/vdr-plugin/config.c | 10 | ||||
-rw-r--r-- | src/vdr-plugin/config.h | 4 | ||||
-rw-r--r-- | src/vdr-plugin/request.c | 2 | ||||
-rw-r--r-- | src/vdr-plugin/webvideo.c | 11 |
6 files changed, 44 insertions, 8 deletions
diff --git a/src/vdr-plugin/common.c b/src/vdr-plugin/common.c index 5ad2747..17a73b0 100644 --- a/src/vdr-plugin/common.c +++ b/src/vdr-plugin/common.c @@ -194,9 +194,20 @@ char *URLdecode(const char *s) { return res; } -char *safeFilename(char *filename) { +char *safeFilename(char *filename, bool vfatnames) { if (filename) { - strreplace(filename, '/', '!'); + strreplace(filename, '/', '_'); + + if (vfatnames) { + strreplace(filename, '\\', '_'); + strreplace(filename, '"', '_'); + strreplace(filename, '*', '_'); + strreplace(filename, ':', '_'); + strreplace(filename, '<', '_'); + strreplace(filename, '>', '_'); + strreplace(filename, '?', '_'); + strreplace(filename, '|', '_'); + } char *p = filename; while ((*p == '.') || isspace(*p)) { diff --git a/src/vdr-plugin/common.h b/src/vdr-plugin/common.h index 90dfb5f..8443081 100644 --- a/src/vdr-plugin/common.h +++ b/src/vdr-plugin/common.h @@ -36,10 +36,12 @@ char *URLencode(const char *s); // Remove URL encoding from s. The called must free the returned // memory. char *URLdecode(const char *s); -// Return a "safe" version of filename. Remove path (replace '/' with -// '!') and dots from the beginning. The string is modified in-place, -// i.e. returns the pointer filename that was passed as argument. -char *safeFilename(char *filename); +// Return a "safe" version of filename. Replace '/' with '_' and +// remove dots from the beginning. If vfatnames is true, replace also +// other characters which are not allowed on VFAT. The string is +// modified in-place, i.e. returns the pointer filename that was +// passed as argument. +char *safeFilename(char *filename, bool vfatnames); // Escape s so that it can be passed as parameter to a shell command. cString shellEscape(const char *s); // Convert string s to lower case diff --git a/src/vdr-plugin/config.c b/src/vdr-plugin/config.c index 81bdb3e..8bc3fde 100644 --- a/src/vdr-plugin/config.c +++ b/src/vdr-plugin/config.c @@ -64,6 +64,7 @@ cWebvideoConfig::cWebvideoConfig() { templatePath = NULL; preferXine = true; postProcessCmd = NULL; + vfatNames = false; } cWebvideoConfig::~cWebvideoConfig() { @@ -216,3 +217,12 @@ void cWebvideoConfig::SetPostProcessCmd(const char *cmd) { const char *cWebvideoConfig::GetPostProcessCmd() { return postProcessCmd; } + +void cWebvideoConfig::SetUseVFATNames(bool vfat) { + vfatNames = vfat; +} + +bool cWebvideoConfig::GetUseVFATNames() { + return vfatNames; +} + diff --git a/src/vdr-plugin/config.h b/src/vdr-plugin/config.h index fd541b3..ccda574 100644 --- a/src/vdr-plugin/config.h +++ b/src/vdr-plugin/config.h @@ -36,6 +36,7 @@ private: char *templatePath; char *postProcessCmd; bool preferXine; + bool vfatNames; cList<cDownloadQuality> downloadLimits; cList<cDownloadQuality> streamLimits; @@ -56,6 +57,9 @@ public: void SetPreferXineliboutput(bool pref); bool GetPreferXineliboutput(); + void SetUseVFATNames(bool vfat); + bool GetUseVFATNames(); + const char *GetMinQuality(const char *site, eRequestType type); const char *GetMaxQuality(const char *site, eRequestType type); diff --git a/src/vdr-plugin/request.c b/src/vdr-plugin/request.c index 00297f7..0d1abf1 100644 --- a/src/vdr-plugin/request.c +++ b/src/vdr-plugin/request.c @@ -320,7 +320,7 @@ bool cFileDownloadRequest::OpenDestFile() { const char *destdir = webvideoConfig->GetDownloadPath(); char *basename = strdup(title ? title : "???"); - basename = safeFilename(basename); + basename = safeFilename(basename, webvideoConfig->GetUseVFATNames()); i = 1; filename = cString::sprintf("%s/%s%s", destdir, basename, ext); diff --git a/src/vdr-plugin/webvideo.c b/src/vdr-plugin/webvideo.c index 02f007a..0f985fc 100644 --- a/src/vdr-plugin/webvideo.c +++ b/src/vdr-plugin/webvideo.c @@ -39,6 +39,7 @@ private: cString conffile; cString postprocesscmd; bool prefermplayer; + bool vfatnames; static int nextMenuID; @@ -79,6 +80,7 @@ cPluginWebvideo::cPluginWebvideo(void) // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT! prefermplayer = false; + vfatnames = false; } cPluginWebvideo::~cPluginWebvideo() @@ -94,6 +96,7 @@ const char *cPluginWebvideo::CommandLineHelp(void) " -t DIR, --templatedir=DIR Read video site templates from DIR\n" \ " -c FILE, --conf=FILE Load settings from FILE\n" \ " -p CMD, --postprocess=CMD Execute CMD after downloading\n" \ + " --vfat Generate Windows compatible filenames\n" \ " -m, --prefermplayer Prefer mplayer over xineliboutput when streaming\n"; } @@ -106,11 +109,12 @@ bool cPluginWebvideo::ProcessArgs(int argc, char *argv[]) { "conf", required_argument, NULL, 'c' }, { "postprocess", required_argument, NULL, 'p' }, { "prefermplayer", no_argument, NULL, 'm' }, + { "vfat", no_argument, NULL, 'v' }, { NULL } }; int c; - while ((c = getopt_long(argc, argv, "d:t:c:p:m", long_options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "d:t:c:p:mv", long_options, NULL)) != -1) { switch (c) { case 'd': destdir = cString(optarg); @@ -127,6 +131,9 @@ bool cPluginWebvideo::ProcessArgs(int argc, char *argv[]) case 'm': prefermplayer = true; break; + case 'v': + vfatnames = true; + break; default: return false; } @@ -157,6 +164,8 @@ bool cPluginWebvideo::Initialize(void) webvideoConfig->SetPostProcessCmd(postprocesscmd); if (prefermplayer) webvideoConfig->SetPreferXineliboutput(false); + if (vfatnames) + webvideoConfig->SetUseVFATNames(vfatnames); cString mymimetypes = AddDirectory(ConfigDirectory(Name()), "mime.types"); const char *mimefiles [] = {"/etc/mime.types", (const char *)mymimetypes, NULL}; |