Skip to content
Extraits de code Groupes Projets
Vérifiée Valider c534a3cb rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Add metadata to downloaded kara

parent e119a347
Aucune branche associée trouvée
Étiquettes
1 requête de fusion!77Kara downloader update
...@@ -37,15 +37,7 @@ struct kara_metadata { ...@@ -37,15 +37,7 @@ struct kara_metadata {
int song_number; 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 { struct kara {
enum kara_action action; /* What to do with this kara. */
size_t id; /* Should never be NULL. NEVER!! */ size_t id; /* Should never be NULL. NEVER!! */
struct kara_metadata mdt; /* The metadata of the kara. */ struct kara_metadata mdt; /* The metadata of the kara. */
char filename[PATH_MAX]; /* The path to the matroska file. */ char filename[PATH_MAX]; /* The path to the matroska file. */
......
...@@ -325,7 +325,10 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, struct json_objec ...@@ -325,7 +325,10 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, struct json_objec
struct kara kara; struct kara kara;
char url[URL_MAX_LEN]; char url[URL_MAX_LEN];
long filestamp, timestamp; long filestamp, timestamp;
char mkvpropedit[PATH_MAX];
RETURN_UNLESS(len > 0 && json_object_get_array(json), "Json invalid or array empty", NOTHING); 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); LOG_INFO_SCT("REPO", "Starting to process json for repo %s", repo->name);
for (i = 0; i < len; ++i) { for (i = 0; i < len; ++i) {
...@@ -377,6 +380,11 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, struct json_objec ...@@ -377,6 +380,11 @@ __handle_got_json(volatile sqlite3 *db, struct lkt_repo *repo, struct json_objec
continue; 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)) { if (!database_update_set_available((sqlite3 *) db, kara.id)) {
LOG_WARN_SCT("REPO", "Could not set kara %ld available", kara.id); LOG_WARN_SCT("REPO", "Could not set kara %ld available", kara.id);
continue; continue;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter