From 477c468861635555c7179f2f4397dd765f499656 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Fri, 3 Feb 2006 12:51:04 +0000 Subject: [PATCH] use recordings.epl as backup if existing. only first part will be played, though. --- lib/dvb/metaparser.cpp | 69 +++++++++++++++++++++++++++++++++++++++++- lib/dvb/metaparser.h | 6 +++- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/lib/dvb/metaparser.cpp b/lib/dvb/metaparser.cpp index abc4456e..6fbc56d1 100644 --- a/lib/dvb/metaparser.cpp +++ b/lib/dvb/metaparser.cpp @@ -1,7 +1,23 @@ #include +#include #include -int eDVBMetaParser::parseFile(const std::string &tsname) +eDVBMetaParser::eDVBMetaParser() +{ + m_time_create = 0; +} + +int eDVBMetaParser::parseFile(const std::string &basename) +{ + /* first, try parsing the .meta file */ + if (!parseMeta(basename)) + return 0; + + /* otherwise, use recordings.epl */ + return parseRecordings(basename); +} + +int eDVBMetaParser::parseMeta(const std::string &tsname) { /* if it's a PVR channel, recover service id. */ std::string filename = tsname + ".meta"; @@ -47,3 +63,54 @@ int eDVBMetaParser::parseFile(const std::string &tsname) fclose(f); return 0; } + +int eDVBMetaParser::parseRecordings(const std::string &filename) +{ + std::string::size_type slash = filename.rfind('/'); + if (slash == std::string::npos) + return -1; + + std::string recordings = filename.substr(0, slash) + "/recordings.epl"; + + FILE *f = fopen(recordings.c_str(), "r"); + if (!f) + { + eDebug("no recordings.epl found: %s: %m", recordings.c_str()); + return -1; + } + + std::string description; + eServiceReferenceDVB ref; + + eDebug("parsing recordings.epl.."); + + while (1) + { + char line[1024]; + if (!fgets(line, 1024, f)) + break; + + if (strlen(line)) + line[strlen(line)-1] = 0; + + if (strlen(line) && line[strlen(line)-1] == '\r') + line[strlen(line)-1] = 0; + + if (!strncmp(line, "#SERVICE: ", 10)) + ref = eServiceReferenceDVB(line + 10); + if (!strncmp(line, "#DESCRIPTION: ", 14)) + description = line + 14; + + if ((line[0] == '/') && (ref.path == filename)) + { + eDebug("hit!"); + m_ref = ref; + m_name = description; + m_description = ""; + m_time_create = 0; + return 0; + } + } + fclose(f); + return -1; +} diff --git a/lib/dvb/metaparser.h b/lib/dvb/metaparser.h index 60329ace..20a61262 100644 --- a/lib/dvb/metaparser.h +++ b/lib/dvb/metaparser.h @@ -7,7 +7,11 @@ class eDVBMetaParser { public: - int parseFile(const std::string &filename); + eDVBMetaParser(); + int parseFile(const std::string &basename); + + int parseMeta(const std::string &filename); + int parseRecordings(const std::string &filename); eServiceReferenceDVB m_ref; std::string m_name, m_description; -- 2.30.2