Airplay songinfo [with short sample]

Suggestions/requests/ideas for RuneAudio core features and functions

Airplay songinfo [with short sample]

Postby tatoosh » 12 Jan 2015, 20:16

Do you plan to add the shairport -M Option to include airplay infos and cover?
Some infos:
To enable the output of metadata, the -M <directory name> flag must be set to instruct shairport where to save the output. This directory must exist. A fifo named now_playing will be created, and records will be written to it when tracks are changed. The end of a set of metadata is delimited by a zero-length line. Cover filenames are relative to the cover directory. Files are not deleted.

An example::

artist=Arcade Fire
title=City With No Children
album=The Suburbs
artwork=cover-e6450a45ab900815e831434f5ee0499c.jpg
genre=Rock
comment=


If not how can i help to implement this?
Tatoosh
Last edited by tatoosh on 14 Jan 2015, 19:25, edited 1 time in total.
tatoosh
 
Posts: 50
Joined: 12 Jan 2015, 12:18

Re: Airplay songinfo

Postby tatoosh » 12 Jan 2015, 20:29

I am new to arch - where can i find and change the shairport config?

can i just edit this: /usr/lib/systemd/system/shairport.service ?
i'll try now :)
Thx Tatoosh
tatoosh
 
Posts: 50
Joined: 12 Jan 2015, 12:18

Re: Airplay songinfo

Postby tatoosh » 12 Jan 2015, 20:47

This solution worked:
[root@z1 shairport]# ls
cover-3372791b956da6821366a956d392b0ac.jpg cover-485dca5c932d9471d1f9941d7dc6e595.jpg cover-e0a25e508cd6bf1f0eca1eacb1b27242.jpg now_playing


but now_playing is empty ... i don't know why.
tatoosh
 
Posts: 50
Joined: 12 Jan 2015, 12:18

Re: Airplay songinfo

Postby tatoosh » 12 Jan 2015, 21:07

Got working by adding the -M <Folder> to the end of the configuration, first i added the arg at start.

Info (from my iPad Spotify premium) now looks:

[root@z1 shairport]# tail now_playing
artist=London Grammar
title=Strong
album=If You Wait
artwork=cover-6bb7f637c001a61f73e9c7beec787ce9.jpg
genre=
comment=


I ordered a 3.2" TFT for 10EUR in china, think it will arrive in Februar ;)
Then i want to push the cover and infos to the TFT.

How to transfer this infos to the web interface?
tatoosh
 
Posts: 50
Joined: 12 Jan 2015, 12:18

Re: Airplay songinfo

Postby tatoosh » 13 Jan 2015, 10:16

I changed the metadata folder in the shairport.service like this:
Code: Select all
--meta-dir=/var/www/shairport


And with this script i will get the cover in the webfolder shairport/cover.jpg. The sing infos are parsed to json to the same folder as now_playing.json.

Now i only have to trigger the filechange of now_playing to run my shell script and build a little PHP site to show the cover on the web ui.
Maybe someone can help me so i can use the normal web ui and don't have to build my own one ;)

Here the getInfo.sh script:

Code: Select all
#!/bin/bash

FOLDER=/var/www/shairport
pipe=$FOLDER/now_playing
datafile=$pipe.json

stringify() {
  a=${1%%=*}
  b=${1##*=}
  echo "\"$a\": \"$b\""
}

exec 4< $pipe
while read -ru 4 line ; do
  if [[ $line == artist* ]]; then
    echo '{' > $datafile
  elif [ -z "$line" ]; then
    echo '}' >> $datafile
    continue
  fi

  # jsonify the string
  data=$(stringify "$line")

  # for logging
#  echo $line

  # pretty print the JSON
  # comment is the last line of the output
  if [[ $line == comment* ]]; then
    echo "  $data" >> $datafile
  else
    echo "  $data," >> $datafile
  fi
done

exec 4<&-


rm $FOLDER/cover.jpg
FILE=$(ls -t $FOLDER/*.jpg | head -1)
cp -f $FILE $FOLDER/cover.jpg

echo Exiting
tatoosh
 
Posts: 50
Joined: 12 Jan 2015, 12:18

Re: Airplay songinfo

Postby tatoosh » 13 Jan 2015, 10:46

Here a fast php snippet to show the song info and cover after running the bash script:

http://runeaudio/shairport/index.php
Code: Select all
<?php

$string = file_get_contents("now_playing.json");
$json_a=json_decode($string,true);

echo '<html><head><link rel="stylesheet" href="../css/runeui.1421133757.css"></head>

<body style="background: black"><div style="text-align: center;background-color: black;color: #34495E">';


foreach ($json_a as $key => $value){
 
  if ($key == "artwork") $cover = $value;
  else echo $key . ':' . $value;
  echo '<br>';
}

echo '<img src="' . $cover . '"/>';
echo '</div></body></html>';

?>


That shows you the info like this:
Image
tatoosh
 
Posts: 50
Joined: 12 Jan 2015, 12:18

support RuneAudio Donate with PayPal


Return to Feature request

Who is online

Users browsing this forum: No registered users and 6 guests