1 #include <lib/dvb/metaparser.h>
2 #include <lib/base/eerror.h>
5 eDVBMetaParser::eDVBMetaParser()
11 int eDVBMetaParser::parseFile(const std::string &basename)
13 /* first, try parsing the .meta file */
14 if (!parseMeta(basename))
17 /* otherwise, use recordings.epl */
18 return parseRecordings(basename);
21 int eDVBMetaParser::parseMeta(const std::string &tsname)
23 /* if it's a PVR channel, recover service id. */
24 std::string filename = tsname + ".meta";
26 FILE *f = fopen(filename.c_str(), "r");
37 if (!fgets(line, 1024, f))
39 if (*line && line[strlen(line)-1] == '\n')
40 line[strlen(line)-1] = 0;
42 if (*line && line[strlen(line)-1] == '\r')
43 line[strlen(line)-1] = 0;
48 m_ref = eServiceReferenceDVB(line);
57 m_time_create = atoi(line);
72 int eDVBMetaParser::parseRecordings(const std::string &filename)
74 std::string::size_type slash = filename.rfind('/');
75 if (slash == std::string::npos)
78 std::string recordings = filename.substr(0, slash) + "/recordings.epl";
80 FILE *f = fopen(recordings.c_str(), "r");
83 // eDebug("no recordings.epl found: %s: %m", recordings.c_str());
87 std::string description;
88 eServiceReferenceDVB ref;
90 // eDebug("parsing recordings.epl..");
95 if (!fgets(line, 1024, f))
99 line[strlen(line)-1] = 0;
101 if (strlen(line) && line[strlen(line)-1] == '\r')
102 line[strlen(line)-1] = 0;
104 if (!strncmp(line, "#SERVICE: ", 10))
105 ref = eServiceReferenceDVB(line + 10);
106 if (!strncmp(line, "#DESCRIPTION: ", 14))
107 description = line + 14;
109 if ((line[0] == '/') && (ref.path == filename))
111 // eDebug("hit! ref %s descr %s", m_ref.toString().c_str(), m_name.c_str());
113 m_name = description;
126 int eDVBMetaParser::updateMeta(const std::string &tsname)
130 std::string filename = tsname + ".meta";
132 FILE *f = fopen(filename.c_str(), "w");
135 fprintf(f, "%s\n%s\n%s\n%d\n%s\n", m_ref.toString().c_str(), m_name.c_str(), m_description.c_str(), m_time_create, m_tags.c_str());