1 #include <lib/dvb/metaparser.h>
2 #include <lib/base/eerror.h>
5 eDVBMetaParser::eDVBMetaParser()
10 int eDVBMetaParser::parseFile(const std::string &basename)
12 /* first, try parsing the .meta file */
13 if (!parseMeta(basename))
16 /* otherwise, use recordings.epl */
17 return parseRecordings(basename);
20 int eDVBMetaParser::parseMeta(const std::string &tsname)
22 /* if it's a PVR channel, recover service id. */
23 std::string filename = tsname + ".meta";
25 FILE *f = fopen(filename.c_str(), "r");
36 if (!fgets(line, 1024, f))
38 if (*line && line[strlen(line)-1] == '\n')
39 line[strlen(line)-1] = 0;
41 if (*line && line[strlen(line)-1] == '\r')
42 line[strlen(line)-1] = 0;
47 m_ref = eServiceReferenceDVB(line);
56 m_time_create = atoi(line);
70 int eDVBMetaParser::parseRecordings(const std::string &filename)
72 std::string::size_type slash = filename.rfind('/');
73 if (slash == std::string::npos)
76 std::string recordings = filename.substr(0, slash) + "/recordings.epl";
78 FILE *f = fopen(recordings.c_str(), "r");
81 // eDebug("no recordings.epl found: %s: %m", recordings.c_str());
85 std::string description;
86 eServiceReferenceDVB ref;
88 // eDebug("parsing recordings.epl..");
93 if (!fgets(line, 1024, f))
97 line[strlen(line)-1] = 0;
99 if (strlen(line) && line[strlen(line)-1] == '\r')
100 line[strlen(line)-1] = 0;
102 if (!strncmp(line, "#SERVICE: ", 10))
103 ref = eServiceReferenceDVB(line + 10);
104 if (!strncmp(line, "#DESCRIPTION: ", 14))
105 description = line + 14;
107 if ((line[0] == '/') && (ref.path == filename))
109 // eDebug("hit! ref %s descr %s", m_ref.toString().c_str(), m_name.c_str());
111 m_name = description;