Skip to content

Instantly share code, notes, and snippets.

@ethanpil
Created July 30, 2023 21:50
Show Gist options
  • Save ethanpil/c92990b55e67e0072f72c73f7c25d19a to your computer and use it in GitHub Desktop.
Save ethanpil/c92990b55e67e0072f72c73f7c25d19a to your computer and use it in GitHub Desktop.

Revisions

  1. ethanpil created this gist Jul 30, 2023.
    37 changes: 37 additions & 0 deletions mopidy-play-stream-cli.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    #!/bin/sh
    #How to play a web stream on mopidy from command line (Linux) using CURL.
    #Can also adjust moplidy playback volume if needed

    #Clear current tracklist. Will also stop playback
    curl -X POST -H Content-Type:application/json -d '{
    "method": "core.tracklist.clear",
    "jsonrpc": "2.0",
    "id": 1
    }' http://localhost:6680/mopidy/rpc

    #Add URL of stream to tracklist
    curl -X POST -H Content-Type:application/json -d '{
    "method": "core.tracklist.add",
    "jsonrpc": "2.0",
    "params": {
    "uris": ["https://broadcast.myurl.com/radio.mp3"]
    },
    "id": 1
    }' http://localhost:6680/mopidy/rpc

    #Adjust volume if necessary
    curl -X POST -H Content-Type:application/json -d '{
    "method": "core.mixer.set_volume",
    "jsonrpc": "2.0",
    "params": {
    "volume": 25
    },
    "id": 1
    }' http://localhost:6680/mopidy/rpc

    #Play the new tracklist
    curl -X POST -H Content-Type:application/json -d '{
    "method": "core.playback.play",
    "jsonrpc": "2.0",
    "id": 1
    }' http://localhost:6680/mopidy/rpc