Merge branch 'master' into dvd_scale_test
[enigma2.git] / lib / dvb / metaparser.cpp
index 6fbc56d140e3001b03f6dd9693d3374fc56b2d02..3e3f9a79143df6cde1b7b50f6e8af02168f35fcd 100644 (file)
@@ -5,6 +5,7 @@
 eDVBMetaParser::eDVBMetaParser()
 {
        m_time_create = 0;
+       m_data_ok = 0;
 }
 
 int eDVBMetaParser::parseFile(const std::string &basename)
@@ -55,12 +56,16 @@ int eDVBMetaParser::parseMeta(const std::string &tsname)
                case 3:
                        m_time_create = atoi(line);
                        break;
+               case 4:
+                       m_tags = line;
+                       break;
                default:
                        break;
                }
                ++linecnt;
        }
        fclose(f);
+       m_data_ok = 1;
        return 0;
 }
 
@@ -75,14 +80,14 @@ int eDVBMetaParser::parseRecordings(const std::string &filename)
        FILE *f = fopen(recordings.c_str(), "r");
        if (!f)
        {
-               eDebug("no recordings.epl found: %s: %m", recordings.c_str());
+//             eDebug("no recordings.epl found: %s: %m", recordings.c_str());
                return -1;
        }
        
        std::string description;
        eServiceReferenceDVB ref;
        
-       eDebug("parsing recordings.epl..");
+//     eDebug("parsing recordings.epl..");
        
        while (1)
        {
@@ -103,14 +108,31 @@ int eDVBMetaParser::parseRecordings(const std::string &filename)
 
                if ((line[0] == '/') && (ref.path == filename))
                {
-                       eDebug("hit!");
+//                     eDebug("hit! ref %s descr %s", m_ref.toString().c_str(), m_name.c_str());
                        m_ref = ref;
                        m_name = description;
                        m_description = "";
                        m_time_create = 0;
+                       
+                       m_data_ok = 1;
+                       fclose(f);
                        return 0;
                }
        }
        fclose(f);
        return -1;
 }
+
+int eDVBMetaParser::updateMeta(const std::string &tsname)
+{
+       if (!m_data_ok) 
+               return -1;
+       std::string filename = tsname + ".meta";
+
+       FILE *f = fopen(filename.c_str(), "w");
+       if (!f)
+               return -ENOENT;
+       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());
+       fclose(f);
+       return 0;
+}