Skip to content

Commit

Permalink
Feat: Use new webradio backends
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Jul 6, 2024
1 parent 432265a commit ef0465b
Show file tree
Hide file tree
Showing 25 changed files with 249 additions and 437 deletions.
22 changes: 11 additions & 11 deletions docs/references/translating_status.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
- bg-BG: 1051 missing phrases
- es-AR: 6 missing phrases
- es-AR: 7 missing phrases
- es-ES: 916 missing phrases
- es-VE: 905 missing phrases
- fi-FI: 902 missing phrases
- fr-FR: 6 missing phrases
- it-IT: 6 missing phrases
- ja-JP: 6 missing phrases
- ko-KR: 6 missing phrases
- nl-NL: 6 missing phrases
- pl-PL: 81 missing phrases
- es-VE: 904 missing phrases
- fi-FI: 901 missing phrases
- fr-FR: 7 missing phrases
- it-IT: 7 missing phrases
- ja-JP: 7 missing phrases
- ko-KR: 7 missing phrases
- nl-NL: 7 missing phrases
- pl-PL: 82 missing phrases
- ru-RU: 152 missing phrases
- zh-Hans: 34 missing phrases
- zh-Hant: 81 missing phrases
- zh-Hans: 35 missing phrases
- zh-Hant: 82 missing phrases
77 changes: 50 additions & 27 deletions htdocs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -801,10 +801,36 @@ <h2 data-phrase="Action for selection" class="dropdown-header"></h2>
<div class="btn-group me-2">
<button data-title-phrase="Manually add webradio favorite" data-href='{"cmd": "manualAddRadioFavorite", "options": []}' type="button" class="btn btn-secondary mi">add</button>
</div>
<div class="input-group flex-grow-1 me-2">
<span class="input-group-text border-secondary bg-secondary mi">search</span>
<div class="input-group me-2 flex-grow-1">
<div class="btn-group">
<button data-title-phrase="Select tag to search" class="btn btn-secondary dropdown-toggle rounded-end-0" type="button" data-bs-toggle="dropdown">
<span class="mi">search</span>
<span data-phrase="Name" id="BrowseRadioFavoritesSearchTagsDesc"></span>
</button>
<div class="dropdown-menu px-2" id="BrowseRadioFavoritesSearchTags"></div>
</div>
<select class="form-select rounded-0 no-flex" id="BrowseRadioFavoritesSearchMatch">
<option data-phrase="contains" value="contains"></option>
<option data-phrase="starts_with" value="starts_with"></option>
<option value="==">==</option>
<option value="=~" class="featPcre">=~</option>
<option value="!=">!=</option>
<option value="!~" class="featPcre">!~</option>
<option id="BrowseRadioFavoritesSearchBitrateMatch" value=">=">&gt;=</option>
</select>
<input data-is="mympd-input-clear" data-clear-event="keydown" data-placeholder-phrase="Search" class="form-control rounded-end" id="BrowseRadioFavoritesSearchStr"/>
</div>
<div class="btn-group me-2">
<button id="BrowseRadioFavoritesSortDropdown" data-title-phrase="Sort by" class="btn btn-secondary dropdown-toggle mi" type="button" data-bs-toggle="dropdown">sort</button>
<div class="dropdown-menu px-2" id="BrowseRadioFavoritesSortTags">
<div id="BrowseRadioFavoritesSortTagsList"></div>
<div class="dropdown-divider"></div>
<div class="form-check">
<button class="btn btn-secondary btn-xs mi mi-sm" id="BrowseRadioFavoritesSortDesc">radio_button_unchecked</button>&nbsp;
<label class="form-check-label" for="BrowseRadioFavoritesSortDesc" data-phrase="Descending"></label>
</div>
</div>
</div>
<div class="btn-group me-2">
<button data-title-phrase="Select" id="BrowseRadioFavoritesListSelectModeBtn" data-href='{"cmd": "switchListMode", "options": ["target"]}' type="button" class="btn btn-secondary mi rounded-end">checklist_rtl</button>
<button data-title-phrase="Action for selection" class="btn btn-secondary dropdown-toggle mi d-none" type="button" data-bs-toggle="dropdown">add_task</button>
Expand All @@ -823,6 +849,7 @@ <h2 data-phrase="Action for selection" class="dropdown-header"></h2>
</div>
<div id="BrowseRadioFavoritesPaginationTop" class="btn-group me-2 pagination"></div>
</div>
<div class="breadcrumb p-2 rounded-2 d-none" id="BrowseRadioFavoritesSearchCrumb"></div>
<div id="BrowseRadioFavoritesContainer"></div>
<div class="btn-toolbar d-none justify-content-between" id="BrowseRadioFavoritesButtonsBottom"></div>
</div>
Expand All @@ -837,29 +864,24 @@ <h2 data-phrase="Action for selection" class="dropdown-header"></h2>
<div class="btn-group me-2">
<button data-title-phrase="Webradio favorites" data-href='{"cmd": "appGoto", "options": ["Browse", "Radio", "Favorites"]}' type="button" class="btn btn-secondary mi">favorite</button>
</div>
<div class="input-group flex-grow-1 me-2">
<span class="input-group-text border-secondary bg-secondary mi">search</span>
<input data-is="mympd-input-clear" data-clear-event="keydown" data-placeholder-phrase="Search" class="form-control rounded-end" id="BrowseRadioWebradiodbSearchStr"/>
</div>
<div class="btn-group me-2">
<button id="BrowseRadioWebradiodbFilterBtn" data-title-phrase="Filter" class="btn btn-secondary rounded-end mi" type="button" data-bs-target="#BrowseRadioWebradiodbFilter" data-bs-toggle="collapse">filter_list_off</button>
</div>
<div class="collapse btn-group2" id="BrowseRadioWebradiodbFilter">
<div class="btn-group position-relative me-2">
<input readonly="readonly" data-is="mympd-select-search" id="BrowseRadioWebradiodbGenreFilter" class="form-select" data-placeholder-phrase="Genre"/>
</div>
<div class="btn-group position-relative me-2">
<input readonly="readonly" data-is="mympd-select-search" id="BrowseRadioWebradiodbCountryFilter" class="form-select" data-placeholder-phrase="Country"/>
</div>
<div class="btn-group position-relative me-2">
<input readonly="readonly" data-is="mympd-select-search" id="BrowseRadioWebradiodbLanguageFilter" class="form-select" data-placeholder-phrase="Language"/>
</div>
<div class="btn-group position-relative me-2">
<input readonly="readonly" data-is="mympd-select-search" id="BrowseRadioWebradiodbCodecFilter" class="form-select" data-placeholder-phrase="Codec"/>
</div>
<div class="btn-group position-relative me-2">
<input readonly="readonly" data-is="mympd-select-search" id="BrowseRadioWebradiodbBitrateFilter" class="form-select" data-placeholder-phrase="Bitrate"/>
<div class="input-group me-2 flex-grow-1">
<div class="btn-group">
<button data-title-phrase="Select tag to search" class="btn btn-secondary dropdown-toggle rounded-end-0" type="button" data-bs-toggle="dropdown">
<span class="mi">search</span>
<span data-phrase="Name" id="BrowseRadioWebradiodbSearchTagsDesc"></span>
</button>
<div class="dropdown-menu px-2" id="BrowseRadioWebradiodbSearchTags"></div>
</div>
<select class="form-select rounded-0 no-flex" id="BrowseRadioWebradiodbSearchMatch">
<option data-phrase="contains" value="contains"></option>
<option data-phrase="starts_with" value="starts_with"></option>
<option value="==">==</option>
<option value="=~" class="featPcre">=~</option>
<option value="!=">!=</option>
<option value="!~" class="featPcre">!~</option>
<option id="BrowseRadioWebradiodbSearchBitrateMatch" value=">=">&gt;=</option>
</select>
<input data-is="mympd-input-clear" data-clear-event="keydown" data-placeholder-phrase="Search" class="form-control rounded-end" id="BrowseRadioWebradiodbSearchStr"/>
</div>
<div class="btn-group me-2">
<button id="BrowseRadioWebradiodbSortDropdown" data-title-phrase="Sort by" class="btn btn-secondary dropdown-toggle mi" type="button" data-bs-toggle="dropdown">sort</button>
Expand All @@ -868,7 +890,7 @@ <h2 data-phrase="Action for selection" class="dropdown-header"></h2>
<div class="dropdown-divider"></div>
<div class="form-check">
<button class="btn btn-secondary btn-xs mi mi-sm" id="BrowseRadioWebradiodbSortDesc">radio_button_unchecked</button>&nbsp;
<label class="form-check-label" for="SearchSortDesc" data-phrase="Descending"></label>
<label class="form-check-label" for="BrowseRadioWebradiodbSortDesc" data-phrase="Descending"></label>
</div>
</div>
</div>
Expand All @@ -890,6 +912,7 @@ <h2 data-phrase="Action for selection" class="dropdown-header"></h2>
</div>
<div id="BrowseRadioWebradiodbPaginationTop" class="btn-group me-2 pagination"></div>
</div>
<div class="breadcrumb p-2 rounded-2 d-none" id="BrowseRadioWebradiodbSearchCrumb"></div>
<div id="BrowseRadioWebradiodbContainer"></div>
<div class="btn-toolbar d-none justify-content-between" id="BrowseRadioWebradiodbButtonsBottom"></div>
</div>
Expand Down Expand Up @@ -2906,9 +2929,9 @@ <h5 class="modal-title"><span class="mi title-icon">favorite</span> <span data-p
</div>
</div>
<div class="row mb-3">
<label class="col-sm-4 col-form-label" for="modalRadioFavoriteEditStateInput" data-phrase="State"></label>
<label class="col-sm-4 col-form-label" for="modalRadioFavoriteEditRegionInput" data-phrase="Region"></label>
<div class="col-sm-8">
<input class="form-control" id="modalRadioFavoriteEditStateInput"/>
<input class="form-control" id="modalRadioFavoriteEditRegionInput"/>
</div>
</div>
<div class="row mb-3">
Expand Down
8 changes: 6 additions & 2 deletions htdocs/js/apidoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2186,7 +2186,9 @@ const APImethods = {
"params": {
"offset": APIparams.offset,
"limit": APIparams.limit,
"expression": APIparams.expression
"expression": APIparams.expression,
"sort": APIparams.sort,
"sortdesc": APIparams.sortdesc
}
},
"MYMPD_API_WEBRADIO_FAVORITE_SAVE": {
Expand Down Expand Up @@ -2299,7 +2301,9 @@ const APImethods = {
"params": {
"offset": APIparams.offset,
"limit": APIparams.limit,
"expression": APIparams.expression
"expression": APIparams.expression,
"sort": APIparams.sort,
"sortdesc": APIparams.sortdesc
}
},
"MYMPD_API_WEBRADIODB_RADIO_GET_BY_NAME": {
Expand Down
1 change: 1 addition & 0 deletions htdocs/js/contextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ function createMenuLists(target, contextMenuTitle, contextMenuBody) {
switch(type) {
case 'song':
case 'stream':
case 'webradio':
addMenuItemsSongActions(dataNode, contextMenuBody, uri, type, name);
break;
case 'dir':
Expand Down
17 changes: 3 additions & 14 deletions htdocs/js/globales.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ const messagesMax = 100;
/** @type {boolean} */
const debugMode = document.querySelector("script").src.replace(/^.*[/]/, '') === 'combined.js' ? false : true;

/** @type {object} */
let webradioDb = null;
/** @type {string} */
const webradioDbPicsUri = 'https://jcorporation.github.io/webradiodb/db/pics/';

/** @type {string} */
const scriptsUri = 'https://github.com/jcorporation/mympd-scripts/tree/main/';
/** @type {string} */
Expand Down Expand Up @@ -1354,9 +1349,9 @@ app.cards = {
"Favorites": {
"offset": 0,
"limit": 100,
"filter": "",
"filter": "any",
"sort": {
"tag": "",
"tag": "Name",
"desc": false
},
"tag": "",
Expand All @@ -1366,13 +1361,7 @@ app.cards = {
"Webradiodb": {
"offset": 0,
"limit": 100,
"filter": {
"genre": "",
"country": "",
"language": "",
"codec": "",
"bitrate": ""
},
"filter": "any",
"sort": {
"tag": "Name",
"desc": false
Expand Down
58 changes: 21 additions & 37 deletions htdocs/js/modalRadioFavoriteEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function manualAddRadioFavorite() {
"Genre": "",
"Homepage": "",
"Country": "",
"State": "",
"Region": "",
"Language": "",
"Codec": "",
"Bitrate": "",
Expand All @@ -46,13 +46,13 @@ function showEditRadioFavorite(obj) {
elGetById('modalRadioFavoriteEditGenreInput').value = obj.Genre === undefined ? '' : obj.Genre;
elGetById('modalRadioFavoriteEditHomepageInput').value = obj.Homepage === undefined ? '' : obj.Homepage;
elGetById('modalRadioFavoriteEditCountryInput').value = obj.Country === undefined ? '' : obj.Country;
elGetById('modalRadioFavoriteEditStateInput').value = obj.State === undefined ? '' : obj.State;
elGetById('modalRadioFavoriteEditRegionInput').value = obj.Region === undefined ? '' : obj.Region;
elGetById('modalRadioFavoriteEditLanguageInput').value = obj.Language === undefined ? '' : obj.Language;
elGetById('modalRadioFavoriteEditCodecInput').value = obj.Codec === undefined ? '' : obj.Codec;
elGetById('modalRadioFavoriteEditBitrateInput').value = obj.Bitrate === undefined ? '' : obj.Bitrate;
elGetById('modalRadioFavoriteEditDescriptionInput').value = obj.Description === undefined ? '' : obj.Description;

setDataId('modalRadioFavoriteEdit', "StremUriOld", (obj.StreamUri === undefined ? '' : obj.StreamUri));
setDataId('modalRadioFavoriteEdit', "StreamUriOld", (obj.StreamUri === undefined ? '' : obj.StreamUri));

const imageEl = elGetById('modalRadioFavoriteEditImageInput');
getImageList(imageEl, [], 'thumbs');
Expand Down Expand Up @@ -85,7 +85,7 @@ function saveRadioFavorite(target) {
"image": elGetById('modalRadioFavoriteEditImageInput').value,
"homepage": elGetById('modalRadioFavoriteEditHomepageInput').value,
"country": elGetById('modalRadioFavoriteEditCountryInput').value,
"state": elGetById('modalRadioFavoriteEditStateInput').value,
"region": elGetById('modalRadioFavoriteEditRegionInput').value,
"language": elGetById('modalRadioFavoriteEditLanguageInput').value,
"codec": elGetById('modalRadioFavoriteEditCodecInput').value,
"bitrate": Number(elGetById('modalRadioFavoriteEditBitrateInput').value),
Expand All @@ -102,39 +102,21 @@ function saveRadioFavoriteCheckError(obj) {
if (modalApply(obj) === true) {
uiElements.modalRadioFavoriteEdit.hide();
if (app.id === 'BrowseRadioFavorites') {
getRadioFavoriteList();
handleBrowseRadioFavorites();
}
}
}


/**
* Wrapper for _checkWebradioDb that fetches the webradioDB if needed
* @returns {void}
*/
//eslint-disable-next-line no-unused-vars
function checkWebradioDb() {
elGetById('webradiodbCheckState').textContent = tn('Checking...');
btnWaitingId('modalRadioFavoriteEditCheckWebradiodbBtn', true);
if (webradioDb === null) {
//fetch webradiodb database
sendAPI("MYMPD_API_CLOUD_WEBRADIODB_COMBINED_GET", {}, function(obj) {
webradioDb = obj.result.data;
_checkWebradioDb();
}, false);
}
else {
_checkWebradioDb();
}
}

/**
* Checks the local webradio favorite against the webradioDB entry
* @returns {void}
*/
function _checkWebradioDb() {
function checkWebradioDb() {
const streamUri = elGetById('modalRadioFavoriteEditStreamUriInput').value;
if (streamUri !== '') {
//TODO
/*
const webradio = streamUriToName(streamUri) + '.m3u';
if (webradioDb.webradios[webradio] === undefined) {
//not a main streamUri - check for alternate streams
Expand Down Expand Up @@ -174,6 +156,7 @@ function _checkWebradioDb() {
elGetById('webradiodbCheckState').textContent = tn('Favorite is uptodate');
}
}
*/
}
else {
elHideId('modalRadioFavoriteEditAddToWebradiodbBtn');
Expand All @@ -192,8 +175,10 @@ function _checkWebradioDb() {
function compareWebradioDb() {
let v1 = '';
let v2 = '';
//TODO
/*
const webradio = streamUriToName(elGetById('modalRadioFavoriteEditStreamUriInput').value) + '.m3u';
for (const v of ['Name', 'StreamUri', 'Genre', 'Homepage', 'Image', 'Country', 'State', 'Language', 'Description', 'Codec', 'Bitrate']) {
for (const v of ['Name', 'StreamUri', 'Genre', 'Homepage', 'Image', 'Country', 'Region', 'Language', 'Description', 'Codec', 'Bitrate']) {
if (v === 'Image') {
v1 += basename(elGetById('modalRadioFavoriteEdit' + v + 'Input').value, false);
}
Expand All @@ -202,6 +187,7 @@ function compareWebradioDb() {
}
v2 += webradioDb.webradios[webradio][v];
}
*/
return v1 === v2;
}

Expand All @@ -212,15 +198,13 @@ function compareWebradioDb() {
//eslint-disable-next-line no-unused-vars
function updateFromWebradioDb() {
const webradio = streamUriToName(elGetById('modalRadioFavoriteEditStreamUriInput').value) + '.m3u';
for (const v of ['Name', 'StreamUri', 'Genre', 'Homepage', 'Image', 'Country', 'State', 'Language', 'Description', 'Codec', 'Bitrate']) {
if (v === 'Image') {
elGetById('modalRadioFavoriteEdit' + v + 'Input').value = webradioDbPicsUri + webradioDb.webradios[webradio][v];
}
else {
elGetById('modalRadioFavoriteEdit' + v + 'Input').value = webradioDb.webradios[webradio][v];
}
//TODO
/*
for (const v of ['Name', 'StreamUri', 'Genre', 'Homepage', 'Image', 'Country', 'Region', 'Language', 'Description', 'Codec', 'Bitrate']) {
elGetById('modalRadioFavoriteEdit' + v + 'Input').value = webradioDb.webradios[webradio][v];
}
_checkWebradioDb();
*/
checkWebradioDb();
}

/**
Expand All @@ -237,7 +221,7 @@ function addToWebradioDb() {
'&homepage=' + encodeURIComponent(elGetById('modalRadioFavoriteEditHomepageInput').value) +
'&image=' + encodeURIComponent(elGetById('modalRadioFavoriteEditImageInput').value) +
'&country=' + encodeURIComponent(elGetById('modalRadioFavoriteEditCountryInput').value) +
'&state=' + encodeURIComponent(elGetById('modalRadioFavoriteEditStateInput').value) +
'&region=' + encodeURIComponent(elGetById('modalRadioFavoriteEditRegionInput').value) +
'&language=' + encodeURIComponent(elGetById('modalRadioFavoriteEditLanguageInput').value) +
'&codec=' + encodeURIComponent(elGetById('modalRadioFavoriteEditCodecInput').value) +
'&bitrate=' + encodeURIComponent(elGetById('modalRadioFavoriteEditBitrateInput').value) +
Expand All @@ -260,7 +244,7 @@ function updateWebradioDb() {
'&homepage=' + encodeURIComponent(elGetById('modalRadioFavoriteEditHomepageInput').value) +
'&image=' + encodeURIComponent(elGetById('modalRadioFavoriteEditImageInput').value) +
'&country=' + encodeURIComponent(elGetById('modalRadioFavoriteEditCountryInput').value) +
'&state=' + encodeURIComponent(elGetById('modalRadioFavoriteEditStateInput').value) +
'&region=' + encodeURIComponent(elGetById('modalRadioFavoriteEditRegionInput').value) +
'&language=' + encodeURIComponent(elGetById('modalRadioFavoriteEditLanguageInput').value) +
'&codec=' + encodeURIComponent(elGetById('modalRadioFavoriteEditCodecInput').value) +
'&bitrate=' + encodeURIComponent(elGetById('modalRadioFavoriteEditBitrateInput').value) +
Expand Down
Loading

0 comments on commit ef0465b

Please sign in to comment.