mirror of
https://github.com/SuperBFG7/ympd
synced 2025-01-27 01:14:53 +00:00
Feat: add setting to disable coverimages
This commit is contained in:
parent
b195c5c93f
commit
c218b50ac4
@ -26,8 +26,11 @@ streamport = 8000
|
||||
#Manual streamurl, overwrites streamport
|
||||
#streamurl = http://jukebox:8000
|
||||
|
||||
#Enable coverimages
|
||||
coverimage = true
|
||||
|
||||
#Name for coverimages
|
||||
coverimage = folder.jpg
|
||||
coverimagename = folder.jpg
|
||||
|
||||
#myMPD state directory
|
||||
varlibdir = /var/lib/mympd
|
||||
|
@ -200,6 +200,12 @@ a.card-img-top {
|
||||
background-image: url(/assets/coverimage-loading.png);
|
||||
}
|
||||
|
||||
a.card-img-top-nc {
|
||||
display: block;
|
||||
height: 20px;
|
||||
background-color:#ccc;
|
||||
}
|
||||
|
||||
button.active {
|
||||
color: #fff;
|
||||
background-color: #28a745 !important;
|
||||
|
@ -34,7 +34,7 @@
|
||||
<a class="dropdown-item text-light bg-dark" href="#" data-toggle="modal" data-target="#modalSettings">Settings</a>
|
||||
<a class="dropdown-item text-light bg-dark" href="#" data-toggle="modal" data-target="#modalAbout">About</a>
|
||||
<a id="nav-add2homescreen" class="dropdown-item text-light bg-dark hide" href="#">Add2HomeScreen</a>
|
||||
<div id="syscmds"></div>
|
||||
<div id="syscmds" class="featSyscmds"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-toolbar col-auto pl-0 pr-0">
|
||||
@ -87,7 +87,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="album-cover" id="currentCover"></div>
|
||||
<div class="album-cover featCoverimage" id="currentCover"></div>
|
||||
<div class="album-desc">
|
||||
<h2 id="currentTrack" data-href='{"cmd": "songClick", "options": []}'></h2>
|
||||
<div class="featTags">
|
||||
@ -918,7 +918,7 @@
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="album-cover"></div>
|
||||
<div class="album-cover featCoverimage"></div>
|
||||
<h1></h1>
|
||||
<div class="table-responsive-md">
|
||||
<table class="table table-sm">
|
||||
|
@ -1015,7 +1015,7 @@ function parseSettings(obj) {
|
||||
|
||||
toggleBtn('btnnotifyPage', settings.notificationPage);
|
||||
|
||||
var features = ["featStickers", "featSmartpls", "featPlaylists", "featTags"];
|
||||
var features = ["featStickers", "featSmartpls", "featPlaylists", "featTags", "featLocalplayer", "featSyscmds", "featCoverimage"];
|
||||
|
||||
for (var j = 0; j < features.length; j++) {
|
||||
var Els = document.getElementsByClassName(features[j]);
|
||||
@ -1074,7 +1074,7 @@ function parseSettings(obj) {
|
||||
filterCols('colsBrowsePlaylistsDetail');
|
||||
filterCols('colsBrowseFilesystem');
|
||||
|
||||
if (settings.localplayer) {
|
||||
if (settings.featLocalplayer) {
|
||||
if (settings.streamurl == '') {
|
||||
settings.mpdstream = 'http://';
|
||||
if (settings.mpdhost == '127.0.0.1' || settings.mpdhost == 'localhost')
|
||||
@ -1085,10 +1085,7 @@ function parseSettings(obj) {
|
||||
}
|
||||
else
|
||||
settings.mpdstream = settings.streamurl;
|
||||
document.getElementsByClassName('featLocalplayer')[0].classList.remove('hide');
|
||||
}
|
||||
else
|
||||
document.getElementsByClassName('featLocalplayer')[0].classList.add('hide');
|
||||
|
||||
addTagList('BrowseDatabaseByTagDropdown', 'browsetags');
|
||||
addTagList('searchqueuetags', 'searchtags');
|
||||
@ -1623,7 +1620,7 @@ function parseListDBtags(obj) {
|
||||
card.setAttribute('id', id);
|
||||
card.setAttribute('data-album', encodeURI(obj.data[i].value));
|
||||
card.innerHTML = '<div class="card mb-4" id="card' + id + '">' +
|
||||
' <a href="#" class="card-img-top"></a>' +
|
||||
(settings.featCoverimage ? ' <a href="#" class="card-img-top"></a>' : '<a href="#" class="card-img-top-nc"></a>') +
|
||||
' <div class="card-body">' +
|
||||
' <h5 class="card-title" id="albumartist' + id + '"></h5>' +
|
||||
' <h4 class="card-title">' + obj.data[i].value + '</h4>' +
|
||||
@ -1717,10 +1714,17 @@ function parseListTitles(obj) {
|
||||
var card = document.getElementById('card' + id)
|
||||
var tbody = card.getElementsByTagName('tbody')[0];
|
||||
var img = card.getElementsByTagName('a')[0];
|
||||
img.style.backgroundImage = 'url("' + obj.cover + '")';
|
||||
if (img.classList.contains('card-img-top'))
|
||||
img.style.backgroundImage = 'url("' + obj.cover + '")';
|
||||
else
|
||||
img.style.backgroundImage = '';
|
||||
img.setAttribute('data-uri', encodeURI(obj.data[0].uri.replace(/\/[^\/]+$/, '')));
|
||||
img.setAttribute('data-name', obj.Album);
|
||||
img.setAttribute('data-type', 'dir');
|
||||
img.addEventListener('click', function(event) {
|
||||
showMenu(this, event);
|
||||
}, false);
|
||||
|
||||
document.getElementById('albumartist' + id).innerText = obj.AlbumArtist;
|
||||
|
||||
var titleTable = document.getElementById('collapseLink' + id);
|
||||
@ -1742,10 +1746,6 @@ function parseListTitles(obj) {
|
||||
'</tr>';
|
||||
}
|
||||
tbody.innerHTML = titleList;
|
||||
|
||||
img.addEventListener('click', function(event) {
|
||||
showMenu(this, event);
|
||||
}, false);
|
||||
|
||||
tbody.parentNode.addEventListener('click', function(event) {
|
||||
if (event.target.nodeName == 'TD') {
|
||||
@ -2227,11 +2227,11 @@ function showMenu(el, event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
hideMenu();
|
||||
|
||||
if (el.getAttribute('data-init'))
|
||||
return;
|
||||
|
||||
hideMenu();
|
||||
|
||||
var type = el.getAttribute('data-type');
|
||||
var uri = decodeURI(el.getAttribute('data-uri'));
|
||||
var name = el.getAttribute('data-name');
|
||||
|
@ -1350,8 +1350,8 @@ int mympd_put_settings(char *buffer) {
|
||||
|
||||
len = json_printf(&out, "{type: settings, data: {"
|
||||
"repeat: %d, single: %d, crossfade: %d, consume: %d, random: %d, "
|
||||
"mixrampdb: %f, mixrampdelay: %f, mpdhost: %Q, mpdport: %d, passwort_set: %B, featSyscmds: %B, featPlaylists: %B, featTags: %B, "
|
||||
"localplayer: %B, streamport: %d, streamurl: %Q, coverimage: %Q, featStickers: %B, mixramp: %B, featSmartpls: %B, maxElementsPerPage: %d, "
|
||||
"mixrampdb: %f, mixrampdelay: %f, mpdhost: %Q, mpdport: %d, passwort_set: %B, featSyscmds: %B, featPlaylists: %B, featTags: %B, featLibrary: %B, "
|
||||
"featLocalplayer: %B, streamport: %d, streamurl: %Q, featCoverimage: %B, coverimagename: %Q, featStickers: %B, mixramp: %B, featSmartpls: %B, maxElementsPerPage: %d, "
|
||||
"replaygain: %Q, notificationWeb: %B, notificationPage: %B, jukeboxMode: %d, jukeboxPlaylist: %Q, jukeboxQueueLength: %d, "
|
||||
"tags: [",
|
||||
mpd_status_get_repeat(status),
|
||||
@ -1367,10 +1367,12 @@ int mympd_put_settings(char *buffer) {
|
||||
config.syscmds,
|
||||
mpd.feat_playlists,
|
||||
mpd.feat_tags,
|
||||
mpd.feat_library,
|
||||
config.localplayer,
|
||||
config.streamport,
|
||||
config.streamurl,
|
||||
config.coverimage,
|
||||
config.coverimagename,
|
||||
config.stickers,
|
||||
config.mixramp,
|
||||
config.smartpls,
|
||||
@ -1480,7 +1482,11 @@ int replacechar(char *str, char orig, char rep) {
|
||||
int mympd_get_cover(const char *uri, char *cover, int cover_len) {
|
||||
char *path = strdup(uri);
|
||||
int len;
|
||||
if (strncasecmp("http:", path, 5) == 0 || strncasecmp("https:", path, 6) == 0) {
|
||||
|
||||
if (!config.coverimage) {
|
||||
len = snprintf(cover, cover_len, "/assets/coverimage-notavailable.png");
|
||||
}
|
||||
else if (strncasecmp("http:", path, 5) == 0 || strncasecmp("https:", path, 6) == 0) {
|
||||
if(strlen(path) > 8) {
|
||||
if (strncasecmp("http:", path, 5) == 0)
|
||||
path += 7;
|
||||
@ -1489,23 +1495,23 @@ int mympd_get_cover(const char *uri, char *cover, int cover_len) {
|
||||
replacechar(path, '/', '_');
|
||||
replacechar(path, '.', '_');
|
||||
snprintf(cover, cover_len, "%s/pics/%s.png", SRC_PATH, path);
|
||||
if (access(cover, F_OK ) == -1 ) {
|
||||
if (access(cover, F_OK ) == -1 )
|
||||
len = snprintf(cover, cover_len, "/assets/coverimage-httpstream.png");
|
||||
} else {
|
||||
else
|
||||
len = snprintf(cover, cover_len, "/pics/%s.png", path);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
len = snprintf(cover, cover_len, "/assets/coverimage-httpstream.png");
|
||||
}
|
||||
}
|
||||
else {
|
||||
dirname(path);
|
||||
snprintf(cover, cover_len, "%s/library/%s/%s", SRC_PATH, path, config.coverimage);
|
||||
if (access(cover, F_OK ) == -1 ) {
|
||||
if (mpd.feat_library) {
|
||||
dirname(path);
|
||||
snprintf(cover, cover_len, "%s/library/%s/%s", SRC_PATH, path, config.coverimagename);
|
||||
if (access(cover, F_OK ) == -1 )
|
||||
len = snprintf(cover, cover_len, "/assets/coverimage-notavailable.png");
|
||||
else
|
||||
len = snprintf(cover, cover_len, "/library/%s/%s", path, config.coverimagename);
|
||||
} else
|
||||
len = snprintf(cover, cover_len, "/assets/coverimage-notavailable.png");
|
||||
} else {
|
||||
len = snprintf(cover, cover_len, "/library/%s/%s", path, config.coverimage);
|
||||
}
|
||||
}
|
||||
free(path);
|
||||
return len;
|
||||
|
@ -164,6 +164,7 @@ struct t_mpd {
|
||||
bool feat_sticker;
|
||||
bool feat_playlists;
|
||||
bool feat_tags;
|
||||
bool feat_library;
|
||||
} mpd;
|
||||
|
||||
struct list mpd_tags;
|
||||
@ -183,7 +184,8 @@ typedef struct {
|
||||
const char* sslcert;
|
||||
const char* sslkey;
|
||||
const char* user;
|
||||
const char* coverimage;
|
||||
bool coverimage;
|
||||
const char* coverimagename;
|
||||
bool stickers;
|
||||
bool mixramp;
|
||||
const char* taglist;
|
||||
|
19
src/mympd.c
19
src/mympd.c
@ -151,7 +151,12 @@ static int inihandler(void* user, const char* section, const char* name, const c
|
||||
else if (MATCH("streamport"))
|
||||
p_config->streamport = strtol(value, &crap, 10);
|
||||
else if (MATCH("coverimage"))
|
||||
p_config->coverimage = strdup(value);
|
||||
if (strcmp(value, "true") == 0)
|
||||
p_config->coverimage = true;
|
||||
else
|
||||
p_config->coverimage = false;
|
||||
else if (MATCH("coverimagename"))
|
||||
p_config->coverimagename = strdup(value);
|
||||
else if (MATCH("varlibdir"))
|
||||
p_config->varlibdir = strdup(value);
|
||||
else if (MATCH("stickers"))
|
||||
@ -341,7 +346,8 @@ int main(int argc, char **argv) {
|
||||
config.user = "mympd";
|
||||
config.streamport = 8000;
|
||||
config.streamurl = "";
|
||||
config.coverimage = "folder.jpg";
|
||||
config.coverimage = true;
|
||||
config.coverimagename = "folder.jpg";
|
||||
config.varlibdir = "/var/lib/mympd";
|
||||
config.stickers = true;
|
||||
config.mixramp = true;
|
||||
@ -358,6 +364,7 @@ int main(int argc, char **argv) {
|
||||
mpd.timeout = 3000;
|
||||
mpd.last_update_sticker_song_id = -1;
|
||||
mpd.last_song_id = -1;
|
||||
mpd.feat_library = false;
|
||||
|
||||
if (argc == 2) {
|
||||
printf("Parsing config file: %s\n", argv[1]);
|
||||
@ -445,6 +452,14 @@ int main(int argc, char **argv) {
|
||||
if (!testdir("Document root", SRC_PATH))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
snprintf(testdirname, 400, "%s/library", SRC_PATH);
|
||||
if (testdir("Link to mpd music_directory", testdirname)) {
|
||||
mpd.feat_library = true;
|
||||
printf("Enabling coverimage support\n");
|
||||
}
|
||||
else
|
||||
printf("Disabling coverimage support\n");
|
||||
|
||||
snprintf(testdirname, 400, "%s/tmp", config.varlibdir);
|
||||
if (!testdir("Temp dir", testdirname))
|
||||
return EXIT_FAILURE;
|
||||
|
Loading…
Reference in New Issue
Block a user