Jump to content

Unable to curl into session_id, but I can get to /emby/sessions


Go to solution Solved by Luke,

Recommended Posts

podonnell
Posted

I've been able to create a script that can pause or unpause by sending a POST to 

/emby/Sessions/{session_id}/Playing/Pause

but I can't toggle subtitles with:

/emby/Sessions/{session_id}/Playing/SubtitleStreamIndex",
                headers=headers,
                json={"SubtitleStreamIndex": new_subtitle_index

I am trying to navigate with curls, such as

curl -X GET "http://<myserver>/emby/Sessions/<sessionid>/Playing/" -H "X-Emby-Token: <my_api_key>"

I am able to get to:

/emby/Sessions/

That comes back with valid data, showing my sessions and a bunch of info, which I pulled my sessionid from. But anything beyond the above, such as /Sessions/<sessionid>/Playing/, comes back with:

Quote

The file &#39;/emby/Sessions/<sessionid>/Playing&#39; cound not be found.

Trying to navigate around to see how these work, and using this as a guide:

https://github.com/MediaBrowser/Emby/wiki/Remote-control

I'm guessing I'm off with the command for the subtitle index, but I thought I'd be able to navigate to session_ids.

Thanks for any help!

Posted

Hi, did you check the supported commands for that session?

podonnell
Posted
On 8/23/2024 at 4:07 PM, Luke said:

Hi, did you check the supported commands for that session?

Yes, if I understand correctly `SetSubtitleStreamIndex` is the actual command which I send.

However, I am thinking something else is not working as expected as I think I should be able to get to /emby/Sessions/<sessionid>/Playing

Would that be right? I keep getting 'The file &#39;/emby/Sessions/<sessionid>/Playing&#39; cound not be found.'

Posted

Did you compare your requests to what the web app is doing?

podonnell
Posted
1 hour ago, Luke said:

Did you compare your requests to what the web app is doing?

No, where might I be able to see the web app commands? Is that on Github?

Posted

No ,you'd just have to use the browser debugger to monitor the requests. But it's a good way to see examples.

podonnell
Posted
1 minute ago, Luke said:

No ,you'd just have to use the browser debugger to monitor the requests. But it's a good way to see examples.

Oh yeah, that would be great. So for Chrome for example, is that just the developer console? I am mostly new to developing so sorry for the basic questions. :)

podonnell
Posted
2 hours ago, Luke said:

Yes exactly.

So I found the 'Request URL' from Chrome when I turn my subtitles off.

http://192.168.1.2:8096/emby/Sessions/Playing/Progress?X-Emby-Client=Emby+Web&X-Emby-Device-Name=Chrome+Windows&X-Emby-Device-Id=123123abcabc&X-Emby-Client-Version=4.8.8.0&X-Emby-Token=abcabc123123&X-Emby-Language=en-us&reqformat=json

Removed some info above but for simplicity sake, should I be able to go to this URL and get a valid response?
I am getting The file '/emby/Sessions/Playing/Progress' cound not be found.

I am finding this in the Network section in developer console, in the headers and payload section.

Posted
Quote

should I be able to go to this URL and get a valid response?

not with a GET, no.

  • Thanks 1
podonnell
Posted (edited)

I've copied the command from Chrome exactly as its being sent into PowerShell just to test it myself on the fly, and the same response comes back, but my subtitles aren't being changed...

 

image.png.7a5a289752b6fbc5263891185d2f77a2.png

> StatusCode        : 204
StatusDescription : No Content
Content           : {}
RawContent        : HTTP/1.1 204 No Content

I was originally trying via a Python script, which I've been able to pause and play successfully with. But this subtitle toggle, perhaps anything going through the /Progress/ is not being taken from anything outside of the actual player.

Here is the copied curl command with sensitive info removed, in case that is helpful:
 

curl "http://<myip>:8096/emby/Sessions/Playing/Progress?X-Emby-Client=Emby+Web&X-Emby-Device-Name=Chrome+Windows&X-Emby-Device-Id=<myid>&X-Emby-Client-Version=4.8.8.0&X-Emby-Token=<mytoken>&X-Emby-Language=en-us&reqformat=json" ^
  -H "Accept: */*" ^
  -H "Accept-Language: en-US,en;q=0.9" ^
  -H "Connection: keep-alive" ^
  -H "Content-Type: text/plain" ^
  -H "Origin: http://<myip>:8096" ^
  -H "Referer: http://<myip>:8096/web/index.html" ^
  -H "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1" ^
  --data-raw ^"^{^\^"VolumeLevel^\^":70,^\^"IsMuted^\^":false,^\^"IsPaused^\^":true,^\^"RepeatMode^\^":^\^"RepeatNone^\^",^\^"Shuffle^\^":false,^\^"SubtitleOffset^\^":0,^\^"PlaybackRate^\^":1,^\^"MaxStreamingBitrate^\^":200000000,^\^"PositionTicks^\^":3803555579,^\^"PlaybackStartTimeTicks^\^":17248819829890000,^\^"SubtitleStreamIndex^\^":-1,^\^"AudioStreamIndex^\^":2,^\^"BufferedRanges^\^":^[^{^\^"start^\^":3747720220,^\^"end^\^":3899340000.0000005^}^],^\^"SeekableRanges^\^":^[^{^\^"start^\^":0,^\^"end^\^":71400000000^}^],^\^"PlayMethod^\^":^\^"Transcode^\^",^\^"PlaySessionId^\^":^\^"c5e497222e19444ab5e3e12130272f80^\^",^\^"MediaSourceId^\^":^\^"6be0ad1bef79b7cb8df37bba70dc84bb^\^",^\^"CanSeek^\^":true,^\^"ItemId^\^":^\^"92^\^",^\^"EventName^\^":^\^"subtitletrackchange^\^",^\^"PlaylistIndex^\^":0,^\^"PlaylistLength^\^":1^}^" ^
  --insecure

 

Edited by podonnell
Posted

That's the progress api. Apps use that to report progress to the server, not to remote control.

podonnell
Posted

This is what I am seeing in the Chrome Network tab as soon as I click the subtitle toggle. It says it is sending the POST to this 

POST /emby/Sessions/Playing/Progress?X-Emby-Client=Emby+Web&X-Emby-Device-Name=Chrome+Windows&X-Emby-Device-Id=......

 

podonnell
Posted (edited)

Am I looking at the right spot? As soon as I turn off the subtitles on the left side with developer tools open, I see an entry appear where the red arrow is. Then, the request URL at the green arrow is where I am seeing the POST that I shared above

Untitled.jpg.ce8f10988b82d289cb16bea0e7efd70d.jpg

Edited by podonnell
podonnell
Posted

I went back to review https://github.com/MediaBrowser/Emby/wiki/Remote-control and eventually got it working with 

/emby/Sessions/{session_id}/Command/SetSubtitleStreamIndex

and a json payload, along with some other tweaks.

That said, I would love to know how to monitor the Chrome requests properly if someone is able to assist. But otherwise, this is all set. Thanks!

  • Thanks 1
Posted

You are looking in the right spot. But you're controlling the same app that you're playing with, therefore it doesn't need to use the server remote control api.

  • Thanks 1
podonnell
Posted
3 minutes ago, Luke said:

You are looking in the right spot. But you're controlling the same app that you're playing with, therefore it doesn't need to use the server remote control api.

Ah yes, that makes sense, thanks.

So I have now properly set the streamindex to -1 to toggle subtitles off, but having a problem turning them on.

For example my current item has a subtitlestreamindex of 5. Finding that value is another problem, but even when I set it manually, nothing happens on the item.

  command_payload = {
            "Arguments": {
                "Index": 5  
            }
        }

        command_response = requests.post(
            f"{config.EMBY_SERVER_URL}/emby/Sessions/{session_id}/Command/SetSubtitleStreamIndex",
            headers=headers,
            json=command_payload
        )

When I set the above to -1, it properly turns subtitles off.

  • Thanks 1
  • Solution
Posted

I would compare to what the web app is sending when you're using the web app to remote control something else.

  • Like 1
podonnell
Posted
1 hour ago, Luke said:

I would compare to what the web app is sending when you're using the web app to remote control something else.

Ah I understand now. Doing this absolutely opened the window to seeing these requests properly, and I'm able to send the command as expected. :)
 

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...