Copy freesat to non-freesat database
This commit is contained in:
parent
5e468f5857
commit
b3ea751561
17
epgsql.c
17
epgsql.c
|
@ -112,6 +112,23 @@ int ExecSQLStatement(char *SQL, sqlite3 *db)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ExecSQLStatementRowCount(char *SQL, sqlite3 *db)
|
||||
{
|
||||
int rc;
|
||||
char *zErrMsg = 0;
|
||||
|
||||
rc = sqlite3_exec(db, SQL, 0, 0, &zErrMsg);
|
||||
|
||||
if( rc!=SQLITE_OK ){
|
||||
fprintf(stderr, "SQL error executing script : %s\n", zErrMsg);
|
||||
fprintf(stderr, "RC : %i\n", rc);
|
||||
fprintf(stderr, "SQL : %s\n", SQL);
|
||||
sqlite3_free(zErrMsg);
|
||||
return -1;
|
||||
}
|
||||
return sqlite3_changes(db);
|
||||
}
|
||||
|
||||
/*int GetFileTimestamp(sqlite3 *db, char *res)*/
|
||||
void GetFileTimestamp(unsigned int * TS)
|
||||
{
|
||||
|
|
1
epgsql.h
1
epgsql.h
|
@ -5,6 +5,7 @@ int OpenCreateDB(char * DBFile, sqlite3 **db);
|
|||
int CloseDB(sqlite3 *db);
|
||||
int InitDB(char * InitScript, sqlite3 *db);
|
||||
int ExecSQLStatement(char *SQL, sqlite3 *db);
|
||||
int ExecSQLStatementRowCount(char *SQL, sqlite3 *db);
|
||||
void GetFileTimestamp(unsigned int *);
|
||||
|
||||
|
||||
|
|
52
main.c
52
main.c
|
@ -21,14 +21,14 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
int debug = 0;
|
||||
const char *version = "1.3";
|
||||
const char *version = "1.8";
|
||||
unsigned long sysopts = 0;
|
||||
unsigned long filterflags = 0;
|
||||
|
||||
int
|
||||
syntax()
|
||||
{
|
||||
fprintf(stderr, "Humax Foxsat EPG Tool v%s, by adrianf36, 2011-2016.\n", version);
|
||||
fprintf(stderr, "Humax Foxsat EPG Tool v%s, by adrianf36, 2011-2016, MofTot 2018-20.\n", version);
|
||||
fprintf(stderr, "based on the Humax (T2) EPG Tool from af123 v1.0.2, 2011.\n\n");
|
||||
|
||||
fprintf(stderr,
|
||||
|
@ -347,6 +347,8 @@ void dosqldump(char * epgpath,struct epgfilter *filter, int Continuous)
|
|||
|
||||
rc = ExecSQLStatement("COMMIT;", db);
|
||||
|
||||
copy_freesat_to_non_freesat(db);
|
||||
|
||||
sprintf(SQL, "replace into epgtimestamp (lastfileprocessed) values (%i);", FileTS);
|
||||
rc = ExecSQLStatement("Delete from epgtimestamp;", db);
|
||||
rc = ExecSQLStatement(SQL, db);
|
||||
|
@ -377,6 +379,8 @@ void dosqldump(char * epgpath,struct epgfilter *filter, int Continuous)
|
|||
|
||||
rc = ExecSQLStatement("COMMIT;", db);
|
||||
|
||||
copy_freesat_to_non_freesat(db);
|
||||
|
||||
sprintf(SQL, "replace into epgtimestamp (lastfileprocessed) values (%i);", FileTS);
|
||||
rc = ExecSQLStatement("Delete from epgtimestamp;", db);
|
||||
rc = ExecSQLStatement(SQL, db);
|
||||
|
@ -568,6 +572,47 @@ dump(struct epg *epg __attribute__((unused)),
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
copy_freesat_to_non_freesat(sqlite3 * db)
|
||||
{
|
||||
int rc;
|
||||
|
||||
ExecSQLStatement(
|
||||
"attach database '/opt/webif/plugin/epg/epgsettings.db' as epgsettings",
|
||||
db
|
||||
);
|
||||
|
||||
ExecSQLStatement("BEGIN;", db);
|
||||
|
||||
rc = ExecSQLStatementRowCount(
|
||||
"insert into epg "
|
||||
"select epgmappings.nonfreesatserviceid, "
|
||||
"eventid, "
|
||||
"starttime, "
|
||||
"duration, "
|
||||
"encrypted, "
|
||||
"name, "
|
||||
"descr, "
|
||||
"warning, "
|
||||
"contentcode, "
|
||||
"contenttype, "
|
||||
"ECRID, "
|
||||
"SCRID, "
|
||||
"RCRID "
|
||||
"from epgsettings.epgmappings join epg on epg.serviceid = epgsettings.epgmappings.freesatserviceid "
|
||||
"except "
|
||||
"select epg.* "
|
||||
"from epgsettings.epgmappings join epg on epg.serviceid = epgsettings.epgmappings.freesatserviceid",
|
||||
db
|
||||
);
|
||||
|
||||
ExecSQLStatement("COMMIT;", db);
|
||||
|
||||
printf("%d EPG event(s) copied from Freesat to non-Freesat\n", rc);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void
|
||||
search(struct epg *epg __attribute__((unused)),
|
||||
struct section *s, struct data *d, struct descriptor **ds,
|
||||
|
@ -765,6 +810,3 @@ nextopt:
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue