From f31cfea03bd409671a63e5efb0bb34d7a87d7fcb Mon Sep 17 00:00:00 2001 From: hummypkg Date: Sun, 3 Jan 2016 10:55:37 +0000 Subject: [PATCH] support descriptor 126 --- descriptor.h | 3 ++- epg.c | 8 ++++--- main.c | 67 +++++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 63 insertions(+), 15 deletions(-) diff --git a/descriptor.h b/descriptor.h index e0e6799..27c7ad9 100644 --- a/descriptor.h +++ b/descriptor.h @@ -20,7 +20,8 @@ #define PARSER_CRID_SERIES 4 #define PARSER_CRID_REC 5 #define PARSER_EXTENDED_EVENT 6 -#define PARSER_MAX 7 +#define PARSER_FTA_CONTENT_MGMT 7 +#define PARSER_MAX 8 #define CRIDT_EVENT '1' #define CRIDT_SERIES '2' diff --git a/epg.c b/epg.c index edfddbf..43ec240 100644 --- a/epg.c +++ b/epg.c @@ -343,13 +343,15 @@ parse(char *epgpath, dslist[PARSER_CONTENT] = ds; break; - /* case DS_FTA_CONTENT_MGMT: + if (!(ds = read_descriptor_header(epg))) + break; read_descriptor(epg, ds); - dump_descriptor(ds, 1); - free_descriptor(ds); + dslist[PARSER_FTA_CONTENT_MGMT] = ds; break; + /* + case DS_LINKAGE: read_descriptor(epg, ds); dump_descriptor(ds, 1); diff --git a/main.c b/main.c index 0592e02..58af27c 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,6 @@ /* * Humax EPG Tool - * by af123, 2011 - 2015 + * by af123, 2011 - 2016 */ #include @@ -21,7 +21,7 @@ #include "lint.h" int debug = 0; -const char *version = "1.2.0"; +const char *version = "1.2.1"; unsigned long sysopts = 0; unsigned long filterflags = 0; static time_t latest_stamp = 0; @@ -34,7 +34,7 @@ sqlite3_stmt *stmt; int syntax() { - fprintf(stderr, "Humax EPG Tool v%s, by af123, 2011-2015.\n\n", + fprintf(stderr, "Humax EPG Tool v%s, by af123, 2011-2016.\n\n", version); fprintf(stderr, "Syntax: epg [options] [filters] ...\n\n"); @@ -91,6 +91,7 @@ syntax() " Service ID, Event ID, Start, Duration, Encrypted,\n" " Title, Synopsis, Warning, Content Code, Content Type,\n" " Event CRID, Series CRID, Recommended CRID, Guidance Mode\n" +" Content Mgmt\n" ); fprintf(stderr, "\n"); @@ -174,6 +175,8 @@ dumpraw(struct epg *epg __attribute__((unused)), dump_descriptor(ds[PARSER_CRID_SERIES], 1); if (ds[PARSER_CRID_REC]) dump_descriptor(ds[PARSER_CRID_REC], 1); + if (ds[PARSER_FTA_CONTENT_MGMT]) + dump_descriptor(ds[PARSER_FTA_CONTENT_MGMT], 1); } /* Strings should all be safe now the huffman module is in place... */ @@ -261,6 +264,7 @@ sqlitedumpstart(char *file) "[start] integer, [end] integer, [duration] integer, " "[name] text, [text] text, [warning] text, [warning_mode] integer, " "[content_code] integer, [content_type] text, " + "[content_mgmt] integer, " "[event_crid] text, [series_crid] text, [rec_crid] text)" ); EXEC("create index tm on epg(start,end)"); @@ -268,7 +272,7 @@ sqlitedumpstart(char *file) EXEC("create index service_id on epg(service_id)"); if (sqlite3_prepare_v2(db, - "insert into epg values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)", + "insert into epg values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", -1, &stmt, NULL) != SQLITE_OK) { fprintf(stderr, @@ -318,6 +322,7 @@ sqlitedump(struct epg *epg __attribute__((unused)), sqlite3_bind_text(stmt, 6, d->content.d77.name, -1, NULL); sqlite3_bind_text(stmt, 7, d->content.d77.text, -1, NULL); } + if (ds[PARSER_USER_DEFINED]) { struct descriptor *d = ds[PARSER_USER_DEFINED]; @@ -326,6 +331,7 @@ sqlitedump(struct epg *epg __attribute__((unused)), sqlite3_bind_text(stmt, 8, d->content.d137.warning, -1, NULL); sqlite3_bind_int(stmt, 9, d->content.d137.guidance_mode); } + if (ds[PARSER_CONTENT]) { sqlite3_bind_int(stmt, 10, @@ -334,24 +340,32 @@ sqlitedump(struct epg *epg __attribute__((unused)), -1, NULL); } + if (ds[PARSER_FTA_CONTENT_MGMT]) + { + sqlite3_bind_int(stmt, 12, + !ds[PARSER_FTA_CONTENT_MGMT]->content.d126.no_scramble); + } + else + sqlite3_bind_int(stmt, 12, 0); + if (ds[PARSER_CRID_EVENT]) { struct descriptor *d = ds[PARSER_CRID_EVENT]; - sqlite3_bind_text(stmt, 12, d->content.d118.crids[0].crid, + sqlite3_bind_text(stmt, 13, d->content.d118.crids[0].crid, -1, NULL); } if (ds[PARSER_CRID_SERIES]) { struct descriptor *d = ds[PARSER_CRID_SERIES]; - sqlite3_bind_text(stmt, 13, d->content.d118.crids[0].crid, + sqlite3_bind_text(stmt, 14, d->content.d118.crids[0].crid, -1, NULL); } if (ds[PARSER_CRID_REC]) { struct descriptor *d = ds[PARSER_CRID_REC]; - sqlite3_bind_text(stmt, 14, d->content.d118.crids[0].crid, + sqlite3_bind_text(stmt, 15, d->content.d118.crids[0].crid, -1, NULL); } @@ -444,6 +458,14 @@ json(struct epg *epg __attribute__((unused)), content_type(ds[PARSER_CONTENT])); } + if (ds[PARSER_FTA_CONTENT_MGMT]) + { + struct descriptor *d = ds[PARSER_FTA_CONTENT_MGMT]; + + printf(",\n \"content_mgmt\": \"%d\"", + !d->content.d126.no_scramble); + } + if (ds[PARSER_CRID_EVENT]) { struct descriptor *d = ds[PARSER_CRID_EVENT]; @@ -487,6 +509,7 @@ sqldumpstart() printf("guidance_mode tinyint unsigned not null,\n"); printf("content_code bigint unsigned not null,\n"); printf("content_type varchar(255),\n"); + printf("content_mgmt bigint unsigned not null default 0,\n"); printf("event_crid varchar(255),\n"); printf("series_crid varchar(255),\n"); printf("rec_crid varchar(255),\n"); @@ -561,6 +584,12 @@ sqldump(struct epg *epg __attribute__((unused)), content_type(ds[PARSER_CONTENT])); } + if (ds[PARSER_FTA_CONTENT_MGMT]) + { + printf(",\n content_mgmt = %d", + !ds[PARSER_CONTENT]->content.d126.no_scramble); + } + if (ds[PARSER_CRID_EVENT]) { struct descriptor *d = ds[PARSER_CRID_EVENT]; @@ -593,6 +622,7 @@ dump(struct epg *epg __attribute__((unused)), void *var __attribute__((unused))) { time_t tm; + int cm; tm = mjd(d->start_date, d->start_hour, d->start_min, d->start_sec); @@ -613,7 +643,7 @@ dump(struct epg *epg __attribute__((unused)), /* service_id, event_id, start, duration, encrypted, name, text * warning, content code, content type, * event CRID, series CRID, rec CRID, - * guidance mode + * guidance mode, content management */ printf("%d\t%d\t%ld\t%d\t%d\t", s->service_id, d->event_id, tm, @@ -685,6 +715,14 @@ dump(struct epg *epg __attribute__((unused)), else printf("\t"); + if (ds[PARSER_FTA_CONTENT_MGMT]) + { + printf("%d\t", !ds[PARSER_FTA_CONTENT_MGMT]-> + content.d126.no_scramble); + } + else + printf("\t"); + printf("\n"); return; } @@ -721,14 +759,21 @@ dump(struct epg *epg __attribute__((unused)), printf("%30s: %d\n", "Service ID", s->service_id); printf("%30s: %d\n", "Event ID", d->event_id); - printf("%30s: %#x %d:%02d:%02d (%s)\n", "start_date", + printf("%30s: %#x %d:%02d:%02d (%s)\n", "Start Date", d->start_date, d->start_hour, d->start_min, d->start_sec, ctime_nl(&tm)); - printf("%30s: %d:%02d:%02d\n", "duration", + printf("%30s: %d:%02d:%02d\n", "Duration", d->dur_hour, d->dur_min, d->dur_sec); - printf("%30s: %d\n", "encrypted", d->u1.u.free_CA_mode); + printf("%30s: %d\n", "Encrypted", d->u1.u.free_CA_mode); + + cm = 1; + if (ds[PARSER_FTA_CONTENT_MGMT]) + { + cm = ds[PARSER_FTA_CONTENT_MGMT]->content.d126.no_scramble; + } + printf("%30s: %s\n", "Content Mgmt", cm ? "No" : "Yes"); if (ds[PARSER_SHORT_EVENT]) {