Webserver

Questions and comments specific to a particular plugin should go here.
leejk
Posts: 16
Joined: Sun Dec 04, 2016 4:32 pm

Re: Webserver

Post by leejk » Wed Aug 14, 2019 11:22 pm

That would be cool! For ports, only in the url the webhook posts to, like http://192.168.0.100:80

There are a few examples of using node.js to parse the payload and control hue lights, so in theory I could adapt these to send events to EG, but better if there’s not a middle layer.

User avatar
kgschlosser
Site Admin
Posts: 4803
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Webserver

Post by kgschlosser » Thu Aug 15, 2019 6:09 am

do you have an example of the data you are being sent?
If you like the work I have been doing then feel free to Image

leejk
Posts: 16
Joined: Sun Dec 04, 2016 4:32 pm

Re: Webserver

Post by leejk » Sat Aug 17, 2019 12:12 am

kgschlosser wrote:
Thu Aug 15, 2019 6:09 am
do you have an example of the data you are being sent?
Sort of. I am running Homebridge on my Mac, and so I put it into debug mode to print out everything being sent to it.

Code: Select all

[8/16/2019, 7:59:56 PM] [homebridge-plex-sensors.Plex] Homebridge Plex Sensors listening for webhooks on: http://<homebridge ip>:22987
[8/16/2019, 7:59:56 PM] Homebridge is running on port 60084.
[8/16/2019, 8:02:07 PM] [homebridge-plex-sensors.Plex] Plex incoming webhook
[8/16/2019, 8:02:07 PM] [homebridge-plex-sensors.Plex] Seen player: "Safari" (with UUID: "skciahdqsfr0b1n4hyig9del")
[8/16/2019, 8:02:07 PM] [homebridge-plex-sensors.Plex] Seen user: "xxxxxx"
[8/16/2019, 8:02:07 PM] [homebridge-plex-sensors.Plex] Processing event: {"event":"media.play","user":true,"owner":true,"Account":{"id":1,"thumb":"https://plex.tv/users/9d468cacd1184e2a/avatar?c=1556848787","title":"xxxxxx"},"Server":{"title":"macmini","uuid":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"},"Player":{"local":true,"publicAddress":"","title":"Safari","uuid":"skciahdqsfr0b1n4hyig9del"},"Metadata":{"librarySectionType":"show","ratingKey":"156298","key":"/library/metadata/156298","parentRatingKey":"156036","grandparentRatingKey":"155958","guid":"com.plexapp.agents.thetvdb://70600/26/39?lang=en","parentGuid":"com.plexapp.agents.thetvdb://70600/26?lang=en","grandparentGuid":"com.plexapp.agents.thetvdb://70600?lang=en","librarySectionTitle":"TV Shows","librarySectionID":2,"librarySectionKey":"/library/sections/2","type":"episode","title":"The College Fraternity Crisis","titleSort":"College Fraternity Crisis","grandparentKey":"/library/metadata/155958","parentKey":"/library/metadata/156036","grandparentTitle":"Dateline NBC","parentTitle":"Season 26","contentRating":"TV-PG","summary":"Andrea Canning reports on cases of alleged hazing at schools and fraternities across the country, including LSU, Texas Tech, Florida A&M, Rider University and more.","index":39,"parentIndex":26,"viewOffset":2297000,"lastViewedAt":1566000127,"year":2018,"thumb":"/library/metadata/156298/thumb/1565665538","art":"/library/metadata/155958/art/1565665539","grandparentThumb":"/library/metadata/155958/thumb/1565665539","grandparentArt":"/library/metadata/155958/art/1565665539","grandparentTheme":"/library/metadata/155958/theme/1565665539","duration":7200000,"originallyAvailableAt":"2018-06-03","addedAt":1564887601,"updatedAt":1565665538,"Genre":[{"id":61057,"filter":"genre=61057","tag":"News"}]}}
And at line 149 in homebridge-plex-sensors is where it spits all that out. Not that homebridge-plex-sensors listens for the webhooks on a certain configurable port. Maybe this approach would work also for EG?

thanks

User avatar
kgschlosser
Site Admin
Posts: 4803
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Webserver

Post by kgschlosser » Sat Aug 17, 2019 2:46 am

OK I think what you are needing is an interface to Plex. instead of busting out with the rubber bands toothpicks and duck tape to make it work.
If you like the work I have been doing then feel free to Image

leejk
Posts: 16
Joined: Sun Dec 04, 2016 4:32 pm

Re: Webserver

Post by leejk » Sat Aug 17, 2019 11:35 pm

I thought about trying to write a EG plugin. Pretty much just need a web server that listens for the Webhooks and then fires an event when it gets a payload. Then use a python script in EG to dissect the payload and perform an action. I’ll have to study up on python first tho.

User avatar
kgschlosser
Site Admin
Posts: 4803
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Webserver

Post by kgschlosser » Sun Aug 18, 2019 2:28 am

The plug-in would be easy to make as there is already a python binding for the Plex API. Just have to connect the GUI related components to the various parts of the API.
If you like the work I have been doing then feel free to Image

leejk
Posts: 16
Joined: Sun Dec 04, 2016 4:32 pm

Re: Webserver

Post by leejk » Tue Aug 20, 2019 3:56 am

Probably, but that adds an unnecessary layer I think. Webhooks seem more reliable in this case I think. Hopefully I get some time soon to dive into this.

User avatar
kgschlosser
Site Admin
Posts: 4803
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Webserver

Post by kgschlosser » Tue Aug 20, 2019 4:50 am

The PlexAPI is not an additional layer per say. because in order for me to get something for ya going I would need to create a socket or some form of a webserver in order to have plex connect.. this is just the other way around. Since Plex already has a webserver that runs on it all that is being done is we are creating a connection to it and asking for the data instead. and the code for that whole end of it is already done. Making the GUI related bits is a whole lot easier to do.
If you like the work I have been doing then feel free to Image

jachin99
Experienced User
Posts: 601
Joined: Sat Feb 13, 2016 8:39 pm

Re: Webserver

Post by jachin99 » Thu Aug 22, 2019 2:39 pm

Someone has created a Kodi Plugin that may be easily transformed into a kind of universal plugin for any other media center via the EG Web Server. My idea came from this thread https://www.thegreenbutton.tv/forums/vi ... =9&t=11767 where the developer noted that if I were able to transform his JSON into XML and host it on a local webserver, then programs such as Macrotube for Windows Media Center might be able to easily consume that feed, and display a list of videos.

I don't use WMC anymore as I have switched to JRiver, and Emby BUT I know JRiver, Plex, Emby, and Probably Media Portal at the very least support RSS XML formats. This gave me the idea that possibly using this plugin, coverting the JSON to XML, and hosting the resulting XML page in the EG Web server. From here, a user could point their media center to the XML page on the server, and hopefully the media center would grab a list of videos, and thumbnails, and everything would work. Would it be possible to give the eventghost web server a friendly name that I could point various media centers to such as WebHost, and host RSS XML page on it?

The plugin itself looks to be written in python, and I'm not sure that it can actually be used outside of Kodi but I know EG can run python scripts without Kodi. I'm just curious to see if something like this would be feasible. I don't even watch channel 9 but I'm wondering if this is a solid concept.

leejk
Posts: 16
Joined: Sun Dec 04, 2016 4:32 pm

Re: Webserver

Post by leejk » Sat Aug 24, 2019 4:00 pm

Still not had any time to experiment but been doing a little research. Based on what I saw, the Plex API (which is unofficial) doesn't send events based on playback automatically, but you can query it for all sorts of information. Since it's not official I'd rather not use it for fear of it breaking on the next Plex server release. I still think the Plex webhooks is the best approach. I can see EG getting the payload from Plex webhooks but no repeatable event name is logged for programming an action. The EG web server plugin seems to support variables, but I can't see any examples or documentation on how they work. I wonder if they could be used to store the payload in a variable, then use a Python script action to dissect the payload?

User avatar
kgschlosser
Site Admin
Posts: 4803
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Webserver

Post by kgschlosser » Sat Aug 24, 2019 5:11 pm

it does send events. the Plex API as a websocket that events are generated on. I do not know to what extent the events are or what they are for.

if you do a search on google for "Plex Python" you will find a library for python already written and it should contain some helpful information
If you like the work I have been doing then feel free to Image

Post Reply