diff options
Diffstat (limited to 'plugins/profiler')
-rw-r--r-- | plugins/profiler/vdrDVBProfiler/channelTitle.conf | 23 | ||||
-rw-r--r-- | plugins/profiler/vdrDVBProfiler/dvbProfiler.cpp | 42 |
2 files changed, 48 insertions, 17 deletions
diff --git a/plugins/profiler/vdrDVBProfiler/channelTitle.conf b/plugins/profiler/vdrDVBProfiler/channelTitle.conf index eccea7a..598c667 100644 --- a/plugins/profiler/vdrDVBProfiler/channelTitle.conf +++ b/plugins/profiler/vdrDVBProfiler/channelTitle.conf @@ -2,5 +2,26 @@ # %chan% - replaced with the channel name # %no% - replaced with the channel number # %title% - replaced with the event title +# +# You may add a delimiter to the variable: +# +# %- |title% - this will add "- " to the output +# if and only if the title is not +# empty. +# +# The default pattern is: %no% %chan% %- |title% +# +# This will produce for instance +# +# 102 arte +# +# or if the title is not empty: +# +# 102 arte - New York +# +# Please report required variables on +# http://projects.vdr-developer.org/projects/plg-upnp +# +# Thank you. -%no% %chan%: %title%
\ No newline at end of file +%no% %chan% %- |title%
\ No newline at end of file diff --git a/plugins/profiler/vdrDVBProfiler/dvbProfiler.cpp b/plugins/profiler/vdrDVBProfiler/dvbProfiler.cpp index 1caaf8b..333f773 100644 --- a/plugins/profiler/vdrDVBProfiler/dvbProfiler.cpp +++ b/plugins/profiler/vdrDVBProfiler/dvbProfiler.cpp @@ -46,7 +46,7 @@ private: public: ChannelTitle() : channelNo(-1) - , pattern("%chan% - %title%") + , pattern("%chan% %- |title%") {} void Clear(){ channelNo = -1; @@ -57,21 +57,31 @@ public: void SetChannelName(const string& name){ channelName = name; } void SetTitle(const string& t){ title = t; } string ToString(){ - string output = pattern; - if(channelNo > 0) - replaceAll(output, "%no%", tools::ToString(channelNo)); - else - replaceAll(output, "%no%", ""); - if(!channelName.empty()) - replaceAll(output, "%chan%", channelName); - else - replaceAll(output, "%chan%", ""); - if(!title.empty()) - replaceAll(output, "%title%", title); - else - replaceAll(output, "%title%", ""); - - return output; + stringstream output; + + size_t startPos = 0, endPos = 0, delim = 0; + string delimiter, var; + while((startPos = pattern.find_first_of('%', startPos)) != string::npos){ + // Copy the content from endPos to startPos + output << pattern.substr(endPos + 1, startPos - endPos - (endPos > 0 ? 1 : 0 )); + if((endPos = pattern.find_first_of('%', startPos+1)) != string::npos){ + if((delim = pattern.find_first_of('|', startPos+1)) != string::npos && delim < endPos){ + delimiter = pattern.substr(startPos + 1, delim - startPos - 1); + startPos = delim; + } + var = pattern.substr(startPos + 1, endPos - startPos - 1); + if (var.compare("no") == 0 && channelNo > 0){ + output << delimiter << channelNo; + } else if(var.compare("chan") == 0 && !channelName.empty()){ + output << delimiter << channelName; + } else if(var.compare("title") == 0 && !title.empty()){ + output << delimiter << title; + } + } + startPos = endPos + 1; + } + + return output.str(); } bool Parse(const char* str){ if(!str || strcmp(str, "") == 0){ |