1
0
mirror of https://github.com/SuperBFG7/ympd synced 2025-07-04 11:02:49 +00:00

Feat: enable coverimages for http streams

This commit is contained in:
jcorporation 2018-08-22 19:42:23 +01:00
parent e1c9854dea
commit b41b8a3b4e
3 changed files with 42 additions and 9 deletions

View File

@ -680,6 +680,7 @@ function webSocketConnect() {
case 'update_queue':
if (app.current.app === 'Queue')
getQueue();
sendAPI({"cmd": "MPD_API_GET_STATE"}, parseState);
break;
case 'update_options':
getSettings();

View File

@ -61,6 +61,9 @@ else
echo "/etc/mpd.conf not found, you must link your music_directory manually to /usr/share/mympd/htdocs/library"
fi
echo "Creating dir for cover pictures"
[ -d /usr/share/mympd/htdocs/pics ] || mkdir /usr/share/mympd/htdocs/pics
echo "Installing systemd service"
if [ -d /etc/systemd/system ]
then

View File

@ -685,6 +685,9 @@ void mympd_get_sticker(const char *uri, t_sticker *sticker) {
sticker->skipCount = 0;
sticker->lastPlayed = 0;
sticker->like = 1;
if (uri == NULL || strncasecmp("http:", uri, 5) == 0 || strncasecmp("https:", uri, 6) == 0)
return;
if (mpd_send_sticker_list(mpd.conn, "song", uri)) {
while ((pair = mpd_recv_sticker(mpd.conn)) != NULL) {
if (strcmp(pair->name, "playCount") == 0)
@ -724,7 +727,7 @@ void mympd_count_song_id(int song_id, char *name, int value) {
}
void mympd_count_song_uri(const char *uri, char *name, int value) {
if (uri == NULL)
if (uri == NULL || strncasecmp("http:", uri, 5) == 0 || strncasecmp("https:", uri, 6) == 0)
return;
struct mpd_pair *pair;
char *crap;
@ -751,6 +754,8 @@ void mympd_count_song_uri(const char *uri, char *name, int value) {
}
void mympd_like_song_uri(const char *uri, int value) {
if (uri == NULL || strncasecmp("http:", uri, 5) == 0 || strncasecmp("https:", uri, 6) == 0)
return;
char v[3];
if (value > 2)
value = 2;
@ -766,7 +771,7 @@ void mympd_last_played_song_id(int song_id) {
}
void mympd_last_played_song_uri(const char *uri) {
if (uri == NULL)
if (uri == NULL || strncasecmp("http:", uri, 5) == 0 || strncasecmp("https:", uri, 6) == 0)
return;
char v[20];
snprintf(v, 19, "%lu", time(NULL));
@ -881,8 +886,7 @@ int mympd_put_settings(char *buffer) {
mpd_return_pair(mpd.conn, pair);
}
len = json_printf(&out,
"{type: settings, data: {"
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, "
"streamport: %d, coverimage: %Q, stickers: %B, mixramp: %B, "
@ -948,11 +952,36 @@ int mympd_put_outputs(char *buffer) {
return len;
}
int replacechar(char *str, char orig, char rep) {
char *ix = str;
int n = 0;
while((ix = strchr(ix, orig)) != NULL) {
*ix++ = rep;
n++;
}
return n;
}
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(strlen(path) > 8) {
if (strncasecmp("http:", path, 5) == 0)
path += 7;
else if (strncasecmp("https:", path, 6) == 0)
path += 8;
replacechar(path, '/', '_');
replacechar(path, '.', '_');
snprintf(cover, cover_len, "%s/pics/%s.png", SRC_PATH, path);
if ( access(cover, F_OK ) == -1 ) {
len = snprintf(cover, cover_len, "/assets/coverimage-httpstream.png");
} else {
len = snprintf(cover, cover_len, "/pics/%s.png", path);
}
} else {
len = snprintf(cover, cover_len, "/assets/coverimage-httpstream.png");
}
}
else {
dirname(path);