Is this possible?
I would like to be able to launch whatever track I want, using a single command or maybe more commands. I've seen a version where you can launch a track using the exact path. But is it maybe possible to have a command where I put the artist and the song in this command, and then lms plays this song? Even when there are more than 1 in the database?
Results 1 to 10 of 12
-
2020-12-21, 14:32 #1
- Join Date
- Apr 2014
- Posts
- 286
Launch a track with cli or http, without path.
-
2021-01-01, 08:24 #2
- Join Date
- Apr 2014
- Posts
- 286
Not possible?
-
2021-01-01, 10:54 #3
Yes you can
Using wget. I created a variable with the request to make it easier to see the full command.
Code:REQUEST={"id":1,"method":"slim.request","params":[ "myPlayer", ["playlist","loadtracks","track.titlesearch=Do%20It%20Again"]]} wget -T 5 -O- --post-data="$REQUEST" --header 'Content-Type: application/json' http://<ip.address.of lms>:9000/jsonrpc.js
Enter the ip address of your lms server
Then where you see the track name, you need to use %20 instead of the space in the name.piCorePlayer a small player for the Raspberry Pi in RAM.
Homepage: https://www.picoreplayer.org
Please donate if you like the piCorePlayer
-
2021-01-08, 06:27 #4
- Join Date
- Apr 2014
- Posts
- 286
-
2021-01-08, 08:24 #5
The commands below are for a shell script. If you would rather work in python, you can still do the same. Either with an os.system call, or build routine that does an http POST.
I assume you want to have a few different track name options? How are you going to select the tracks to be played?piCorePlayer a small player for the Raspberry Pi in RAM.
Homepage: https://www.picoreplayer.org
Please donate if you like the piCorePlayer
-
2021-01-08, 16:03 #6
- Join Date
- Apr 2014
- Posts
- 286
My end goal is, to use tasker with AutoVoice and google home to launch the song. For now I use it to launch a playlist or some radio channel.
But the goal is to use a certain command with the name of the song in it, and use the script to launch that song in lms. I could even use node red to do some stuff if needed.
But say, I want launch the song: Purple Rain
What command would I need? Something like this?:
Code:wget -T 5 -O- --post-data="{"id":1,"method":"slim.request","params":[ "raspberrypi", ["playlist","loadtracks","track.titlesearch=Purple%20Rain"]]}" --header 'Content-Type: application/json' http://192.168.1.29:9000/jsonrpc.js
http://192.168.1.29:9000/jsonrpc.js
Connecting to 192.168.1.29:9000... connected.
HTTP request sent, awaiting response... Read error (Connection timed out) in headers.
Retrying.
So what is going wrong?
-
2021-01-08, 17:51 #7
You have to be careful with placement and types of quote marks. Its odd the difference when using shell variables and when entering straight. Put single quotes around the post-data.
Code:wget -T 5 -O- --post-data='{"id":1,"method":"slim.request","params":[ "raspberrypi", ["playlist","loadtracks","track.titlesearch=Purple%20Rain"]]}' --header 'Content-Type: application/json' http://192.168.1.29:9000/jsonrpc.js
Code:# Sends a command to LMS via the jsonrpc interface. def send_lms_command (json, lmsip, port): cmdline = '/usr/bin/wget -T 5 -q -O- --post-data=\'%s\' --header \'Content-Type: application/json\' http://%s:%s/jsonrpc.js' % ( json, lmsip, port) t = Popen( cmdline, shell=True, stdout=DEVNULL, stderr=DEVNULL) t.wait(timeout=6) def send_play_command( lmsip, port, player): json_req = '{"id":1,"method":"slim.request","params":[ "%s", [ "play" ]]}' % player send_lms_command (json_req, lmsip, port)
piCorePlayer a small player for the Raspberry Pi in RAM.
Homepage: https://www.picoreplayer.org
Please donate if you like the piCorePlayer
-
2021-01-09, 03:54 #8
- Join Date
- Apr 2014
- Posts
- 286
-
2021-01-09, 06:13 #9
You would have to use the song ID’s. The unique number assigned by LMS in the library.
piCorePlayer a small player for the Raspberry Pi in RAM.
Homepage: https://www.picoreplayer.org
Please donate if you like the piCorePlayer
-
2021-01-09, 06:36 #10
- Join Date
- Apr 2014
- Posts
- 286