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 Members, Plex Pass Posts: 248 Plex Pass

Introduction:



What is Phlex? Phlex stands for Personal Home Language EXtension. I mean, I guess. I literally just made that up. Also, it sounds cool.

Aside from being a made-up name that sounds cool, The purpose of Phlex is to provide a natural language interface for Home Theater applications - effectively bridging the current gap between commercial AI Solutions like Google Home and personal web applications like Plex, Couchpotato, and Sonarr.

Or, in short - you can watch and download movies and shows just by telling your phone to do so.


Phlex Demo #2

photo 0.png

photo ccbg.png

photo ccbg2.png

photo ccbg3.png
photo ccbg4.png
photo 6.png

Installation:


Phlex requires a webserver and PHP with CURL/SSH enabled in order to work correctly.

For Cast Device Control, you will also need to enable the Sockets module.

For most use cases, XAMPP is going to be the easiest options.

XAMPP is a free, cross-platform web server package, and can be found here:

https://www.apachefriends.org/index.html



When installing XAMPP, we only require the PHP and Apache features. You can uncheck the rest of the options in installation if you have no need for them:

MySQL, FileZilla FTP Server, Mercury Mail Server, Tomcat, Perl, phpMyAdmin, Webalizer, Fake Sendmail

Once installed, clone or download the Phlex directory to the root web directory of XAMPP, which should be the /htdocs folder. When done, the path should be something like C:\xampp\htdocs\phlex (windows) or usr/home/xampp/htdocs/phlex (linux).

That should be it. You can now restart the apache service for your webserver, and browse to your Phlex installation at 'http://yourserveraddress:80/Phlex'.

To log in, enter your Plex username and password.

If you are running Phlex on an existing webserver, Phlex supports PHP versions is 5.6.x and up. Phlex will also require r/w access to the root of the /Phlex directory for configuration and logging purposes.
You will also need the CURL and openSSL extensions enabled, and sockets if you have any Cast devices.


Post-Installation (Network Stuff):



First, you'll need to forward IP traffic to port 80 on the computer where Phlex is running. You do not have to forward port 80 to port 80, you can choose any open port you like.

If you wish to change the listening port for Phlex to something other than 80, you can do so in the Xampp control panel by clicking the "config" button next to Apache, and then opening httpd.conf.

In httpd.conf, you will see a line that reads "Listen 80". Change 80 to whichever port you want. Restart apache, and forward to that port. If you are on Windows, you will need to make a rule in Windows Firewall to allow that port's traffic as well.


Setting it up with Google Assistant:



Log into Phlex with your Plex.tv username and password.
Click on the gear icon to open settings.
In settings, under the general tab, make sure you fill in the "Public Address" box with the FULL address of your Phlex server. Typically, you will just need to append /Phlex to the directory path, and a port if you changed it to something other than 80.

For example:

273.482.234.33/Phlex:66678

If you've set up a domain with reverse proxy, then just put the url you've setup:

my.domain.com/Phlex

Or:

phlex.my.domain.com




Once you've got the address entered, simply ask your Google Assistant to "Talk to Flex TV". This is the invocation name you will use to talk to Phlex.

You should now be prompted to link your Google account. Hop over to Phlex, and click that "Link Google Account" button. On the page you'll be redirected to, paste in the API key that's been conveniently
copied to your clipboard. Press the button.

On the next page, pick your Google account or log in if prompted. Once logged in, you should be redirected to Google.com with a success message.

Boom. You can now talk to Phlex by saying things like "Ask Flex TV to play batman begins" or "Ask Flex TV to play the lastest episode of THe Big Bang Theory". I'll be adding a wiki page for voice commands as time allows.


Google Assistant Examples:


When talking with Google Assistant, your speech is parsed using API.ai's natural language processing, meaning Phlex is always getting better! Below are just a few examples of the type of things you can ask Flex TV to do.

OK Google, Ask Flex TV to play Batman Begins.

OK Google, Tell 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 stop playback.

OK Google, Ask Flex TV to set the volume to 80%.

OK Google, Ask Flex TV turn the volume down.

OK Google, Ask Flex TV to turn on a Bill Murray movie.

OK Google, Ask Flex TV to fire up 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 download Season 2 Episode 5 of the show The Americans.

OK Google, Ask Flex TV to fetch The Avengers Age of Ultron.

OK Google, Ask Flex TV what's playing.

OK Google, Ask Flex TV what the name of this movie is.

OK Google, Tell Flex TV I want to watch Frozen From 1 Hour and 45 Minutes.

OK Google, Ask Flex TV if I have any new movies.



Trigger phrases:



Below are all of the recognized trigger phrases for Google Assistant commands.

(Note, these values are always expanding, so you may want to try other "synonyms" for these phrases!)

"Play":

"I want to watch",
"I feel like watching",
"do I have",
"can you fire up",
"can you play",
"start",
"turn on",
"put on",
"throw on",
"find",
"can you find",
"cast"

"Resume":

"Play",
"Resume",
"Start",
"Continue"

"Pause":

"Pause"

"Stop":

"Stop Playback",
"Halt",
"End Playback",
"Cease",
"Desist"

"Skip Forward":

"Skip Forward",
"Skip Ahead",
"Jump Ahead",
"Next Chapter"

"Skip Backward":

"Skip Backward",
"Skip Back",
"Jump Back",
"Previous Chapter"

"Seek Forward":

"Seek Forward",
"Fast Forward",
"Step Forward",
"Seek Ahead"

"Seek Backward":

"Seek Backward",
"Rewind",
"Step Backward",
"Step Back"

"Jump To": // Not Implemented Yet

"Jump To",
"Seek To",
"Skip To",
"Fast Forward To",
"Rewind To",
"Go Back To"

"Stop":

"stop"

"Volume":

"set the volume",
"adjust the volume",
"turn the volume down",
"turn the volume up",
"turn it up",
"turn it down"

"Fetch*:

"fetch",
"I want to download",
"can you download",
"download",
"grab",
"****",
"pirate",
"add",
"snag"

"Change Player"/"Change Server":

"switch player",
"choose player",
"change player",
"select player",
"pick player",
"swap player"

"Currently playing":

"What's playing?",
"What's on?",
"What is playing?",
"What is on?",
"What am I watching?",
"What is on TV?",
"What movie is on?",
"What show is on?",
"Am I watching something?",
"Can you tell me what this movie is called?",
"Can you tell me what this show is called?",
"What is this called?",
"what the name of this"

"New Media": Not sure if I implemented or not

"What new TYPE",
"have any new TYPE",
"What's new?",
"what is new",
"recent",
"recently added",
"just added"

"On Deck Items": Also forgot if I actually wrote this or not yet

"ondeck",
"What's on deck",
"What is on deck",
"up next"

Setting up IFTTT With Phlex

  1. Head on over to https://ifttt.com/ and create an account.
  2. Go to the "applets" page.
  3. Click "New applet".
  4. Click the blue + button for IF THIS.
  5. search for "Assistant".
  6. "Say a phrase with a Text Ingredient".
  7. What do you want to say:
    • Depends on the command you want to use. I use "I want to watch", "Tell Plex to", and I want to download" for playback, control, and fetch commands respectively.
  • You can use whatever you want, but some triggers are reserved - these should work.

  • Put the $ sign where the thing you're sending to Phlex goes.

  • "I want to watch $"

  • Start playing $

  1. Save it.

  2. Click the "then that" button.

  3. Search for "Maker".

  4. Pick "Make a web request", the only option.

  5. The URLs can be found in settings.

  6. Click "Create Action", test it out.

  7. Repeat for a download and "control playback" command.


SUPPORT



For general help with installation, setup, or questions, head on over to the Plex forums and drop me a line.



https://forums.plex.tv/discussion/252910/phlex-google-home-plex-integration-with-support-for-sonarr-couchpotato-etc-now-live/

Reporting Issues

If you think you've found a bug or would like to make a feature request, feel free to use the issue tracker to let me know. When posting an issue, try to include the following information:

  1. On what OS are you running Phlex?
  2. Are you using a new instance of XAMPP, or an existing webserver?
    • If Using an existing Webserver, have you ensured the proper modules are enabled and installed, and that PHP can read and write to the /Phlex directory?
  3. If you're having issues communicating with a specific instance of Plex/Couchpotato/Sonarr/etc. - tell me the OS you're running that app on.
  4. Is Phlex using http or https?
  5. If you're having issues with a specific command, please note the timestamp in the web UI, and take a look at Phlex and Phlex_error.log files. Paste anything that looks related as well.



DONATIONS



If you really really like this project and want to thank me for sharing it with the world, you can send money via paypal to ** donate.to.digitalhigh@gmail.com **.

This is a donate-only address, support requests will not be answered.

«13456745

Answers

  • JasonMeudtJasonMeudt Members, Plex Pass Posts: 212 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 Members, Plex Pass Posts: 248 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 Members, Plex Pass Posts: 2 Plex Pass

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

    Keep it up :)

  • kevman95kevman95 Validating, Plex Pass Posts: 7 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 Members Posts: 2

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

  • skipbrannanskipbrannan Members Posts: 1

    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 Members, Plex Pass Posts: 212 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 Members, Plex Pass Posts: 3 Plex Pass

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

  • ifollettifollett Members Posts: 1

    @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 Members, Plex Pass Posts: 248 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 Members, Plex Pass Posts: 248 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 Members, Plex Pass Posts: 20 Plex Pass

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

  • digitalhighdigitalhigh Members, Plex Pass Posts: 248 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 Members, Plex Pass Posts: 20 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 Members, Plex Pass Posts: 68 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 Members Posts: 9 ✭✭

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

  • digitalhighdigitalhigh Members, Plex Pass Posts: 248 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 Members, Plex Pass Posts: 248 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 Members, Plex Pass Posts: 30 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 Members, Plex Pass Posts: 248 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.

«13456745
Sign In or Register to comment.