diff --git a/inc/lektor/mkv.h b/inc/lektor/mkv.h index 21b3808c0b7ea7d3d27f99d101787729fafa5de2..1d6d9d1a753b8f1420bac0cae01d477dfdacab75 100644 --- a/inc/lektor/mkv.h +++ b/inc/lektor/mkv.h @@ -37,15 +37,7 @@ struct kara_metadata { int song_number; }; -enum kara_action { - kara_action_none = 0, /* Do nothing */ - kara_action_add = (1 << 1), /* Add to database */ - kara_action_delete = (1 << 2), /* Delete from database */ - kara_action_unavail = (1 << 3), /* Mark kara as unavailable */ -}; - struct kara { - enum kara_action action; /* What to do with this kara. */ size_t id; /* Should never be NULL. NEVER!! */ struct kara_metadata mdt; /* The metadata of the kara. */ char filename[PATH_MAX]; /* The path to the matroska file. */ diff --git a/src/net/downloader.c b/src/net/downloader.c index b25ebac890df8e24b9ce60e3f6a43c0010beda0b..ffead91a8029b5f77134f3e4b781e1b52a6ae6c7 100644 --- a/src/net/downloader.c +++ b/src/net/downloader.c @@ -325,7 +325,10 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, struct json_objec struct kara kara; char url[URL_MAX_LEN]; long filestamp, timestamp; + char mkvpropedit[PATH_MAX]; RETURN_UNLESS(len > 0 && json_object_get_array(json), "Json invalid or array empty", NOTHING); + RETURN_UNLESS(database_config_get_text(db, "externals", "mkvpropedit", mkvpropedit, PATH_MAX - 1), + "Can't get the mkvpropedit executable path", NOTHING); LOG_INFO_SCT("REPO", "Starting to process json for repo %s", repo->name); for (i = 0; i < len; ++i) { @@ -377,6 +380,11 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, struct json_objec continue; } + if (!kara_metadata_write(&kara.mdt, kara.filename, mkvpropedit)) { + LOG_WARN_SCT("REPO", "Could not write metadata to kara '%ld' with path '%s'", kara.id, kara.filename); + continue; + } + if (!database_update_set_available((sqlite3 *) db, kara.id)) { LOG_WARN_SCT("REPO", "Could not set kara %ld available", kara.id); continue;