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);
67 int eDVBMetaParser::parseRecordings(const std::string &filename)
69 std::string::size_type slash = filename.rfind('/');
70 if (slash == std::string::npos)
73 std::string recordings = filename.substr(0, slash) + "/recordings.epl";
75 FILE *f = fopen(recordings.c_str(), "r");
78 eDebug("no recordings.epl found: %s: %m", recordings.c_str());
82 std::string description;
83 eServiceReferenceDVB ref;
85 eDebug("parsing recordings.epl..");
90 if (!fgets(line, 1024, f))
94 line[strlen(line)-1] = 0;
96 if (strlen(line) && line[strlen(line)-1] == '\r')
97 line[strlen(line)-1] = 0;
99 if (!strncmp(line, "#SERVICE: ", 10))
100 ref = eServiceReferenceDVB(line + 10);
101 if (!strncmp(line, "#DESCRIPTION: ", 14))
102 description = line + 14;
104 if ((line[0] == '/') && (ref.path == filename))
108 m_name = description;