From 2d3702b8507361c3c9f17fe290fc1d6af0cef983 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 22 May 2005 10:43:10 +0200 Subject: [PATCH] Fall back to 'summary.vdr' if there is no 'info.vdr' --- HISTORY | 3 ++- recording.c | 55 +++++++++++++++++++++++++++++++++++++++++++++---- recording.h | 4 ++-- summary2info.pl | 4 ++-- 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/HISTORY b/HISTORY index c20d1318..44ba0212 100644 --- a/HISTORY +++ b/HISTORY @@ -3533,7 +3533,8 @@ Video Disk Recorder Revision History summary2info.pl /video - (the parameter given has to be the video directory). + (the parameter given has to be the video directory). If there is no 'info.vdr' + file for a recording, an attempt is made to read a 'summary.vdr'. - The "Summary" button in the "Recordings" menu has been renamed to "Info", and the page it brings up now shows the recording's information, much like the EPG event page. Therefore it now no longer uses the skin's SetText() function, but diff --git a/recording.c b/recording.c index a946fca4..347962bf 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.101 2005/05/22 09:13:26 kls Exp $ + * $Id: recording.c 1.102 2005/05/22 10:43:10 kls Exp $ */ #include "recording.h" @@ -23,6 +23,8 @@ #include "tools.h" #include "videodir.h" +#define SUMMARYFALLBACK + #define RECEXT ".rec" #define DELEXT ".del" /* This was the original code, which works fine in a Linux only environment. @@ -45,6 +47,9 @@ // end of implementation for brain dead systems #define RESUMEFILESUFFIX "/resume%s%s.vdr" +#ifdef SUMMARYFALLBACK +#define SUMMARYFILESUFFIX "/summary.vdr" +#endif #define INFOFILESUFFIX "/info.vdr" #define MARKSFILESUFFIX "/marks.vdr" @@ -230,10 +235,12 @@ cRecordingInfo::~cRecordingInfo() delete ownEvent; } -void cRecordingInfo::SetTitleAndDescription(const char *Title, const char *Description) +void cRecordingInfo::SetData(const char *Title, const char *ShortText, const char *Description) { - if (isempty(event->Title()) && !isempty(Title)) + if (!isempty(Title)) ((cEvent *)event)->SetTitle(Title); + if (!isempty(ShortText)) + ((cEvent *)event)->SetShortText(ShortText); if (!isempty(Description)) ((cEvent *)event)->SetDescription(Description); } @@ -422,7 +429,7 @@ cRecording::cRecording(cTimer *Timer, const cEvent *Event) // timer into the recording info, but it saves us from having to actually // copy the entire event data: if (!isempty(Timer->Summary())) - info->SetTitleAndDescription(Timer->File(), Timer->Summary()); + info->SetData(isempty(info->Title()) ? Timer->File() : NULL, NULL, Timer->Summary()); } cRecording::cRecording(const char *FileName) @@ -462,6 +469,46 @@ cRecording::cRecording(const char *FileName) else if (errno != ENOENT) LOG_ERROR_STR(InfoFileName); free(InfoFileName); +#ifdef SUMMARYFALLBACK + // fall back to the old 'summary.vdr' if there was no 'info.vdr': + if (isempty(info->Title())) { + char *SummaryFileName = NULL; + asprintf(&SummaryFileName, "%s%s", fileName, SUMMARYFILESUFFIX); + FILE *f = fopen(SummaryFileName, "r"); + if (f) { + int line = 0; + char *data[3] = { NULL }; + cReadLine ReadLine; + char *s; + while ((s = ReadLine.Read(f)) != NULL && line < 3) { + if (*s) { + if (data[line]) { + int len = strlen(s); + len += strlen(data[line]) + 1; + data[line] = (char *)realloc(data[line], len + 1); + strcat(data[line], "\n"); + strcat(data[line], s); + } + else + data[line] = strdup(s); + } + else + line++; + } + fclose(f); + if (line == 1) { + data[2] = data[1]; + data[1] = NULL; + } + info->SetData(data[0], data[1], data[2]); + for (int i = 0; i < 3; i ++) + free(data[i]); + } + else if (errno != ENOENT) + LOG_ERROR_STR(SummaryFileName); + free(SummaryFileName); + } +#endif } } diff --git a/recording.h b/recording.h index 548e8017..893c9a23 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.36 2005/05/22 09:08:40 kls Exp $ + * $Id: recording.h 1.37 2005/05/22 10:29:02 kls Exp $ */ #ifndef __RECORDING_H @@ -39,7 +39,7 @@ private: const cEvent *event; cEvent *ownEvent; cRecordingInfo(const cEvent *Event = NULL); - void SetTitleAndDescription(const char *Title, const char *Description); + void SetData(const char *Title, const char *ShortText, const char *Description); public: ~cRecordingInfo(); const char *Title(void) const { return event->Title(); } diff --git a/summary2info.pl b/summary2info.pl index 4bf70624..8e80abe0 100755 --- a/summary2info.pl +++ b/summary2info.pl @@ -10,7 +10,7 @@ # See the main source file 'vdr.c' for copyright information and # how to reach the author. # -# $Id: summary2info.pl 1.1 2005/05/15 16:03:10 kls Exp $ +# $Id: summary2info.pl 1.2 2005/05/22 10:37:47 kls Exp $ $VideoDir = $ARGV[0] || die "please provide the name of the video directory\n"; @@ -29,7 +29,7 @@ for $SummaryFile (@SummaryFiles) { $data[$line] .= $_; } else { - $line++ unless ($_); + $line++; } } close(F);