Announcement

Collapse
No announcement yet.

Oneliner to get currentsong or now playing artist + songtitle on specific player

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Oneliner to get currentsong or now playing artist + songtitle on specific player

    > I need a one line URL to get the now playing song and artist info.

    What kine of one liner do you need? A URL? A script returning data in a
    specific format? What's going to execute the one line, and what is
    consuming it?

    #2
    Oneliner to get currentsong or now playing artist + songtitle on specific player

    Hi,

    I have been wading through this forums vast content, but can not seem to find a working answer.

    I need a one line URL to get the now playing song and artist info.
    When I try this http://192.168.1.29:9000/status.html#currentsong. I still get the complete server xml/html.
    I know i need to include the mac address of the player, but the syntax is not clear to me.
    Is it possible?

    Or should I maybe use the CLI interface to make a txt file I can scan?
    If yes, some good pointers in the right direction would be greatly appreciated.
    Thanks in advance.

    Henk

    Comment


      #3
      Hi michael,

      I need a line for a program called radiocaster it can point to an URL or a txt file to show artist title info in the stream it catches from audio output (which has no info) or even a networksource.

      I found a little more info using this command;
      curl -v 'http://192.168.1.29:9000/jsonrpc.js' --data-raw '{"id":1,"method":"slim.request","params":["08:00:27:6c:e1:a2",["stop"]]}'
      It controls my player play/stop. Is there also command to only show the current song from that player??

      But since I don't know any of the parameters I don't know how to proceed I use squeezelite-x as a client and the material interface.

      Greetings,
      Henk

      NB: Thx for the help on my ID3tag problem the other day.

      Comment


        #4
        Originally posted by Hellsblade View Post
        I need a line for a program called radiocaster it can point to an URL or a txt file to show artist title info in the stream it catches from audio output (which has no info) or even a networksource.
        What OS is this little program going to run on Linux, PCP, MacOS, Windows ?
        What are your capabilities: None, Perl, Python, VB, bash etc.

        Comment


          #5
          Originally posted by bpa View Post
          What OS is this little program going to run on Linux, PCP, MacOS, Windows ?
          What are your capabilities: None, Perl, Python, VB, bash etc.
          Hi,
          Its running on Windows: programming capabilities are very limited, but i'm not scared to try something
          LMS is running inside a docker container on a Raspberry PI 4.

          Comment


            #6
            Is it this that you are trying to satisfy?



            If you are rebroadcasting from a stream in LMS ... then it looks to me like it could extract the metadata that LMS inserts into the stream.mp3
            Paul Webster
            Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
            and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

            Comment


              #7
              Originally posted by Paul Webster View Post
              Is it this that you are trying to satisfy?



              If you are rebroadcasting from a stream in LMS ... then it looks to me like it could extract the metadata that LMS inserts into the stream.mp3
              I started with that. Sounds logical. The program accepts the url (i think), but its shows no info.
              Does this stream work with "Icy-MetaData: 1" ?

              How does LMS know which stream to catch in the /stream.mp3? Because I have more than one player in my network.

              Comment


                #8
                stream.mp3 is a real player.
                When you connect to it you will see a new player appear in the list and you can then queue songs to it
                Paul Webster
                Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
                and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

                Comment


                  #9
                  Not sure it can be done with a one liner, because you first need a path to or id of the current song, then a second query gets the songinfo.

                  I haven't coded with PowerShell in a while, but there's the Invoke-Webrequest method that will allow you to post both queries, then PS can easily parse the json return objects.

                  The Invoke-WebRequest cmdlet sends HTTP and HTTPS requests to a web page or web service. It parses the response and returns collections of links, images, and other significant HTML elements. This cmdlet was introduced in PowerShell 3.0. Beginning in PowerShell 7.0, Invoke-WebRequest supports proxy configuration defined by environment variables. See the Notes section of this article. Important The examples in this article reference hosts in the contoso.com domain. This is a fictitious domain used by Microsoft for examples. The examples are designed to show how to use the cmdlets. However, since the contoso.com sites don't exist, the examples don't work. Adapt the examples to hosts in your environment.


                  The queries are documented here:
                  http://<LMS Server IP>:9000/html/docs/cli-api.html

                  Here's how I do it from an RPi in the C language:

                  (mac is the macId of the player, tags is an optional list of tags to be returned)

                  sprintf(query,"{"id":1,"method":"slim.request","pa rams":["%s",["path","?"]]}",mac);
                  post(host,port,query,decoded,2048);

                  ... (grab the _path result from the returned json into a var named p) ...

                  sprintf(query,"{"method":"slim.request","params":["%s",["songinfo",0,99,"url:%s","tags:%s"]]}",mac,p,tags);

                  post(host,port,query,decoded,2048);

                  ... (grab the name/value pairs from the returned json for album, artist, etc.)

                  Here's a typical result:

                  id=-1173897872
                  title=It's You or No One
                  artist=Lurlean Hunter
                  duration=191
                  samplesize=16
                  coverart=0
                  artwork_url=http://resources.tidal.com/images/66aeadee/09e1/43c4/ab0d/a007c1f240c2/1280x1280.jpg
                  album=Lonesome Gal
                  info_link=plugins/wimp/trackinfo.html
                  type=FLAC
                  bitrate=424kbps
                  samplerate=44100
                  url=wimp://11062173.flac
                  year=0
                  piTouchâ„¢ w/JustBoom DigiHat -> RME ADI-2 DAC FS -> JBL 305P MkII monitors; LMS 8.2 on piCorePlayer/Pi 4; Material Skin.

                  Comment


                    #10
                    Originally posted by Paul Webster View Post
                    stream.mp3 is a real player.
                    When you connect to it you will see a new player appear in the list and you can then queue songs to it
                    So that URL seems to show up every now and then in LMS, if put the URL in the browser it shows as a html5 player, but then when i put a playlist in it of any kind its racing through all songs. If use it in the app it can be used as a network stream source, but then it says 200 ok and errorcode -1 every second. So it looks this stream.mp3 is not behaving like the progam is expecting. I only get some hackling bad quality sounds from it every now and then.

                    How about the oneliner i'm looking for if I use squeezelite-x as a client for the program. It gives me the control I want and the the audio quality i want. Can it be done also?

                    Comment


                      #11
                      Originally posted by chicks View Post
                      Not sure it can be done with a one liner, because you first need a path to or id of the current song, then a second query gets the songinfo.

                      I haven't coded with PowerShell in a while, but there's the Invoke-Webrequest method that will allow you to post both queries, then PS can easily parse the json return objects.
                      Thx for the tip. Maybe my rusty Powershell knowledge can help me some

                      Comment


                        #12
                        I haven't tested this on Windows.

                        An alternative would be to use the "ncat" package (part of the nmap package ) https://nmap.org/ncat/
                        It is available for Windows and Linux. It is like the standard linux netcat/nc utility but has a built in a lua script engine.

                        Attached is a sample lua script ( cli_status.lua cli_status.lua.txt ) uses LMS CLI port 9090 to get the current title,artist and album for a specified player (you need to edit to include your own MAC address)

                        After renaming the attached script to just "cli_status.lua" The command is invoked by
                        Code:
                        ncat <LMSIPaddress> 9090 --lua-exec cli_status.lua
                        When run from a command prompt it gerenates log messages to console and writes out to a file in /tmp "/tmp/cliresult.txt"

                        Comment


                          #13
                          Originally posted by bpa View Post
                          I haven't tested this on Windows.

                          When run from a command prompt it generates log messages to console and writes out to a file in /tmp "/tmp/cliresult.txt"
                          Nice

                          Windows defender was stopping me from running this executable (will work on that)

                          Luckily i already have an installed nmap on my mac, so the command works out of the box from there.
                          Have to work on the output though;
                          :Title:08:00:27:6c:e1:a2 title Heat Miser :Artists: 08:00:27:6c:e1:a2 artist Massive Attack :Album: 08:00:27:6c:e1:a2 album Spirits Of Nature 2
                          Should be;
                          Title: Heat Miser Artists: Massive Attack Album: Spirits Of Nature 2

                          And the most important; because it's not part of the streaming process itself, it needs a process that runs on title change so the file is updated.
                          Maybe some radio broadcaster programs can do that, but that's a bit too much for a hobby project.
                          Could maybe make a powershell script for that.
                          LUA is not my kind of language, but it keeps me busy

                          Comment


                            #14
                            Originally posted by Hellsblade View Post
                            g me from running this executable (will work on that)

                            Luckily i already have an installed nmap on my mac, so the command works out of the box from there.
                            Have to work on the output though;
                            :Title:08:00:27:6c:e1:a2 title Heat Miser :Artists: 08:00:27:6c:e1:a2 artist Massive Attack :Album: 08:00:27:6c:e1:a2 album Spirits Of Nature 2
                            Should be;
                            Title: Heat Miser Artists: Massive Attack Album: Spirits Of Nature 2

                            And the most important; because it's not part of the streaming process itself, it needs a process that runs on title change so the file is updated.
                            Maybe some radio broadcaster programs can do that, but that's a bit too much for a hobby project.
                            Could maybe make a powershell script for that.
                            LUA is not my kind of language, but it keeps me busy
                            1. It is proof of concept - to show access to LMS CLI and generate a text file with currently playing artist, album and title.

                            2. If you want notification on changes you use the CLI command "listen 1" - then unsolicited changes will be sent. The script then has to change into a loop whose action looks at strings received, waits for a "newmetadata" message, then does inquiry.
                            look at LMS WebGUI /Help/Technical Information/Command Line Interface as there are alternatives such as "subscribe status"

                            3. Lua - the scripts won't have to do complicated stuff and there are plenty of resources. I don't know Lua either - I just cobbled it together. KISS principle.



                            To get used to CLI, I'd advise play around using the "telnet" command - just make sure your commands end with CTRL/J - CLI will only respond t0 lines which end with CTRL/J and not "Return".

                            edit:

                            As well as "newmetdata", you'll have to look for "playlist newsong" - it seem there are more than a few ways to indicate change.
                            Last edited by bpa; 2022-02-20, 14:16.

                            Comment


                              #15
                              Originally posted by Hellsblade View Post
                              Have to work on the output though;
                              :Title:08:00:27:6c:e1:a2 title Heat Miser :Artists: 08:00:27:6c:e1:a2 artist Massive Attack :Album: 08:00:27:6c:e1:a2 album Spirits Of Nature 2
                              Should be;
                              Title: Heat Miser Artists: Massive Attack Album: Spirits Of Nature 2
                              Following chnage does what you want.

                              Code:
                              -- Write out results in a one line
                              
                              [color=red]curtitle  = curtitle:sub(25,-1)
                              curartist = curartist:sub(26,-1)
                              curalbum  = curalbum:sub(25,-1)
                              
                              f:write("Title: " .. curtitle .. " Artists: " .. curartist .. " Album: " .. curalbum )[/color]
                              f:flush()
                              f:close()

                              Comment

                              Working...
                              X