mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-05 10:48:09 -05:00
[artwork] Use settings to enable online sources
This commit is contained in:
parent
18cf2dbbbf
commit
b73f33f8e9
@ -36,6 +36,7 @@
|
|||||||
#include "misc_json.h"
|
#include "misc_json.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "conffile.h"
|
#include "conffile.h"
|
||||||
|
#include "settings.h"
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
#include "transcode.h"
|
#include "transcode.h"
|
||||||
@ -213,7 +214,7 @@ static struct artwork_source artwork_item_source[] =
|
|||||||
.data_kinds = (1 << DATA_KIND_FILE) | (1 << DATA_KIND_SPOTIFY),
|
.data_kinds = (1 << DATA_KIND_FILE) | (1 << DATA_KIND_SPOTIFY),
|
||||||
.cache = ON_FAILURE,
|
.cache = ON_FAILURE,
|
||||||
},
|
},
|
||||||
/* {
|
{
|
||||||
// TODO merge with spotifywebapi_get
|
// TODO merge with spotifywebapi_get
|
||||||
.name = "Spotify2",
|
.name = "Spotify2",
|
||||||
.handler = source_item_spotify2_get,
|
.handler = source_item_spotify2_get,
|
||||||
@ -233,7 +234,7 @@ static struct artwork_source artwork_item_source[] =
|
|||||||
.data_kinds = (1 << DATA_KIND_FILE),
|
.data_kinds = (1 << DATA_KIND_FILE),
|
||||||
.cache = NEVER,
|
.cache = NEVER,
|
||||||
},
|
},
|
||||||
*/ {
|
{
|
||||||
.name = "embedded",
|
.name = "embedded",
|
||||||
.handler = source_item_embedded_get,
|
.handler = source_item_embedded_get,
|
||||||
.data_kinds = (1 << DATA_KIND_FILE),
|
.data_kinds = (1 << DATA_KIND_FILE),
|
||||||
@ -1067,6 +1068,23 @@ online_source_search(struct online_source *src, struct artwork_ctx *ctx)
|
|||||||
return artwork_url;
|
return artwork_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
online_source_is_enabled(const char *setting_name)
|
||||||
|
{
|
||||||
|
struct settings_category *category;
|
||||||
|
struct settings_option *option;
|
||||||
|
|
||||||
|
category = settings_category_get("artwork");
|
||||||
|
if (!category)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
option = settings_option_get(category, setting_name);
|
||||||
|
if (!option)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return settings_option_getbool(option);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------- SOURCE HANDLER IMPLEMENTATION -------------------- */
|
/* ---------------------- SOURCE HANDLER IMPLEMENTATION -------------------- */
|
||||||
|
|
||||||
@ -1327,6 +1345,9 @@ source_item_discogs_get(struct artwork_ctx *ctx)
|
|||||||
char *url;
|
char *url;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (!online_source_is_enabled("enable_discogs"))
|
||||||
|
return ART_E_NONE;
|
||||||
|
|
||||||
url = online_source_search(&discogs_source, ctx);
|
url = online_source_search(&discogs_source, ctx);
|
||||||
if (!url)
|
if (!url)
|
||||||
return ART_E_NONE;
|
return ART_E_NONE;
|
||||||
@ -1343,6 +1364,9 @@ source_item_coverartarchive_get(struct artwork_ctx *ctx)
|
|||||||
char *url;
|
char *url;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (!online_source_is_enabled("enable_coverartarchive"))
|
||||||
|
return ART_E_NONE;
|
||||||
|
|
||||||
// We search Musicbrainz to get the Musicbrainz ID, which we need to get the
|
// We search Musicbrainz to get the Musicbrainz ID, which we need to get the
|
||||||
// artwork from the Cover Art Archive
|
// artwork from the Cover Art Archive
|
||||||
url = online_source_search(&musicbrainz_source, ctx);
|
url = online_source_search(&musicbrainz_source, ctx);
|
||||||
@ -1364,6 +1388,9 @@ source_item_spotify2_get(struct artwork_ctx *ctx)
|
|||||||
char *url;
|
char *url;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (!online_source_is_enabled("enable_spotify"))
|
||||||
|
return ART_E_NONE;
|
||||||
|
|
||||||
spotifywebapi_access_token_get(&info);
|
spotifywebapi_access_token_get(&info);
|
||||||
if (!info.token)
|
if (!info.token)
|
||||||
return ART_E_ERROR;
|
return ART_E_ERROR;
|
||||||
@ -1434,7 +1461,7 @@ source_item_spotify2_get(struct artwork_ctx *ctx)
|
|||||||
// Silence compiler warning about spotify_source being unused
|
// Silence compiler warning about spotify_source being unused
|
||||||
(void)spotify_source;
|
(void)spotify_source;
|
||||||
|
|
||||||
return ART_E_ERROR;
|
return ART_E_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -31,9 +31,17 @@ static struct settings_option webinterface_options[] =
|
|||||||
{ "show_composer_for_genre", SETTINGS_TYPE_STR },
|
{ "show_composer_for_genre", SETTINGS_TYPE_STR },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct settings_option artwork_options[] =
|
||||||
|
{
|
||||||
|
{ "enable_spotify", SETTINGS_TYPE_BOOL },
|
||||||
|
{ "enable_discogs", SETTINGS_TYPE_BOOL },
|
||||||
|
{ "enable_coverartarchive", SETTINGS_TYPE_BOOL },
|
||||||
|
};
|
||||||
|
|
||||||
static struct settings_category categories[] =
|
static struct settings_category categories[] =
|
||||||
{
|
{
|
||||||
{ "webinterface", webinterface_options, ARRAY_SIZE(webinterface_options) },
|
{ "webinterface", webinterface_options, ARRAY_SIZE(webinterface_options) },
|
||||||
|
{ "artwork", artwork_options, ARRAY_SIZE(artwork_options) },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user