From 9fd6117cd5e07d2f3cedc6bf3574d629a830a02e Mon Sep 17 00:00:00 2001 From: hummypkg Date: Mon, 2 Nov 2015 23:05:32 +0000 Subject: [PATCH] extract and store episode thumbnail --- tvdb.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tvdb.c b/tvdb.c index 39134c6..75eb4cb 100644 --- a/tvdb.c +++ b/tvdb.c @@ -28,6 +28,7 @@ struct episode { unsigned long id; char *name; char *overview; + char *thumb; unsigned long series; unsigned long episode; }; @@ -204,19 +205,21 @@ main(int argc, char **argv) sprintf(buf, "attach '%s/%lu.db' as episode", CACHE, s.id); EXEC(buf); + EXEC("drop table if exists episode.episode"); EXEC( "create table if not exists episode.episode(" "[episode_id] integer primary key, " "[series] integer, " "[episode] integer, " "[name] text, " - "[overview] text" + "[overview] text, " + "[thumb] text" ")" ); if (sqlite3_prepare_v2(db, "insert or replace into episode.episode " - "values(?,?,?,?,?)", + "values(?,?,?,?,?,?)", -1, &stmt, NULL) != SQLITE_OK) { fprintf(stderr, @@ -255,6 +258,13 @@ main(int argc, char **argv) *q = '\0'; unescape(e.overview); } + if (!strncmp(p, "filename>", 9)) + { + e.thumb = strdup(p + 9); + if ((q = strstr(e.thumb, ""))) + *q = '\0'; + unescape(e.thumb); + } if (!strncmp(p, "/Episode>", 8)) { @@ -268,12 +278,14 @@ main(int argc, char **argv) sqlite3_bind_text(stmt, 4, e.name, -1, NULL); sqlite3_bind_text(stmt, 5, e.overview, -1, NULL); + sqlite3_bind_text(stmt, 6, e.thumb, -1, NULL); sqlite3_step(stmt); sqlite3_reset(stmt); sqlite3_clear_bindings(stmt); } if (e.name) free(e.name); if (e.overview) free(e.overview); + if (e.thumb) free(e.thumb); memset(&e, '\0', sizeof(e)); } }