nahovevyse 1 Posted March 16, 2019 Share Posted March 16, 2019 Checked the WebSocket wiki page. It shows to connect to a WebSocket you will require an API key and device ID I'm trying to get the device ID as soon as any user logs in to the server. Till now I got no response after WebSocket connection.here's my python code websocket.enableTrace(True) host = "xxx.xx.xx.xx" port = 8096 api_key = "xxxxxx" device_id = "xxxx" ws = websocket.create_connection("ws://{}:{}/embywebsocket?api_key={}&deviceId={}".format(host, port, api_key, device_id)) result = ws.recv() print('Result: {}'.format(result)) result = ws.recv() print('Result: {}'.format(result)) # Trying something from community... ws.send(json.dumps([json.dumps({'msg': 'connect', 'version': '1', 'support': ['1', 'pre2', 'pre1']})])) result = ws.recv() print('Result: {}'.format(result)) Result: --- request header --- GET /embywebsocket?api_key=xxxxxxxx&deviceId=a7650139abe6b220 HTTP/1.1 Upgrade: websocket Connection: Upgrade Host: xxx.xx.xx.xx:8096 Origin: http://xxx.xx.xx.xx:8096 Sec-WebSocket-Key: mHuOCG3yyL41uB7gk7fK8g== Sec-WebSocket-Version: 13 ----------------------- --- response header --- HTTP/1.1 101 Switching Protocols Connection: Upgrade Upgrade: websocket Sec-WebSocket-Accept: Ta03Qfon0bEHLCQKG+0BtGNZXjQ= ----------------------- send: b'\x8a\x80\x93\tf\xe1' send: b'\x8a\x80\x13\xf8qB' send: b'\x8a\x80\xa3\xf3\xa1b' send: b'\x8a\x80\xa9\x87\xad\x9e' send: b'\x8a\x80@\x19\xa7\xa7' These send messages came after some time of no response. These are not proper Hex codes. IDK what they are.Requesting EMBY gurus to help me on this.I think I don't even know much about WebSockets 1 Link to comment Share on other sites More sharing options...
Luke 37049 Posted March 16, 2019 Share Posted March 16, 2019 What do you mean after your user logs into the server? Link to comment Share on other sites More sharing options...
nils12 0 Posted March 16, 2019 Share Posted March 16, 2019 when a user access emby server from his device, thats what he means. Link to comment Share on other sites More sharing options...
Luke 37049 Posted March 17, 2019 Share Posted March 17, 2019 Is this script being run from the same device? Link to comment Share on other sites More sharing options...
nils12 0 Posted March 17, 2019 Share Posted March 17, 2019 Yes the plugin/script is on the same server as emby Link to comment Share on other sites More sharing options...
setavecata 0 Posted March 18, 2019 Share Posted March 18, 2019 (edited) +1I don't also understood the working. I feel emby documentation is not proper, Lack examples.I see anytime anyone asks something you guys point to your wiki page. Wiki pages is I feel don't help completely. They don't elaborate enough.plex has much better support. Edited March 18, 2019 by setavecata Link to comment Share on other sites More sharing options...
Luke 37049 Posted March 18, 2019 Share Posted March 18, 2019 +1 I don't also understood the working. I feel emby documentation is not proper, Lack examples. I see anytime anyone asks something you guys point to your wiki page. Wiki pages is I feel don't help completely. They don't elaborate enough. plex has much better support. Why would you say such a thing? Have you seen how active we are in the community? Link to comment Share on other sites More sharing options...
Luke 37049 Posted March 18, 2019 Share Posted March 18, 2019 Yes the plugin/script is on the same server as emby Ok, you can't use an apikey from another device to open a web socket connection. What is your end goal? What are you trying to do? Link to comment Share on other sites More sharing options...
nils12 0 Posted March 18, 2019 Share Posted March 18, 2019 I believe the end goal is to grab the device id and user id as soon as a user logs onto emby server. Link to comment Share on other sites More sharing options...
setavecata 0 Posted March 19, 2019 Share Posted March 19, 2019 Why would you say such a thing? Have you seen how active we are in the community? Sorry, didn't want to be mean. It's just what I felt. I've been reading your community forum since quite a while. I'm just trying to understand emby. I felt the documentation can bigger with rich examples code + use cases, everybody can relate. Maybe I'm wrong... maybe Link to comment Share on other sites More sharing options...
nahovevyse 1 Posted March 19, 2019 Author Share Posted March 19, 2019 I believe the end goal is to grab the device id and user id as soon as a user logs onto emby server. Yes the goal is to have the device id or Ip address related to a user Id. Link to comment Share on other sites More sharing options...
Luke 37049 Posted March 19, 2019 Share Posted March 19, 2019 Then I would use the /Sessions api. Please also make sure to explore our api documentation: https://github.com/MediaBrowser/Emby/wiki Thanks. Link to comment Share on other sites More sharing options...
nahovevyse 1 Posted March 27, 2019 Author Share Posted March 27, 2019 Then I would use the /Sessions api. Please also make sure to explore our api documentation: https://github.com/MediaBrowser/Emby/wiki Thanks. so with sessions what will be the algorithm session api will return all devices and the user logged in with those devices. to limit a user X to few devices N I'll then have to - loop through the objects (session api json output objects), - Filter and get the devices for X count - check if number_of_logged_in_devices_by_X >= N (permitted number of devices) Remove the allowed all devices check Use the /devices api and disable last used devices so that number_of_logged_in_devices_by_X becomes equal to N There will be other scenarios like the user X wants to use the device we disabled etc With this approach, the script will be running all the time and for ~1000-1500 user's I don't think it's a wise approach. requesting EMBY gurus to share ideas/thoughts? Link to comment Share on other sites More sharing options...
nils12 0 Posted March 28, 2019 Share Posted March 28, 2019 Hi Luke, Can you help on this please ? Link to comment Share on other sites More sharing options...
nils12 0 Posted March 29, 2019 Share Posted March 29, 2019 (edited) - Edited March 29, 2019 by nils12 Link to comment Share on other sites More sharing options...
nils12 0 Posted March 29, 2019 Share Posted March 29, 2019 Why would you say such a thing? Have you seen how active we are in the community? Luke? Link to comment Share on other sites More sharing options...
nahovevyse 1 Posted March 30, 2019 Author Share Posted March 30, 2019 Then I would use the /Sessions api. Please also make sure to explore our api documentation: https://github.com/MediaBrowser/Emby/wiki Thanks. Everyone just vanished??? lol Link to comment Share on other sites More sharing options...
nahovevyse 1 Posted April 1, 2019 Author Share Posted April 1, 2019 (edited) - The Comment was originally posted on 29 March 2019- 07:18 AM ] Why didn't anyone replied to the post? If there's no better way or you're busy or don't wanna help or something else, whatever it is. Just say it. At least reply. Edited April 3, 2019 by nahovevyse Link to comment Share on other sites More sharing options...
Luke 37049 Posted April 1, 2019 Share Posted April 1, 2019 so with sessions what will be the algorithm session api will return all devices and the user logged in with those devices. to limit a user X to few devices N I'll then have to - loop through the objects (session api json output objects), - Filter and get the devices for X count - check if number_of_logged_in_devices_by_X >= N (permitted number of devices) Remove the allowed all devices check Use the /devices api and disable last used devices so that number_of_logged_in_devices_by_X becomes equal to N There will be other scenarios like the user X wants to use the device we disabled etc With this approach, the script will be running all the time and for ~1000-1500 user's I don't think it's a wise approach. requesting EMBY gurus to share ideas/thoughts? Yes, I guess you could do that, but we haven't tried that ourselves. Link to comment Share on other sites More sharing options...
nahovevyse 1 Posted April 3, 2019 Author Share Posted April 3, 2019 (edited) Yes, I guess you could do that, but we haven't tried that ourselves. That's an idea. It's not feasible and will have loopholes for 100's of users's. We just want to limit the user device usage via code, not manually. Please help me with the process, I mean the things I should be using. First I tried websockets. Turned out they're not of use for this task. Then sessions but the algo is not good. What do you recommend?? How it should be done?? Edited April 3, 2019 by nahovevyse Link to comment Share on other sites More sharing options...
nahovevyse 1 Posted April 3, 2019 Author Share Posted April 3, 2019 (edited) Yes, I guess you could do that, but we haven't tried that ourselves. I feel I'm not the only one trying to limit devices. Someone must have done this or anything related. This is nothing new but it's completely new for me tho lol Edited April 3, 2019 by nahovevyse Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now