Search code examples
pythonhttprequestraspberry-piairplay

Airplay Remote control HTTP request


I use Airplay with a Raspberry Pi, so I installed Sharply-sync. It work perfectly but I want to control the music of my iPhone which is emitting music with airplay. I saw this page to do this: http://nto.github.io/AirPlay.html#audio-remotecontrol

So I have to make an HTTP request to control the music, but I don't know how to use this: GET /ctrl-int/1/pause HTTP/1.1 Host: starlight.local. Active-Remote: 1986535575 How can I make a request ( why not in Python :) ) with that ?

My raspberry informations: IP: 192.168.X.XX The Port: 5000 Active-Remote: 1075873687 (It's an example because it change every Time)

I know the first part of the url which I have to make the request, I think it's: http://192.168.X.XX:5000//ctrl-int/1/pause but I don't know how to put the rest...

How can I do that PLEASE ?

Thank for your answers and I'm so sorry for my bad English..


Solution

  • Just use requests module. Check sample code below.

    import requests
    headers = {'Host': 'starlight.local.' , 'Active-Remote': 1986535575}
    url = "http://192.168.x.xx:5000//ctrl-int/1/pause"
    requests.get(url, headers=headers)
    

    For more details please check the documentation for the module at http://docs.python-requests.org/en/master/.