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.
This commit is contained in:
Rafał Dzięgiel
2025-07-25 19:18:11 +02:00
parent d8ea220aad
commit 4a34fb3484

View File

@@ -39,6 +39,7 @@
*/ */
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/tag/tag.h>
#include <gst/pbutils/pbutils.h> #include <gst/pbutils/pbutils.h>
#include "clapper-discoverer.h" #include "clapper-discoverer.h"
@@ -128,8 +129,9 @@ _run_discovery (ClapperDiscoverer *self)
ClapperMediaItem *item; ClapperMediaItem *item;
ClapperQueue *queue; ClapperQueue *queue;
ClapperDiscovererDiscoveryMode discovery_mode; ClapperDiscovererDiscoveryMode discovery_mode;
GstTagList *tags;
const gchar *uri; const gchar *uri;
gboolean success = FALSE; gboolean empty_tags, success = FALSE;
if (self->pending_items->len == 0) { if (self->pending_items->len == 0) {
GST_DEBUG_OBJECT (self, "No more pending items"); GST_DEBUG_OBJECT (self, "No more pending items");
@@ -157,6 +159,16 @@ _run_discovery (ClapperDiscoverer *self)
goto finish; goto finish;
} }
tags = clapper_media_item_get_tags (item);
empty_tags = gst_tag_list_is_empty (tags);
gst_tag_list_unref (tags);
if (!empty_tags) {
GST_DEBUG_OBJECT (self, "Queued %" GST_PTR_FORMAT
" already has tags, ignoring discovery", item);
goto finish;
}
uri = clapper_media_item_get_uri (item); uri = clapper_media_item_get_uri (item);
GST_DEBUG_OBJECT (self, "Starting discovery of %" GST_DEBUG_OBJECT (self, "Starting discovery of %"
GST_PTR_FORMAT "(%s)", item, uri); GST_PTR_FORMAT "(%s)", item, uri);