[http] Support for extracting artwork url from within StreamUrl field

This commit is contained in:
ejurgensen
2025-01-01 15:41:21 +01:00
committed by Alain Nussbaumer
parent 6c7b568e49
commit 3c98ca7928
3 changed files with 63 additions and 2 deletions

View File

@@ -173,8 +173,9 @@ streamurl_process(struct input_metadata *metadata, const char *url)
{
struct http_client_ctx client = { 0 };
struct keyval kv = { 0 };
struct evbuffer *evbuf;
struct evbuffer *evbuf = NULL;
const char *content_type;
const char *artwork_url;
char *body;
int ret;
@@ -186,6 +187,21 @@ streamurl_process(struct input_metadata *metadata, const char *url)
return -1;
}
// If the StreamUrl contains a keyword followed by the actual url, e.g. http://metadata.cdnstream1.com/?yadayada&ALBUM_ART=https%3A%2F%2Fis1-ssl.mzstatic.com%2Fimage%2Fthumb%2FMusic%2F11%2Fcc%2F21%2Fmzi.nepwiuir.jpg
if (streamurl_map[0].words)
{
ret = http_form_urldecode(&kv, url);
if (ret < 0)
return -1;
artwork_url = keyval_get(&kv, streamurl_map[0].words);
metadata->artwork_url = safe_strdup(artwork_url);
keyval_clear(&kv);
if (metadata->artwork_url)
goto out;
}
DPRINTF(E_DBG, L_PLAYER, "Downloading StreamUrl resource '%s'\n", url);
CHECK_NULL(L_PLAYER, evbuf = evbuffer_new());
@@ -219,7 +235,8 @@ streamurl_process(struct input_metadata *metadata, const char *url)
out:
keyval_clear(&kv);
evbuffer_free(evbuf);
if (evbuf)
evbuffer_free(evbuf);
streamurl_settings_unload();
return ret;
}