Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

Phlex - Google Home + Plex Integration (with support for Sonarr, Couchpotato, etc.) NOW LIVE!

digitalhighdigitalhigh Posts: 135Members, Plex Pass Plex Pass

So, the TL/DR version is - I started writing a web application that will handle input from Google Assistant (and maybe Amazon) and then do stuff on Plex.

While there may be other API's for communicating with Plex, this one is designed to be fairly easy to set up, and easy to deploy. It runs on PHP/Javascript, has a webUI so you can debug commands and set up your server info, and has a pretty decent ability to parse the commands thrown at it.

Currently, it has the ability to accept voice input from Google Assistant via the actions API OR IFTTT. Using custom language parsing, I've created the ability to handle a wide array of input requests, as well as prompting the user for more input (when using Google Actions API). Phlex can handle commands like:

OK Google, Ask Flex TV to play batman begins.
OK Google, Ask Flex TV to play the latest episode of Game of Thrones.
OK Google, Ask Flex TV to pause playback.
OK Google, Ask Flex TV to set the volume to 80%.
OK Google, Ask Flex TV to play a Bill Murray movie.
OK Google, Ask Flex TV to play a Comedy.
OK Google, Ask Flex TV to play a Movie.
OK Google, Ask Flex TV to play season 4 episode 3 of The Simpsons.
OK Google, Ask Flex TV to download the show Alf.
OK Google, Ask Flex TV to fetch The Avengers Age of Ultron.

You can find a full list of supported phrases, as well as download and instructions, at https://github.com/d8ahazard/Phlex.

Phlex can be controlled via Google Assistant in two different ways. For simple, non-customized responses to commands, you can integrate it with IFTTT in a few steps.

For more intelligent, responsive, and sometime fun responses, you can also link Phlex directly to your Google Account. Just say "Okay Google, Talk to Flex TV", and you can link your account and start chatting!

EDIT:

Please note: If posting a support request, it is very helpful to note a few things:

What OS you are running Phlex on.

If you're using Phlex with Xampp, or an existing webserver.

If you're getting issues with a specific server or client - what OS is the server/client running on?

If you're having super-weird stuff happening that I can't replicate - zip up Phlex.log and Phlex_error.log and send them to me in a PM.

#

Here's a video:

Here are some screenshots of the UI:

photo 0.png

photo 1.png

photo 2.png

photo 3.png

photo 4.png

photo 5.png

photo 6.png

Here's the original demo video, using IFTTT:

https://drive.google.com/file/d/0B0OpOqUNqeKkTk14NmRPU0RHRm8/view?usp=sharing

«13456720

Answers

  • JasonMeudtJasonMeudt Posts: 194Members, Plex Pass Plex Pass
    edited January 6

    @digitalhigh said:

    What other apps besides plex/sonarr/couchpotato should it support? Ideally, they should have some kind of documented API that's not ridiculously complicated, and I can construct the queries needed to talk to them. ;)

    Nice work so far! I'm looking forward to seeing this grow!

    How do you intend to deal with Plex Home users and would the playback intent go to whomever is currently logged in?

    As far as what programs to integrate, how about Ombi (PlexRequests), and maybe PlexPy, although I am not sure what good the latter would do from a player's perspective and the former's usage would be tied to Sonarr/CouchPotato...

  • digitalhighdigitalhigh Posts: 135Members, Plex Pass Plex Pass

    @JasonMeudt said:

    @digitalhigh said:

    What other apps besides plex/sonarr/couchpotato should it support? Ideally, they should have some kind of documented API that's not ridiculously complicated, and I can construct the queries needed to talk to them. ;)

    Nice work so far! I'm looking forward to seeing this grow!

    How do you intend to deal with Plex Home users and would the playback intent go to whomever is currently logged in?

    As far as what programs to integrate, how about Ombi (PlexRequests), and maybe PlexPy, although I am not sure what good the latter would do from a player's perspective and the former's usage would be tied to Sonarr/CouchPotato...

    Well, added more phrase handlers today, so it should now respond to "I want to watch a movie", I want to watch a show", and/or "I want to watch a new movie" and "I want to watch a new show" - these phrases will trigger the searching and playing of a random movie or series.

    Also, it should be noted that "I want to watch" is a customizeable trigger word, so you could change it to something like "Start playing a movie" or "beam a movie to the TV".

    To answer your question - I have no idea at this time. I'm still learning all the fun things I can do with the Plex API, as well as how to do it.

    Like - does anybody have any idea the proper way to set headers to send a "play" command to a web or PHT player? This works like a charm on Android TV devices, but I'm getting some funky stuff when I try to send it to web players. But, I'll figure it out eventually.

    So, handling users - as I think about it, I can probably read the available Plex Home users, and then allow you to select who to assign stuff to when using voice commands. That would make the most sense, as Google Home only allows one user to be the brains of everything anyway. OR, to make it more flexible, assuming I can read the list of users, we could theroetically assign a PHP handler to each person's name as a parameter of our GET command.

    Yeah, that sounds fun.

    For Ombi - I will see if they have a dedicated API that would allow passing show/movie names to it in lieu of CP/sonarr/etc, which would definitely make it easier on me in terms of how I request what media. I'd still want to have direct calls to CP and Sonarr in case people don't have or don't want to set up Ombi. I know it was a PITA for me to get set up on my Synology,, and I refused to have one webapp running on my server. But I'm rambling. I will look at Ombi and see if we can be friends with it.

    For PlexPy - I'm curious what it is we want to be able to ask about. I was under the impression that PlexPy/Plexivity is basically just an interface for the data that Plex already contains. Is there some specific information we can get from it that can't be gotten directly from Plex? More importantly, is there an API to get that information from it?

    Again - I'll check it out in time. Thanks for the feedback. :D

  • omareiomarei Posts: 2Members, Plex Pass Plex Pass

    @digitalhigh Looks good and has a lot of potential.
    Name: Phlex :p

    Keep it up :)

  • kevman95kevman95 Posts: 7Validating, Plex Pass Plex Pass

    This is awesome! Thank you for doing this, this has been something ive been looking for for awhile! :)

    Does this support playing to the chromcast client as well? Should definitely add that if not!

    Phlex also sounds like a good name to use for this.

    Cannot wait for some sort of release!

  • GuSoCastilloGuSoCastillo Posts: 2Members

    How abou sickrage integration? and place all in a docker package, that would be awesome

  • skipbrannanskipbrannan Posts: 1Members

    Great work! I use my plex server only as my audio library. Will it support playing full albums/individual songs/songs by certain artists, etc. that I have in my library?

  • JasonMeudtJasonMeudt Posts: 194Members, Plex Pass Plex Pass

    @digitalhigh said:

    Well, added more phrase handlers today, so it should now respond to "I want to watch a movie", I want to watch a show", and/or "I want to watch a new movie" and "I want to watch a new show" - these phrases will trigger the searching and playing of a random movie or series.

    Also, it should be noted that "I want to watch" is a customizeable trigger word, so you could change it to something like "Start playing a movie" or "beam a movie to the TV".

    Just checking... Do you have your current work up on GitHub or ...?

  • chetstrikerchetstriker Posts: 3Members, Plex Pass Plex Pass

    Thanks for your work on this, this is super exciting.

  • ifollettifollett Posts: 1Members

    @chetstriker said:
    Thanks for your work on this, this is super exciting.

    Second this.

    @JasonMeudt said:

    Just checking... Do you have your current work up on GitHub or ...?

    Looking forward to a code release and eager to help contribute.

  • digitalhighdigitalhigh Posts: 135Members, Plex Pass Plex Pass

    http://i803.photobucket.com/albums/yy318/d8ahazard/Screen2.png

    So, lots more work done in the past days, both on the UI portion and the backend's ability to handle all the commands I can think of (within reason).

    Still focusing just on Plex, but as you can see from my more slightly polished screenshots, I've now standardized the return object generated from queries, allowing me to parse it and display it all pretty-like in the UI. Clicking the little "Json" bit in a return will show the full JSON object. :D

    Commands now support "the latest/newest/new" "season/episode" of "tvshow", " a movie" "with/featuring/starring" "actor". I spent the first half of the day doing the JSON return stuff, and a portion of the afternoon making the display nice and responsive, so it works as well on the phone as it does on the PC. And the commands...Oh, it's so buttery.

    I started with the hooks for "play/pause/stop/skip/volume" as well. Working out a command that didn't feel too awkward on IFTTT was probably the harder part - I settled on using "Tell plex to " "pause the movie." "Tell plex to set the volume to 70%.". Etc. You can replace "tell plex to" with whatever you want via IFTTT, it's just what I picked.

    Um - no, the code is not on github yet. I wanted to get this somewhat workable, and iron out all the bugs in the ginormous challenge of figuring out a way to parse a multitude of text commands in a logical way, and still write code that isn't 100% embarrassing. ;)

    In addition to this now, I've also contributed heavily to the app Muximux, so much that it's due for a 2.0 release just as soon as I go squash a few last bugs on it. So, I want to finish that up first, which isn't a lot, I've just been distracted. Once that's done, I need to add "random movie by year" - which should be easy now that I've got the "random movie by actor" bit worked out.

    Once THAT is done, I want to add the couchpotato support I've already working via Scriptr.IO+IFTTT, and maybe Sonarr if CP doesn't snowball too badly.

    Point is - I tend to get a lot of scope creep, and my coding methods are sometimes unorthodoxed and messy. I hack stuff together till it works, then go back over it obsessively and refine it...then release.

    But, I promise you, I'll put up a commit in a few days. I've made a lot of progress today and yesterday, so tomorrow should be even more fun.

    Stay tuned. XD

  • digitalhighdigitalhigh Posts: 135Members, Plex Pass Plex Pass

    Oh, I get it. You can just use plain old HTML code to insert stuff here. Neato.

    So, did some work on the UI today, think I'm happy with the overall idea. The main screen is where you can test your various commands, do debugging, and generally figure out what is and isn't going to work for you. Still want to tweak the colors, I hate that shade of green.

    Added filtering options for seasons as pictured somewhere below - you can say "I want to watch the third season of game of thrones" - and it'll start that season. I'm currently working out filtering for "the tenth episode", and eventually " season XX" episode xx" - although I'm not sure how many people know that off the top o their heads.

    Playback controls are now implemented and working wonderfully. You can say "set the volume to XX percent", "fast forward", "rewind", and a number of combinations of "jump, seek, skip" and "ahead, back, forward, backwards" to control back/forward control.

    I still want to work out searching by year, then I can jump onto CouchPotato and Sonarr, then think about making this public.

    But, for now, check out the pretty screenshots...

    photo Phlex1.png

    photo Phlex6.png

    photo Phlex2.png

    photo Phlex5.png

    photo Phlex4.png

    photo Phlex3.png

  • XmemphistoXXmemphistoX Posts: 18Members, Plex Pass Plex Pass

    Once it's released - How do you integrate this? This is awesome by the way!

  • digitalhighdigitalhigh Posts: 135Members, Plex Pass Plex Pass

    To integrated, you need to do a couple things. Your Plex server needs to be accessible from the internet, which is pretty common. You will need to run some kind of web server that can handle PHP. you will have to have your web server be available via the Internet. You then set up if this then that to point at your web server, with a trigger like "I want to watch" for playback comma and "tell Plex to" for commands, which then forwards the command on to the web server, and talks with Plex.

  • XmemphistoXXmemphistoX Posts: 18Members, Plex Pass Plex Pass
    edited January 9

    Ahh gotcha. Thanks for the diagram. Can't wait for this! Will it support multiple plex clients (IE multi rooms) or would it be best to create more than one Webserver per plex client with a different unique IFTTT command?

  • FlippageFlippage Posts: 63Members, Plex Pass Plex Pass

    Hey @digitalhigh

    Any update on this one?

    This looks really promising, and exactly what I was hoping for when I bought the Google Home.

    Any chance of getting a beta of this? Are you still working on it?

  • lolcatzurulolcatzuru Posts: 9Members ✭✭

    Hey im also really really interested in this, i'd also be willing to donate if itll help get this out!

  • digitalhighdigitalhigh Posts: 135Members, Plex Pass Plex Pass
    edited January 13

    @Flippage said:
    Hey @digitalhigh

    Any update on this one?

    This looks really promising, and exactly what I was hoping for when I bought the Google Home.

    Any chance of getting a beta of this? Are you still working on it?

    Actually, yes. I've been tearing through my code on this, adding, polishing, tweaking, improving. I've done a number of things since last checking in.

    I've now incorporated a direct login with your plex username to the portal for configuration. You go to the page for your Phlex server, log in with your Plex credentials. I then generate some session data to associate your creds with your token and preferences, and bladow - anybody who can use your server can log into it and customize commands for their device which is tied directly to their plex account.

    Additionally, I've got the generation and authentication mechanism in place so that once a user has logged in, they can get an API key that will allow Plex-authenticated voice commands without having to store your creds on IFTTT/etc.

    For Media searching, I literally went off the deep end and back again trying to account for a bajillion different requests and phrases - stuff as complex as "I want to watch season 1 episode 2 of Game of thrones from 15 minutes and 45 seconds in". I had trouble getting google to figure out that I was using my IFTTT command because this was so long, but typing it into the web UI works no problem, so the issue there is on Google's end, not mine. :D

    But you can easily say "I want to watch Goonies from the beginning." or "I want to watch Goonies from 1 hour 45 minutes and 33 seconds", and it will start Goonies at 1:45:33.

    I've done a ton of work on handling multiple results as well, whereas before I'd just kinda grab the first result, I've now refined it to the point of looking for the exact match first, then expanding to other results if none are found.

    Similarly, while small and nuanced, I can now say "I want to watch a Bill Murray Movie" or "A movie with Bill Murray", or really just say "Bill Murray", or "Bill Murray" and "Movie", etc.

    What about if there are two movies with the exact same name, but you want to watch the new one that came out this year? Well then, say the name of the movie followed by the year. Because nobody wants to watch "Passengers" that was made in 2008... XD

    I've still got a lot of work to do. Right now, the login page is ugly as sin and has zero styling or design whatsoever.

    As a result of needing to check the status of the player I'm requesting to play stuff to, I figured I might as well build a little "Now Playing" bar into the WebUI. I'm currently checking the result of the "play" command, but that will return a positive result as long as the request is well-formed - it doesn't actually tell you if what you wanted to play started playing.

    Which brings me to the biggest issue I'm currently facing - which is that I can only send media for playback to my Shield currently. I have not tested with my Nexus Player, but have been working to get the same results with a copy of Plex Media Player I've got installed on my computer downstairs. (It's running server 2016, so no store app). But, I really, really, really want this to be able to do anything you can do from the regular plex web app, so I'll keep talking to people who know more about Plex than I do and see what I'm doing wrong. As of right now, I can see from the logs that my commands are making it where they need to go and they're recognized as coming from a valid Plex device, so that's good.

    But, for those of you running an Android-based version of the Plex app, it should work right now. The rest are WIP.

    Here are a couple of screenshots. I still have a lot of UI work to do...like I said, I want to add an actual poll to the designated player so you can see that commands are working all proper-like. I want the web UI to display not only the results of commands entered directly, but also fired by the API, so that any weirdness with other apps is easy to figure out. Right now, the list of clients is only updated when the page is loaded - I need to make it load every time you click the dropdown menu for the players. Same with settings - now that I'm able to scrape data directly from Plex.tv, there's no reason to have to enter that info into Settings - just pick the main server from the dropdown and go.

    And the text parsing. While a lot of it works wonderfully, the more complex commands still cause some quirky results. Or, on the programming side, it'd be better to say that not every successful command will return a successful JSON array containing any and all relevant data needed to debug unsuccessful commands. Additionally, a uniform response system would ensure that future compatibility with AI/assistants could include smarter responses.

    Here's the initial screen after login.


    photo Phlex14.png

    A simple, single-title search with no modifier.


    photo Phlex10.png

    A more complex search, with series name, episode/season designator, and a starting offset


    You can also see the dropdown where you can select the command set to test/send. (Media, control, fetch).

    photo Phlex11.png

    An nth-selector, asking for the most recent episode of a series


    photo Phlex12.png

    Indicate that you want to resume playback from the currently saved offset


    photo Phlex13.png

    The same query, only with a general indicator to start at the begnning


    photo Phlex15.png

    Mobile-responsive version

    photo Phlex16.png

  • digitalhighdigitalhigh Posts: 135Members, Plex Pass Plex Pass

    Oh yeah, and I've got an array built up out of the genres in my library, I just need to add a bit in my parser to look for those keywords and return a random movie in that category. Same for year. ;)

  • drummondstdrummondst Posts: 23Members, Plex Pass Plex Pass

    This all looks great! I am very eager to get a hold of this. Is Chromecast support on your roadmap? or Searching multiple servers?

    Also I would be very willing to help alpha/beta test if you are looking for volunteers!

  • digitalhighdigitalhigh Posts: 135Members, Plex Pass Plex Pass

    @drummondst said:
    This all looks great! I am very eager to get a hold of this. Is Chromecast support on your roadmap? or Searching multiple servers?

    Also I would be very willing to help alpha/beta test if you are looking for volunteers!

    Once I get all/more Plex player types working, I'll consider looking at the cast protocol. Multiple servers should be easy.

    Beta testers... Not ready yet, but anybody volunteering should have an Android player and some technical knowledge to help debug stuff.

«13456720
Sign In or Register to comment.