diff options
author | Matti Lehtimäki <matti.lehtimaki@gmail.com> | 2012-08-31 12:42:02 +0300 |
---|---|---|
committer | Matti Lehtimäki <matti.lehtimaki@gmail.com> | 2012-08-31 12:42:02 +0300 |
commit | 745d6c415c56826ad2ae700beeb1f22341258bab (patch) | |
tree | ac621e56103992f204e12cb54f7d9994e705879d | |
parent | ca254b2a135566a4b666b1c27af9a125b77e4302 (diff) | |
download | vdr-plugin-epgfixer-745d6c415c56826ad2ae700beeb1f22341258bab.tar.gz vdr-plugin-epgfixer-745d6c415c56826ad2ae700beeb1f22341258bab.tar.bz2 |
Support for channel intervals for channel numbers.
Optimisations when using channel IDs.
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | epgfixer/regexp.conf | 4 | ||||
-rw-r--r-- | po/fi_FI.po | 4 | ||||
-rw-r--r-- | tools.c | 82 | ||||
-rw-r--r-- | tools.h | 4 |
5 files changed, 54 insertions, 41 deletions
@@ -59,6 +59,7 @@ General syntax of configuration files: is used. If no list of channels is given the line is used for all channels. - Channel_list can contain either channel IDs (e.g. S19.2E-1-1089-12003-0) or numbers but not both. +- Channel intervals (e.g. 1-10) can be used for channel numbers. Syntax of regexp.conf line is "Channel_list:Parsed_epg_field=Regexp" with: - Parsed_epg_field is the EPG field for which the regular expression is applied diff --git a/epgfixer/regexp.conf b/epgfixer/regexp.conf index ab8bb77..ab36f5d 100644 --- a/epgfixer/regexp.conf +++ b/epgfixer/regexp.conf @@ -2,8 +2,8 @@ #!title=^(?:Movie: |Document: )(?<title>.*)$ # Remove "Movie: " or "Document: " from the beginning of title field for -# channels 1, 3 and 5: -#1,3,5:title=^(?:Movie: |Document: )(?<title>.*)$ +# channels 1, 3, 5, 6 and 7: +#1,3,5-7:title=^(?:Movie: |Document: )(?<title>.*)$ # Also channel IDs can be used: #S19.2E-1-1089-12003-0:title=^(?:Movie: |Document: )(?<title>.*)$ diff --git a/po/fi_FI.po b/po/fi_FI.po index d4b8b00..435193a 100644 --- a/po/fi_FI.po +++ b/po/fi_FI.po @@ -7,14 +7,14 @@ msgid "" msgstr "" "Project-Id-Version: vdr-epgfixer 0.2.0\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2012-05-09 23:25+0300\n" +"POT-Creation-Date: 2012-08-14 13:49+0300\n" "PO-Revision-Date: 2012-05-09 23:20+0300\n" "Last-Translator: Matti Lehtimäki <matti.lehtimaki@gmail.com>\n" "Language-Team: Finnish <vdr@linuxtv.org>\n" +"Language: fi\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: fi\n" msgid "Fix bugs in EPG" msgstr "Korjaa virheitä EPG:ssä" @@ -240,7 +240,7 @@ cListItem::cListItem() string = NULL; numchannels = 0; channels_num = NULL; - channels_str = NULL; + channels_id = NULL; } cListItem::~cListItem(void) @@ -250,24 +250,17 @@ cListItem::~cListItem(void) void cListItem::Free(void) { - if (channels_str) { - int i = 0; - while (i < numchannels) { - free(channels_str[i]); - ++i; - } - } FREE(channels_num); - FREE(channels_str); + FREE(channels_id); FREE(string); numchannels = 0; enabled = false; } -const char *cListItem::GetChannelID(int index) +tChannelID *cListItem::GetChannelID(int index) { - if (channels_str && index >= 0 && index < numchannels) - return channels_str[index]; + if (channels_id && index >= 0 && index < numchannels) + return &channels_id[index]; else return NULL; } @@ -282,53 +275,72 @@ int cListItem::GetChannelNum(int index) bool cListItem::IsActive(tChannelID ChannelID) { - bool active = true; + bool active = false; if (numchannels > 0) { - bool found = false; int i = 0; + int channel_number = Channels.GetByChannelID(ChannelID)->Number(); while (i < numchannels) { - if ((Channels.GetByChannelID(ChannelID)->Number() == GetChannelNum(i)) || - (GetChannelID(i) && strcmp(*(ChannelID.ToString()), GetChannelID(i)) == 0)) { - found = true; + if ((channel_number == GetChannelNum(i)) || + (GetChannelID(i) && (ChannelID == *GetChannelID(i)))) { + active = true; break; } ++i; } - if (!found) - active = false; } + else + active = true; return active; } int cListItem::LoadChannelsFromString(const char *string) { numchannels = 0; - char *tmpstring = strdup(string); - char *c = tmpstring; - while (c) { - ++numchannels; - c = strchr(c+1, ','); - } + bool numbers = false; + if (string != NULL) { + if (atoi(string)) + numbers = true; + char *tmpstring = strdup(string); + char *c = strtok(tmpstring, ","); + while (c) { + ++numchannels; + char *d = 0; + if (numbers && (d = strchr(c, '-')))// only true if numbers are used + numchannels = numchannels + atoi(d+1) - atoi(c); + c = strtok(NULL, ","); + } + free(tmpstring); + } if (numchannels > 0) { - char *c = tmpstring; + char *tmpstring = strdup(string); // Use channel numbers - if (atoi(string)) + if (numbers) channels_num = (int *)malloc(sizeof(int)*numchannels); else// use channel IDs - channels_str = (char **)malloc(sizeof(char *)*numchannels); + channels_id = (tChannelID *)malloc(sizeof(tChannelID)*numchannels); int i = 0; - char *pc = strtok(c, ","); + char *c = strtok(tmpstring, ","); while (i < numchannels) { // Use channel numbers - if (atoi(string)) - channels_num[i] = atoi(pc); - else// use channel IDs - channels_str[i] = strdup(pc); - pc = strtok(NULL, ","); + if (numbers) { + channels_num[i] = atoi(c); + if (char *d = strchr(c, '-')) { + int count = atoi(d+1) - channels_num[i] + 1; + int j = 1; + while (j < count) { + channels_num[i+j] = channels_num[i] + j; + ++j; + } + i = i + count; + } + } + else // use channel IDs + channels_id[i] = tChannelID::FromString(c); + c = strtok(NULL, ","); ++i; } + free(tmpstring); } - free(tmpstring); return numchannels; } @@ -27,10 +27,10 @@ protected: bool enabled; char *string; int *channels_num; - char **channels_str; + tChannelID *channels_id; int numchannels; void Free(); - const char *GetChannelID(int index); + tChannelID *GetChannelID(int index); int GetChannelNum(int index); int LoadChannelsFromString(const char *string); bool IsActive(tChannelID ChannelID); |