Skip to content

Commit

Permalink
Feat: Add option to disable WebradioDB integration #1071
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Jun 25, 2024
1 parent fdfdb5f commit 896c698
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 33 deletions.
7 changes: 7 additions & 0 deletions cli_tools/mympd-config/mympd-config
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ set_default() {
MYMPD_CUSTOM_CERT="false"
MYMPD_SSL_CERT=""
MYMPD_SSL_KEY=""
MYMPD_WEBRADIODB="true"
}

read_config() {
Expand All @@ -109,6 +110,7 @@ read_config() {
[ -f "${CONFIG_DIR}/custom_cert" ] && read -r MYMPD_CUSTOM_CERT < "${CONFIG_DIR}/custom_cert"
[ -f "${CONFIG_DIR}/ssl_cert" ] && read -r MYMPD_SSL_CERT < "${CONFIG_DIR}/ssl_cert"
[ -f "${CONFIG_DIR}/ssl_key" ] && read -r MYMPD_SSL_KEY < "${CONFIG_DIR}/ssl_key"
[ -f "${CONFIG_DIR}/webradiodb" ] && read -r MYMPD_WEBRADIODB < "${CONFIG_DIR}/webradiodb"
}

apply_config() {
Expand Down Expand Up @@ -137,6 +139,7 @@ apply_config() {
-E MYMPD_CUSTOM_CERT="$MYMPD_CUSTOM_CERT" \
-E MYMPD_SSL_CERT="$MYMPD_SSL_CERT" \
-E MYMPD_SSL_KEY="$MYMPD_SSL_KEY" \
-E MYMPD_WEBRADIODB="$MYMPD_WEBRADIODB" \
$MYMPD_BIN -c
else
export MYMPD_ACL
Expand All @@ -161,6 +164,7 @@ apply_config() {
export MYMPD_CUSTOM_CERT
export MYMPD_SSL_CERT
export MYMPD_SSL_KEY
export MYMPD_WEBRADIODB
$MYMPD_BIN -c
fi
}
Expand Down Expand Up @@ -275,6 +279,7 @@ menu_misc() {
"Save Caches" "$MYMPD_SAVE_CACHES" \
"Enable stickers" "$MYMPD_STICKERS" \
"Enable sticker padding" "$MYMPD_STICKERS_PAD_INT" \
"Enable WebradioDB" "$MYMPD_WEBRADIODB" \
3>&1 1>&2 2>&3)
case "$SELECT" in
"Album group tag") MYMPD_ALBUM_GROUP_TAG=$(get_input "$SELECT" "$MYMPD_ALBUM_GROUP_TAG") ;;
Expand All @@ -288,6 +293,7 @@ menu_misc() {
"Save Caches") MYMPD_SAVE_CACHES=$(toggle_bool "$MYMPD_SAVE_CACHES") ;;
"Enable stickers") MYMPD_STICKERS=$(toggle_bool "$MYMPD_STICKERS") ;;
"Enable sticker padding") MYMPD_STICKERS_PAD_INT=$(toggle_bool "$MYMPD_STICKERS_PAD_INT") ;;
"Enable WebradioDB") MYMPD_WEBRADIODB=$(toggle_bool "$MYMPD_WEBRADIODB") ;;
"") return ;;
esac
menu_misc
Expand Down Expand Up @@ -338,6 +344,7 @@ parse_options() {
MYMPD_CUSTOM_CERT) MYMPD_CUSTOM_CERT="$2" ;;
MYMPD_SSL_CERT) MYMPD_SSL_CERT="$2" ;;
MYMPD_SSL_KEY) MYMPD_SSL_KEY="$2" ;;
MYMPD_WEBRADIODB) MYMPD_WEBRADIODB="$2" ;;
*)
echo "Invalid configuration setting"
exit 1
Expand Down
1 change: 1 addition & 0 deletions docs/configuration/configuration-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ systemd-run -p DynamicUser=yes -p StateDirectory=mympd -p CacheDirectory=mympd -
| scriptacl | string | MYMPD_SCRIPTACL | +127.0.0.1 | ACL to access the myMPD script backend: [ACL]({{ site.baseurl }}/configuration/acl), allows only local connections in the default configuration. The acl above must also grant access. |
| stickers | boolean | MYMPD_STICKERS | true | Enables the support for MPD stickers. |
| stickers_pad_int | boolean | MYMPD_STICKERS_PAD_INT | false | Enables the padding of integer sticker values (12 digits). |
| webradiodb | boolean | MYMPD_WEBRADIODB | true | Enables the WebradioDB integration. |
{: .table .table-sm }

1. If http_port is disabled: The MPD curl plugin must trust the myMPD CA or certificate checking must be disabled. MPD fetches webradio playlists with http(s) from myMPD webserver.
Expand Down
28 changes: 14 additions & 14 deletions docs/references/translating_status.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
- bg-BG: 1048 missing phrases
- es-AR: 2 missing phrases
- es-ES: 914 missing phrases
- es-VE: 904 missing phrases
- fi-FI: 901 missing phrases
- fr-FR: 2 missing phrases
- it-IT: 32 missing phrases
- ja-JP: 2 missing phrases
- ko-KR: 2 missing phrases
- nl-NL: 2 missing phrases
- pl-PL: 77 missing phrases
- ru-RU: 148 missing phrases
- zh-Hans: 30 missing phrases
- zh-Hant: 77 missing phrases
- bg-BG: 1049 missing phrases
- es-AR: 3 missing phrases
- es-ES: 915 missing phrases
- es-VE: 905 missing phrases
- fi-FI: 902 missing phrases
- fr-FR: 3 missing phrases
- it-IT: 33 missing phrases
- ja-JP: 3 missing phrases
- ko-KR: 3 missing phrases
- nl-NL: 3 missing phrases
- pl-PL: 78 missing phrases
- ru-RU: 149 missing phrases
- zh-Hans: 31 missing phrases
- zh-Hant: 78 missing phrases
10 changes: 5 additions & 5 deletions htdocs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ <h2 data-phrase="Action for selection" class="dropdown-header"></h2>
<button data-title-phrase="Select view" class="btn btn-secondary dropdown-toggle mi" type="button" data-bs-toggle="dropdown">layers</button>
<div class="dropdown-menu px-2" id="BrowseRadioFavoritesNavDropdown"></div>
</div>
<div class="btn-group me-2">
<div class="btn-group me-2 featWebradioDB">
<button data-title-phrase="Browse WebradioDB" class="btn btn-secondary mi" data-href='{"cmd": "appGoto", "options": ["Browse", "Radio", "Webradiodb"]}'>radio</button>
</div>
<div class="btn-group me-2">
Expand Down Expand Up @@ -2946,10 +2946,10 @@ <h5 class="modal-title"><span class="mi title-icon">favorite</span> <span data-p
<label class="col-sm-4 col-form-label" data-phrase="WebradioDB"></label>
<div class="col-sm-8">
<p id="webradiodbCheckState"></p>
<button id="modalRadioFavoriteEditAddToWebradiodbBtn" type="button" class="btn btn-success me-2 d-none" data-href='{"cmd": "addToWebradioDb", "options": []}' data-phrase="Add to WebradioDB"></button>
<button id="modalRadioFavoriteEditCheckWebradiodbBtn" type="button" class="btn btn-success me-2 d-none" data-href='{"cmd": "checkWebradioDb", "options": []}' data-phrase="Check WebradioDB"></button>
<button id="modalRadioFavoriteEditUpdateFromWebradiodbBtn" type="button" class="btn btn-success me-2 d-none" data-href='{"cmd": "updateFromWebradioDb", "options": []}' data-phrase="Update from WebradioDB"></button>
<button id="modalRadioFavoriteEditUpdateWebradiodbBtn" type="button" class="btn btn-success me-2 d-none" data-href='{"cmd": "updateWebradioDb", "options": []}' data-phrase="Update WebradioDB"></button>
<button id="modalRadioFavoriteEditAddToWebradiodbBtn" type="button" class="btn btn-success me-2 d-none featWebradioDB" data-href='{"cmd": "addToWebradioDb", "options": []}' data-phrase="Add to WebradioDB"></button>
<button id="modalRadioFavoriteEditCheckWebradiodbBtn" type="button" class="btn btn-success me-2 d-none featWebradioDB" data-href='{"cmd": "checkWebradioDb", "options": []}' data-phrase="Check WebradioDB"></button>
<button id="modalRadioFavoriteEditUpdateFromWebradiodbBtn" type="button" class="btn btn-success me-2 d-none featWebradioDB" data-href='{"cmd": "updateFromWebradioDb", "options": []}' data-phrase="Update from WebradioDB"></button>
<button id="modalRadioFavoriteEditUpdateWebradiodbBtn" type="button" class="btn btn-success me-2 d-none featWebradioDB" data-href='{"cmd": "updateWebradioDb", "options": []}' data-phrase="Update WebradioDB"></button>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions htdocs/js/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function setFeatures() {
features.featStickersEnabled = settings.features.featStickersEnabled;
features.featFooterAudioFormat = settings.webuiSettings.footerAudioFormat;
features.featMygpiod = settings.features.featMygpiod;
features.featWebradioDB = settings.features.featWebradioDB;

//mpd features
if (settings.partition.mpdConnected === true) {
Expand Down
1 change: 1 addition & 0 deletions src/compile_time.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ extern struct t_mympd_queue *mympd_api_queue;
#define CFG_MYMPD_ALBUM_GROUP_TAG "Date"
#define CFG_MYMPD_STICKERS true
#define CFG_MYMPD_STICKERS_PAD_INT false
#define CFG_MYMPD_WEBRADIODB true

//default partition state settings
#define PARTITION_HIGHLIGHT_COLOR "#28a745"
Expand Down
20 changes: 10 additions & 10 deletions src/i18n/json/i18n.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"default": {"desc":"Browser default", "missingPhrases": 0},
"de-DE": {"desc":"Deutsch (de-DE)", "missingPhrases": 2},
"de-DE": {"desc":"Deutsch (de-DE)", "missingPhrases": 3},
"en-US": {"desc":"English (en-US)", "missingPhrases": 0},
"es-AR": {"desc":"Español (es-AR)", "missingPhrases": 2},
"fr-FR": {"desc":"Français (fr-FR)", "missingPhrases": 2},
"it-IT": {"desc":"Italiano (it-IT)", "missingPhrases": 32},
"ja-JP": {"desc":"日本語 (ja-JP)", "missingPhrases": 2},
"ko-KR": {"desc":"한국어 (ko-KR)", "missingPhrases": 2},
"nl-NL": {"desc":"Nederlands (nl-NL)", "missingPhrases": 2},
"pl-PL": {"desc":"Polish (pl-PL)", "missingPhrases": 77},
"zh-Hans": {"desc":"简体中文 (zh-Hans)", "missingPhrases": 30},
"zh-Hant": {"desc":"简体中文 (zh-Hant)", "missingPhrases": 77}
"es-AR": {"desc":"Español (es-AR)", "missingPhrases": 3},
"fr-FR": {"desc":"Français (fr-FR)", "missingPhrases": 3},
"it-IT": {"desc":"Italiano (it-IT)", "missingPhrases": 33},
"ja-JP": {"desc":"日本語 (ja-JP)", "missingPhrases": 3},
"ko-KR": {"desc":"한국어 (ko-KR)", "missingPhrases": 3},
"nl-NL": {"desc":"Nederlands (nl-NL)", "missingPhrases": 3},
"pl-PL": {"desc":"Polish (pl-PL)", "missingPhrases": 78},
"zh-Hans": {"desc":"简体中文 (zh-Hans)", "missingPhrases": 31},
"zh-Hant": {"desc":"简体中文 (zh-Hant)", "missingPhrases": 78}
}
1 change: 1 addition & 0 deletions src/i18n/json/phrases.json
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,7 @@
{"term":"Webradio favorite successfully saved"},
{"term":"Webradio favorites"},
{"term":"WebradioDB"},
{"term":"WebradioDB is disabled"},
{"term":"WebradioDB update failed"},
{"term":"WebradioDB update started"},
{"term":"Webradioformat"},
Expand Down
2 changes: 2 additions & 0 deletions src/lib/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ void mympd_config_defaults(struct t_config *config) {
config->mympd_uri = startup_getenv_string("MYMPD_URI", CFG_MYMPD_URI, vcb_isname, config->first_startup);
config->stickers = startup_getenv_bool("MYMPD_STICKERS", CFG_MYMPD_STICKERS, config->first_startup);
config->stickers_pad_int = startup_getenv_bool("MYMPD_STICKERS_PAD_INT", CFG_MYMPD_STICKERS_PAD_INT, config->first_startup);
config->webradiodb = startup_getenv_bool("MYMPD_WEBRADIODB", CFG_MYMPD_WEBRADIODB, config->first_startup);

sds album_mode_str = startup_getenv_string("MYMPD_ALBUM_MODE", CFG_MYMPD_ALBUM_MODE, vcb_isname, config->first_startup);
config->albums.mode = parse_album_mode(album_mode_str);
Expand Down Expand Up @@ -212,6 +213,7 @@ bool mympd_config_rw(struct t_config *config, bool write) {
config->mympd_uri = state_file_rw_string_sds(config->workdir, DIR_WORK_CONFIG, "mympd_uri", config->mympd_uri, vcb_isname, write);
config->stickers = state_file_rw_bool(config->workdir, DIR_WORK_CONFIG, "stickers", config->stickers, write);
config->stickers_pad_int = state_file_rw_bool(config->workdir, DIR_WORK_CONFIG, "stickers_pad_int", config->stickers_pad_int, write);
config->webradiodb = state_file_rw_bool(config->workdir, DIR_WORK_CONFIG, "webradiodb", config->webradiodb, write);

sds album_mode_str = state_file_rw_string(config->workdir, DIR_WORK_CONFIG, "album_mode", lookup_album_mode(config->albums.mode), vcb_isname, write);
config->albums.mode = parse_album_mode(album_mode_str);
Expand Down
1 change: 1 addition & 0 deletions src/lib/config_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct t_config {
bool ssl; //!< enable listening on ssl_port
bool stickers; //!< enable sticker support
bool stickers_pad_int; //!< enable the padding of integer sticker values
bool webradiodb; //!< enable webradiodb support
struct t_albums_config albums; //!< album specific config
int cache_cover_keep_days; //!< expiration time for cover cache files in days
int cache_lyrics_keep_days; //!< expiration time for lyrics cache files in days
Expand Down
5 changes: 5 additions & 0 deletions src/mpd_worker/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@ void mpd_worker_api(struct t_mpd_worker_state *mpd_worker_state) {
}
break;
case MYMPD_API_WEBRADIODB_UPDATE:
if (mpd_worker_state->config->webradiodb == false) {
response->data = jsonrpc_respond_message(response->data, request->cmd_id, request->id,
JSONRPC_FACILITY_PLAYLIST, JSONRPC_SEVERITY_INFO, "WebradioDB is disabled");
break;
}
if (json_get_bool(request->data, "$.params.force", &bool_buf1, &parse_error) == true) {
response->data = jsonrpc_respond_message(response->data, request->cmd_id, request->id,
JSONRPC_FACILITY_PLAYLIST, JSONRPC_SEVERITY_INFO, "WebradioDB update started");
Expand Down
10 changes: 6 additions & 4 deletions src/mympd_api/mympd_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ void *mympd_api_loop(void *arg_config) {
album_cache_read(&mympd_state->album_cache, mympd_state->config->workdir, &mympd_state->config->albums);
}
//webradiodb
webradios_read_from_disk(mympd_state->config, mympd_state->webradiodb, FILENAME_WEBRADIODB);
if (mympd_state->config->webradiodb == true) {
webradios_read_from_disk(mympd_state->config, mympd_state->webradiodb, FILENAME_WEBRADIODB);
MYMPD_LOG_DEBUG(NULL, "Adding timer for WebradioDB update to execute periodic each day");
mympd_api_timer_add(&mympd_state->timer_list, TIMER_WEBRADIODB_UPDATE_OFFSET, TIMER_WEBRADIODB_UPDATE_INTERVAL,
timer_handler_by_id, TIMER_ID_WEBRADIODB_UPDATE, NULL);
}
// set timers
MYMPD_LOG_DEBUG(NULL, "Adding timer for cache cropping to execute periodic each day");
mympd_api_timer_add(&mympd_state->timer_list, TIMER_DISK_CACHE_CLEANUP_OFFSET, TIMER_DISK_CACHE_CLEANUP_INTERVAL,
timer_handler_by_id, TIMER_ID_DISK_CACHE_CROP, NULL);
MYMPD_LOG_DEBUG(NULL, "Adding timer for WebradioDB update to execute periodic each day");
mympd_api_timer_add(&mympd_state->timer_list, TIMER_WEBRADIODB_UPDATE_OFFSET, TIMER_WEBRADIODB_UPDATE_INTERVAL,
timer_handler_by_id, TIMER_ID_WEBRADIODB_UPDATE, NULL);

// start trigger
mympd_api_trigger_execute(&mympd_state->trigger_list, TRIGGER_MYMPD_START, MPD_PARTITION_ALL, NULL);
Expand Down
1 change: 1 addition & 0 deletions src/mympd_api/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,7 @@ sds mympd_api_settings_get(struct t_mympd_state *mympd_state, struct t_partition
buffer = tojson_bool(buffer, "featDbAdded", partition_state->mpd_state->feat.db_added, true);
buffer = tojson_bool(buffer, "featStickerSortWindow", partition_state->mpd_state->feat.sticker_sort_window, true);
buffer = tojson_bool(buffer, "featStickerInt", partition_state->mpd_state->feat.sticker_int, true);
buffer = tojson_bool(buffer, "featWebradioDB", partition_state->config->webradiodb, true);
}
buffer = tojson_bool(buffer, "featCacert", (mympd_state->config->custom_cert == false && mympd_state->config->ssl == true ? true : false), true);
#ifdef MYMPD_ENABLE_MYGPIOD
Expand Down

0 comments on commit 896c698

Please sign in to comment.