extract and store episode thumbnail

This commit is contained in:
hummypkg 2015-11-02 23:05:32 +00:00
parent 4c14046991
commit 9fd6117cd5
1 changed files with 14 additions and 2 deletions

16
tvdb.c
View File

@ -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, "</filename>")))
*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));
}
}