From 7ddc7d9737b0c898b8c12cf6b27ad596c595d0b2 Mon Sep 17 00:00:00 2001 From: whatdoineed2do/Ray Date: Sun, 5 Nov 2023 10:52:03 +0000 Subject: [PATCH] [jsonapi] apply rating meta update to media if supported through ffmpeg AVDictionary api --- src/httpd_jsonapi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/httpd_jsonapi.c b/src/httpd_jsonapi.c index ead76ec55b..52af2ce496 100644 --- a/src/httpd_jsonapi.c +++ b/src/httpd_jsonapi.c @@ -3686,6 +3686,26 @@ track_sync_rating(const struct db_media_file_info *dbmfi, unsigned *updated, uns char rating[5] = { '\0' }; char dest[PATH_MAX]; + // keep in sync with scan_metadata_ffmpeg and incl types supported by ffmpeg AVDictionary interface + static const char *supported_meta[] = { + "mpeg", "flac", NULL + }; + const char **supported = supported_meta; + while (*supported) + { + if (strcmp(dbmfi->codectype, *supported) == 0) { + break; + } + ++supported; + } + if (*supported == NULL) + { + // unsupported rating, dont bother + // using stream[x]->codecpar but this is already known in db and via dbmfi + DPRINTF(E_WARN, L_WEB, "unsupported metadata update for 'rating' on '%s' (%s) - skipping\n", dbmfi->path, dbmfi->codectype); + return ENOEXEC; + } + AVFormatContext* ctx = NULL; if ( (ret = avformat_open_input(&ctx, dbmfi->path, NULL, NULL)) != 0) {