From b4922a58473bf7411b0a2f36d3d8c09279740cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Fri, 25 Jul 2025 19:18:11 +0200 Subject: [PATCH] clapper: discoverer: Skip items that already have tags When tags are populated elsewhere, do not run discovery on them again. It is possible they were discovered in more efficient maner (e.g. from playlist data itself). This avoid us downloading each media item separately after all playlist items are queued. --- .../features/discoverer/clapper-discoverer.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib/clapper/features/discoverer/clapper-discoverer.c b/src/lib/clapper/features/discoverer/clapper-discoverer.c index cfd62653..cd0e4feb 100644 --- a/src/lib/clapper/features/discoverer/clapper-discoverer.c +++ b/src/lib/clapper/features/discoverer/clapper-discoverer.c @@ -39,6 +39,7 @@ */ #include +#include #include #include "clapper-discoverer.h" @@ -128,8 +129,9 @@ _run_discovery (ClapperDiscoverer *self) ClapperMediaItem *item; ClapperQueue *queue; ClapperDiscovererDiscoveryMode discovery_mode; + GstTagList *tags; const gchar *uri; - gboolean success = FALSE; + gboolean had_tags, success = FALSE; if (self->pending_items->len == 0) { GST_DEBUG_OBJECT (self, "No more pending items"); @@ -157,6 +159,16 @@ _run_discovery (ClapperDiscoverer *self) goto finish; } + tags = clapper_media_item_get_tags (item); + had_tags = !gst_tag_list_is_empty (tags); + gst_tag_list_unref (tags); + + if (had_tags) { + GST_DEBUG_OBJECT (self, "Queued %" GST_PTR_FORMAT + " already has tags, ignoring discovery", item); + goto finish; + } + uri = clapper_media_item_get_uri (item); GST_DEBUG_OBJECT (self, "Starting discovery of %" GST_PTR_FORMAT "(%s)", item, uri);