[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

@@ -36,6 +36,7 @@
#include <libavutil/opt.h>
#include <event2/event.h>
#include <event2/keyvalq_struct.h>
#include <curl/curl.h>
@@ -193,6 +194,41 @@ http_client_request(struct http_client_ctx *ctx, struct http_client_session *ses
return 0;
}
int
http_form_urldecode(struct keyval *kv, const char *uri)
{
struct evhttp_uri *ev_uri = NULL;
struct evkeyvalq ev_query = { 0 };
struct evkeyval *param;
const char *query;
int ret;
ev_uri = evhttp_uri_parse_with_flags(uri, EVHTTP_URI_NONCONFORMANT);
if (!ev_uri)
return -1;
query = evhttp_uri_get_query(ev_uri);
if (!query)
goto error;
ret = evhttp_parse_query_str(query, &ev_query);
if (ret < 0)
goto error;
// musl libc doesn't have sys/queue.h so don't use TAILQ_FOREACH
for (param = ev_query.tqh_first; param; param = param->next.tqe_next)
keyval_add(kv, param->key, param->value);
evhttp_uri_free(ev_uri);
evhttp_clear_headers(&ev_query);
return 0;
error:
evhttp_uri_free(ev_uri);
evhttp_clear_headers(&ev_query);
return -1;
}
char *
http_form_urlencode(struct keyval *kv)
{