From 22ccf22f6f4c2dd94e322f0aebf134a90b310fae Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 2 Sep 2001 15:21:54 +0200 Subject: [PATCH] Using subtitle for repeating timers; taking summary at recording time --- HISTORY | 15 +++++++++++++++ MANUAL | 14 ++++++++++++++ config.c | 20 ++++---------------- config.h | 3 ++- i18n.c | 11 ++++++++++- menu.c | 13 ++++++++----- recording.c | 25 +++++++++++++++++++------ recording.h | 4 ++-- videodir.c | 22 +++++++++++++++------- 9 files changed, 89 insertions(+), 38 deletions(-) diff --git a/HISTORY b/HISTORY index 7ea886d3..90aace92 100644 --- a/HISTORY +++ b/HISTORY @@ -701,3 +701,18 @@ Video Disk Recorder Revision History been chosen since the file system's directory delimiter '/' may be part of a regular programme name (showing the directory hierarchy in the "Recordings" menu will follow later). +- Repeating timers now create recordings that contain the 'Subtitle' information + from the EPG data in their file name. Typically (on tv stations that care + about their viewers) this contains the episode title of a series. The + subtitle is appended to the timer's file name, separated by a '~' character, + so that it results in all recordings of this timer being collected in a + common subdirectory. You can disable this with the 'UseSubtitle' parameter + in the "Setup" menu. +- The summary information is now taken from the EPG data at the actual time of + recording (no longer at the time the timer is created in the "Schedule" menu). + If a timer already has summary data, that data will be used. If you have + repeating timers in your 'timers.conf', you may want to make sure they do + NOT contain any summary information (that's the last field in the timer + definitions). Use your favourite text editor to delete that information. + That way every recording will store the actual summary data at the time of + the recording. diff --git a/MANUAL b/MANUAL index 2645f681..c6b5efd7 100644 --- a/MANUAL +++ b/MANUAL @@ -291,6 +291,12 @@ Video Disk Recorder User's Manual structure "/video/Sci-Fi/Star_Trek/Voyager". The '~' character has been chosen for this since the file system's directory delimiter '/' may be part of a regular programme name. + Repeating timers create recordings that contain the 'Subtitle' + information from the EPG data in their file name. Typically (on tv + stations that care about their viewers) this contains the episode + title of a series. The subtitle is appended to the timer's file name, + separated by a '~' character, so that it results in all recordings + of this timer being collected in a common subdirectory. If this field is left blank, the channel name will be used to form the name of the recording. @@ -408,6 +414,14 @@ Video Disk Recorder User's Manual means that this recording will never be deleted automatically. + UseSubtitle = 1 Repeating timers use the EPG's 'Subtitle' information to + create recording file names in a hierarchical structure + (for instance to gather all episodes of a series in a + common subdirectory). This parameter can be used to + control this. + 0 = don't use the 'Subtitle' + 1 = use it (and create subdirectories) + VideoFormat = 0 The video format (or aspect ratio) of the tv set in use. 0 = 4:3 1 = 16:9 diff --git a/config.c b/config.c index fa9e3641..a97d7e4c 100644 --- a/config.c +++ b/config.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.c 1.63 2001/09/01 15:17:44 kls Exp $ + * $Id: config.c 1.64 2001/09/02 15:04:13 kls Exp $ */ #include "config.h" @@ -365,21 +365,6 @@ cTimer::cTimer(const cEventInfo *EventInfo) if (!isempty(Title)) strn0cpy(file, EventInfo->GetTitle(), sizeof(file)); summary = NULL; - const char *Subtitle = EventInfo->GetSubtitle(); - if (isempty(Subtitle)) - Subtitle = ""; - const char *Summary = EventInfo->GetExtendedDescription(); - if (isempty(Summary)) - Summary = ""; - if (*Subtitle || *Summary) { - asprintf(&summary, "%s%s%s", Subtitle, (*Subtitle && *Summary) ? "\n\n" : "", Summary); - char *p = summary; - while (*p) { - if (*p == '\n') - *p = '|'; - p++; - } - } } cTimer::~cTimer() @@ -815,6 +800,7 @@ cSetup::cSetup(void) PrimaryLimit = 0; DefaultPriority = 50; DefaultLifetime = 50; + UseSubtitle = 1; VideoFormat = VIDEO_FORMAT_4_3; ChannelInfoPos = 0; OSDwidth = 52; @@ -851,6 +837,7 @@ bool cSetup::Parse(char *s) else if (!strcasecmp(Name, "PrimaryLimit")) PrimaryLimit = atoi(Value); else if (!strcasecmp(Name, "DefaultPriority")) DefaultPriority = atoi(Value); else if (!strcasecmp(Name, "DefaultLifetime")) DefaultLifetime = atoi(Value); + else if (!strcasecmp(Name, "UseSubtitle")) UseSubtitle = atoi(Value); else if (!strcasecmp(Name, "VideoFormat")) VideoFormat = atoi(Value); else if (!strcasecmp(Name, "ChannelInfoPos")) ChannelInfoPos = atoi(Value); else if (!strcasecmp(Name, "OSDwidth")) OSDwidth = atoi(Value); @@ -922,6 +909,7 @@ bool cSetup::Save(const char *FileName) fprintf(f, "PrimaryLimit = %d\n", PrimaryLimit); fprintf(f, "DefaultPriority = %d\n", DefaultPriority); fprintf(f, "DefaultLifetime = %d\n", DefaultLifetime); + fprintf(f, "UseSubtitle = %d\n", UseSubtitle); fprintf(f, "VideoFormat = %d\n", VideoFormat); fprintf(f, "ChannelInfoPos = %d\n", ChannelInfoPos); fprintf(f, "OSDwidth = %d\n", OSDwidth); diff --git a/config.h b/config.h index b13cd19b..e1aecc8a 100644 --- a/config.h +++ b/config.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.h 1.70 2001/09/01 15:16:42 kls Exp $ + * $Id: config.h 1.71 2001/09/02 15:03:19 kls Exp $ */ #ifndef __CONFIG_H @@ -292,6 +292,7 @@ public: int SortTimers; int PrimaryLimit; int DefaultPriority, DefaultLifetime; + int UseSubtitle; int VideoFormat; int ChannelInfoPos; int OSDwidth, OSDheight; diff --git a/i18n.c b/i18n.c index 1387b85b..086d85a3 100644 --- a/i18n.c +++ b/i18n.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: i18n.c 1.38 2001/09/01 15:20:45 kls Exp $ + * $Id: i18n.c 1.39 2001/09/02 15:17:33 kls Exp $ * * Slovenian translations provided by Miha Setina * Italian translations provided by Alberto Carraro @@ -857,6 +857,15 @@ const tPhrase Phrases[] = { "Durée de vie par défaut", "Normal levetid (Timer)", }, + { "UseSubtitle", + "Subtitle verwenden", + "", // TODO + "", // TODO + "", // TODO + "", // TODO + "", // TODO + "", // TODO + }, { "VideoFormat", "Video Format", "", // TODO diff --git a/menu.c b/menu.c index 1f4e8674..5c32bb09 100644 --- a/menu.c +++ b/menu.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 1.113 2001/09/02 10:00:40 kls Exp $ + * $Id: menu.c 1.114 2001/09/02 15:04:41 kls Exp $ */ #include "menu.h" @@ -1727,6 +1727,7 @@ void cMenuSetup::Set(void) Add(new cMenuEditIntItem( tr("PrimaryLimit"), &data.PrimaryLimit, 0, MAXPRIORITY)); Add(new cMenuEditIntItem( tr("DefaultPriority"), &data.DefaultPriority, 0, MAXPRIORITY)); Add(new cMenuEditIntItem( tr("DefaultLifetime"), &data.DefaultLifetime, 0, MAXLIFETIME)); + Add(new cMenuEditBoolItem(tr("UseSubtitle"), &data.UseSubtitle)); Add(new cMenuEditBoolItem(tr("VideoFormat"), &data.VideoFormat, "4:3", "16:9")); Add(new cMenuEditBoolItem(tr("ChannelInfoPos"), &data.ChannelInfoPos, tr("bottom"), tr("top"))); Add(new cMenuEditIntItem( tr("OSDwidth"), &data.OSDwidth, MINOSDWIDTH, MAXOSDWIDTH)); @@ -2100,12 +2101,14 @@ cRecordControl::cRecordControl(cDvbApi *DvbApi, cTimer *Timer) timer->SetPending(true); timer->SetRecording(true); if (Channels.SwitchTo(timer->channel, dvbApi)) { + const char *Subtitle = NULL; + const char *Summary = NULL; if (GetEventInfo()) { - //XXX this is in preparation for storing recordings in subdirectories and giving them the name of the Subtitle - dsyslog(LOG_INFO, "Title: '%s' Subtitle: '%s'", eventInfo->GetTitle(), eventInfo->GetSubtitle());//XXX - //XXX modify timer's name and summary, mark it as modified (revert later when stopping) + dsyslog(LOG_INFO, "Title: '%s' Subtitle: '%s'", eventInfo->GetTitle(), eventInfo->GetSubtitle()); + Subtitle = eventInfo->GetSubtitle(); + Summary = eventInfo->GetExtendedDescription(); } - cRecording Recording(timer); + cRecording Recording(timer, Subtitle, Summary); if (dvbApi->StartRecord(Recording.FileName(), Channels.GetByNumber(timer->channel)->ca, timer->priority)) Recording.WriteSummary(); Interface->DisplayRecording(dvbApi->CardIndex(), true); diff --git a/recording.c b/recording.c index c98d5252..f6573781 100644 --- a/recording.c +++ b/recording.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.c 1.35 2001/09/02 10:25:12 kls Exp $ + * $Id: recording.c 1.36 2001/09/02 15:09:28 kls Exp $ */ #define _GNU_SOURCE @@ -204,19 +204,32 @@ char *ExchangeChars(char *s, bool ToFileSystem) return s; } -cRecording::cRecording(cTimer *Timer) +cRecording::cRecording(cTimer *Timer, const char *Subtitle, const char *Summary) { titleBuffer = NULL; fileName = NULL; - name = strdup(Timer->file); + if (Timer->IsSingleEvent() || !Setup.UseSubtitle) + name = strdup(Timer->file); + else { + if (isempty(Subtitle)) + Subtitle = " "; + asprintf(&name, "%s~%s", Timer->file, Subtitle); + } // substitute characters that would cause problems in file names: strreplace(name, '\n', ' '); - summary = Timer->summary ? strdup(Timer->summary) : NULL; - if (summary) - strreplace(summary, '|', '\n'); start = Timer->StartTime(); priority = Timer->priority; lifetime = Timer->lifetime; + // handle summary: + summary = !isempty(Timer->summary) ? strdup(Timer->summary) : NULL; + if (!summary) { + if (isempty(Subtitle)) + Subtitle = ""; + if (isempty(Summary)) + Summary = ""; + if (*Subtitle || *Summary) + asprintf(&summary, "%s%s%s", Subtitle, (*Subtitle && *Summary) ? "\n\n" : "", Summary); + } } cRecording::cRecording(const char *FileName) diff --git a/recording.h b/recording.h index 87cf8395..e1af3db3 100644 --- a/recording.h +++ b/recording.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.h 1.15 2001/09/01 12:58:02 kls Exp $ + * $Id: recording.h 1.16 2001/09/02 11:35:56 kls Exp $ */ #ifndef __RECORDING_H @@ -39,7 +39,7 @@ public: time_t start; int priority; int lifetime; - cRecording(cTimer *Timer); + cRecording(cTimer *Timer, const char *Subtitle, const char *Summary); cRecording(const char *FileName); ~cRecording(); const char *FileName(void); diff --git a/videodir.c b/videodir.c index 6f35a3dc..d9d3f852 100644 --- a/videodir.c +++ b/videodir.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: videodir.c 1.5 2001/05/01 09:48:57 kls Exp $ + * $Id: videodir.c 1.6 2001/09/02 14:55:15 kls Exp $ */ #include "videodir.h" @@ -188,13 +188,21 @@ const char *PrefixVideoFileName(const char *FileName, char Prefix) if (!PrefixedName || strlen(PrefixedName) <= strlen(FileName)) PrefixedName = (char *)realloc(PrefixedName, strlen(FileName) + 2); if (PrefixedName) { - strcpy(PrefixedName, VideoDirectory); - char *p = PrefixedName + strlen(PrefixedName); - *p++ = '/'; - *p++ = Prefix; - strcpy(p, FileName + strlen(VideoDirectory) + 1); + const char *p = FileName + strlen(FileName); // p points at the terminating 0 + int n = 2; + while (p-- > FileName && n > 0) { + if (*p == '/') { + if (--n == 0) { + int l = p - FileName + 1; + strncpy(PrefixedName, FileName, l); + PrefixedName[l] = Prefix; + strcpy(PrefixedName + l + 1, p + 1); + return PrefixedName; + } + } + } } - return PrefixedName; + return NULL; } void RemoveEmptyVideoDirectories(void)