Skip to content

Commit

Permalink
Improve spotmeta parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
moodeaudio committed Jan 19, 2025
1 parent 280cd4b commit 5f92bdc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions var/local/www/commandw/spotevent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ MULTIROOM_TX=${arr[9]}
RX_ADDRESSES=$(sudo moodeutl -d -gv rx_addresses)
# cfg_spotify
BITRATE=$(sqlite3 $SQLDB "SELECT value FROM cfg_spotify WHERE param='bitrate'")"K"
FORMAT="Vorbis "$BITRATE
FORMAT="Vorbis "$BITRATE

if [[ $INPACTIVE == '1' ]]; then
exit 1
Expand Down Expand Up @@ -118,10 +118,9 @@ if [[ $PLAYER_EVENT == "session_disconnected" ]]; then
fi

if [[ $PLAYER_EVENT == "track_changed" ]]; then
COVER=$(echo $COVERS | cut -d " " -f 1)
#ARTIST=$(echo $ARTISTS | cut -d " " -f 1) should be \n delimited?
#ARTISTS=$(echo "$ARTISTS" | tr '\n' ', ') should be \n delimited?
METADATA="${NAME}~~~${ARTISTS}~~~${ALBUM}~~~${DURATION_MS}~~~${COVER}~~~${FORMAT}"
#ARTISTS=$(echo -e -n "$ARTISTS" | tr "\n" ";")
#COVERS=$(echo -e -n "$COVERS" | tr "\n" ";")
METADATA="${NAME}~~~${ARTISTS}~~~${ALBUM}~~~${DURATION_MS}~~~${COVERS}~~~${FORMAT}"
echo -e "$METADATA" > $SPOTMETA_FILE
/var/www/util/send-fecmd.php "update_spotmeta,$METADATA"
fi
8 changes: 4 additions & 4 deletions www/js/playerlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,16 +814,16 @@ function updateInpsrcMeta(cmd, data) {
$('#inpsrc-backdrop').css('filter', 'blur(0px)');
$('#inpsrc-backdrop').css('transform', 'scale(1.0)');

// Spotify: [0]:title [1]:artist [2]:album [3]:duration (in ms) [4];coverurl [5]:format
// Deezer: [0]:title [1]:artist [2]:album [3]:duration (in secs) [4];coverurl [5]:format
// Spotify: [0]:title [1]:artists [2]:album [3]:duration (in ms) [4];coverurls [5]:format
// Deezer: [0]:title [1]:artist [2]:album [3]:duration (in secs) [4];coverurl [5]:format
var metadata = data.split('~~~');
var timeDivisor = (cmd == 'get_spotmeta' || cmd == 'update_spotmeta') ? 1000 : 1;

var title = metadata[0];
var artist = metadata[1];
var artist = cmd == 'get_spotmeta' ? metadata[1].split("\n")[0] : metadata[1];
var album = metadata[2];
var duration = formatSongTime(Math.round(parseInt(metadata[3]) / timeDivisor));
var coverURL = metadata[4];
var coverURL = cmd == 'get_spotmeta' ? metadata[4].split("\n")[0] : metadata[4];
var format = metadata[5];

if (title == '' || duration == '') {
Expand Down

0 comments on commit 5f92bdc

Please sign in to comment.