Author Topic: plex integration  (Read 35410 times)

0 Members and 2 Guests are viewing this topic.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: plex integration
« Reply #30 on: March 13, 2014, 12:24:16 PM »
I have absolutely no opinion of any kind on whether or not Plex is good, or whether it is better or worse than XBMC or any of the other Media experiences available out there.  I am not interested in where it came from or what style it is (iOs vs Android etc.)

My only question is, is there any point in trying to make it work with VC?  If you can only do one kind of command and everything else must be done using a remote, then what is the point of going to all the trouble of setting it up with VC, just to be able to play movies by name and that is all you can do by voice.  I'm not saying don't try.  If you can find a way to do more that's great.  But until we can figure out how to control the UI in some practical ways, I don't think anyone is going to want to use it with VC.

Correct me if I'm wrong, but the only things that we can currently do with the Plex api is

- emulate keyboard or button presses
- play a specific movie title, or in general a single specific file (I guess it could be music or video)

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: plex integration
« Reply #31 on: March 13, 2014, 12:37:55 PM »
No I'm on board w/ you James.
Just giving a bit of background is all.

At this time I agree completely w/ your last statement.
Whether you can do more w/ the HTTP API or other API, not certain yet. Will continue to dig ...for now.

Just perhaps excited to get the movies from the xml so readily exposed and hoped everything else would just come together ;)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: plex integration
« Reply #32 on: March 13, 2014, 01:24:00 PM »
OK.  So here is how you can create a payloadXML file automatically, assuming that you have the xml file from plex.

For this command to work you need to do 2 things first.

1 - create a child folder in your VC folder called PlexPayloads.   This is where the payloadXML file will be created
2 - save the movie xml from plex to this file:  C:\plexdata\movies.xml

The command will scrape this file.  If you are able to directly scrape the xml from the Plex Media Server, even better but I wan't able to test that so I used your file instead.  Here is the command.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="287" name="Generate plex xml" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <cmdString>file://C:\plexdata\movies.xml</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <cmdString>ratingKey="(.*?)".*?title=.(.*?)["|"]</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PayloadXML.AddPair</cmdType>
    <cmdString>PlexPayloads\Movies.xml&amp;&amp;{Match.{i}.1}&amp;&amp;{Match.{i}.2}</cmdString>
    <cmdRepeat>{#M}</cmdRepeat>
  </action>
  <phrase>Generate plex movie xml</phrase>
</command>

This command requires version 2 alpha.  If you don't want to pay the $10 to upgrade from VC1 to VC2, then just install VC2 and use it in trial mode in order to generate the payloadXML.  Then you can use the payloadXML in VC1.

An even better way, especially if you have a large library, is to use this command.  It works in a similar way, but it fills a map table first, and then exports it to a payloadXML file.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="291" name="Generate plex xml using maps" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Map.CreateTable</cmdType>
    <cmdString>plexTemp</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Scrape</cmdType>
    <cmdString>file://C:\plexdata\movies.xml</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <cmdString>ratingKey="(.*?)".*?title=.(.*?)["|"]</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Map.Set</cmdType>
    <cmdString>plexTemp&amp;&amp;{Match.{i}.1}&amp;&amp;{Match.{i}.2}&amp;&amp;False</cmdString>
    <cmdRepeat>{#M}</cmdRepeat>
  </action>
  <action>
    <cmdType>Map.ExportPayloadXML</cmdType>
    <cmdString>PlexPayloads\Movies.xml&amp;&amp;plexTemp&amp;&amp;True&amp;&amp;True</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Generate plex xml using maps</phrase>
</command>

This method is significantly faster (which won't matter for a small library like the sample you sent me) but also lets you customize the phrases in your maps if you want.  When you run it again, any changes you made in the map will be kept, and only new content will be added.  That is because in the Map.Set action, the third parameter (overwrite) is set to False.  Also, when exporting the map to a payloadXML file I am setting subSetMatch to true.  This is optional.
« Last Edit: March 17, 2014, 07:19:09 PM by nime5ter »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: plex integration
« Reply #33 on: March 13, 2014, 01:28:09 PM »
Please note that I edited the xml in my last post so please copy and paste from the forum and not from an email that you may have received if you are subscribed to this topic.

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: plex integration
« Reply #34 on: April 06, 2014, 09:12:04 PM »
Sorry had my hands full, finally testing this V2 Build.
Not following how to implement this command. I saved a unicode xml but can open/import it in the command builder?
I would think based on my reading of the Scrape command and plex exposing the xml via http://ip:port/library/sections/#/all I could just use Scrape to pull down the xml directly via the Srape command but it saves to {Last Result} so not sure how to implement the parser after that.
Did new install of VC v2 in new folder. Activated.
Pasted from forum into new file. Saved unicode.
copied an existing XML and copy from forum into that one as well which was unsuccessful.

Cheers.

Getting:
---------------------------

---------------------------
error:

System.Xml.XmlException: There is no Unicode byte order mark. Cannot switch to Unicode.

   at System.Xml.XmlTextReaderImpl.Throw(Exception e)

   at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res)

   at System.Xml.XmlTextReaderImpl.CheckEncoding(String newEncodingName)

   at System.Xml.XmlTextReaderImpl.ParseXmlDeclaration(Boolean isTextDecl)

   at System.Xml.XmlTextReaderImpl.Read()

   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)

   at System.Xml.XmlDocument.Load(XmlReader reader)

   at System.Xml.XmlDocument.Load(String filename)

   at eval_a.eval_ᜀ(String A_0, TreeNode A_1)
---------------------------
OK  
---------------------------
« Last Edit: April 06, 2014, 09:55:04 PM by vulcanjedi »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: plex integration
« Reply #35 on: April 06, 2014, 10:15:21 PM »
Sounds like you need to revisit the proper way to copy and paste commands from forum code boxes. http://voxcommando.com/mediawiki/index.php?title=XML_on_the_forum

You should not be saving anything to a new file. You should simply be copying and pasting the xml directly from the code box into your command tree.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: plex integration
« Reply #36 on: April 06, 2014, 10:29:23 PM »
Much thanks nime5ter!  Man this app/support is awesome.
Just copy/paste directly in the app is amazing too. Wow. Worked perfectly and I was able to just directly scrape via the url to generate w/o precreating the XML from Plex first.
I'll just need to get to work on the playback command to work from these payloads now.
Thanks again!!

Sounds like you need to revisit the proper way to copy and paste commands from forum code boxes. http://voxcommando.com/mediawiki/index.php?title=XML_on_the_forum

You should not be saving anything to a new file. You should simply be copying and pasting the xml directly from the code box into your command tree.
« Last Edit: April 07, 2014, 12:58:45 AM by vulcanjedi »

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: plex integration
« Reply #37 on: May 03, 2014, 11:18:50 PM »
Many thanks to xtermin8r, kalle, nime5ter and of course James.
Finally got most of the core things I really wanted to make Vox and Plex be friends.
Got some familiarity with even more neat features about the VC platform.
Utilizing many newer things to me in VC: regex, map tables, xml parsing, python..etc I'm sure theres opportunities to clean up and make more efficient but I'm pretty pleased I got things functional:)
Anyways I felt I would share my progress:

Windows Installation of VoxCommando (I'm on VC2 v1.9.3.1)
Any installation of Plex Media Server
Get the IP of local PMS
http://IP:32400
Note the machineIdentifier / IP
http://IP:32400/clients
Note the machineidentfier / IP / Port for the client you intend to control w/ VoxCommando
http://IP:32400/library/sections
Note the key numbers for the Movies / TV sections

Load the PY Plugin in Options of VoxCommando
Create a .\plexPayloads folder in the root of VoxCommando folder

Copy the pythonPayloads.xml to .\plexPayloads
Copy the plexXML.py to the .\PY folder
Create a Map Table called plexSystem
   Enter the values for the machineIdentifier // IP // Port found above into the Map Table
Edit the .\PY\plexXML.py file with the plex client's machineIdentifier so you can filter currently playing info from any other clients' sessions
   Not sure you can pass this from VC into PY script as not all objects/vars are exposed in the PY script so hard coded for now.
Create a Map Table called plexSections

Actions include:
Plex NAV - Left/right/up/down, page up/down,select….
Plex PLAY - skip, step, toggle OSD, stop, play, pause…
Plex SYS -
These are my adhoc commands:
   Play movie ABC
      Uses payload that is scraped from library to enhance results
   Play the next episode of Mr Wizards World
      This command leverages Plex's OnDeck
   Generate Plex XML,
       this starts up w/ VC and can call as well. This will load the system variables so VC will know for future calls where the Ips/machineIDs…etc are (this is mostly in lieu of a plugin, and some more could probably  be scraped as well)
   Update Libraries
      This sends remote calls to PMS to update libraries for new/clean up content
   Type
      This sends speech to Plex such as in  SEARCH, you can also use to in fields like renaming Device name in PHT
   Dictate
      This is like Type but uses the dictionary payloads for things like spelling out letters/acronyms like SOS
   What movie is this?
      This will leverage sessions XML w/ Python and filter for the plex client VC is controlling to get the right movie name and who's starring in it
   What show is this?
      This will leverage sessions XML w/ Python and filter for the plex client VC is controlling to get the right show name and episode title, season and ep number
   What is the plot?
      This will leverage sessions XML w/ Python and filter for the plex client VC is controlling to get the plot summary
      
   Note any of the commands the call DIRECT PLAYS will always play the content from the beginning w/o asking regardless.  A previous resume point will not be honored.

Still working on: commands to tell how many/who are sharing/transcoding from the PMS...
« Last Edit: May 16, 2014, 11:14:32 AM by vulcanjedi »

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: plex integration
« Reply #38 on: May 04, 2014, 05:57:38 AM »
Good job vulcanjedi, thanks for sharing.   ::bow
***********  get excited and make things  **********

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: plex integration
« Reply #39 on: May 04, 2014, 09:56:26 AM »
This is amazing, vulcanjedi. It's fantastic to see how much you've managed to do -- and having wrestled with Plex a bit myself, I do salute you.  ::bow

Thanks for sharing this!

If you ever have time to record a video demo some day, I'm sure that would help folks to really "get the picture" of all you've accomplished. But hopefully they'll just follow your instructions and give it a go.

We shall leave Plex users and their questions in your capable hands. ;)
« Last Edit: May 04, 2014, 09:59:10 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: plex integration
« Reply #40 on: June 17, 2014, 06:20:35 PM »
@vulcanjedi -- I can't bring myself to wrestle with Plex again, but I was wondering whether you've considered adding any keyboard emulation to the mix since posting your commands above?

I'm thinking in particular for functionality such as returning directly to the home screen, turning subtitles on and off, F6 for full movie info, maybe also the context menu and that style of thing.

Curious whether the documentation here is accurate. https://support.plex.tv/hc/en-us/articles/201670487-Keyboard-Shortcuts





TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

vulcanjedi

  • $upporter
  • Sr. Member
  • *****
  • Posts: 213
  • Karma: 8
    • View Profile
Re: plex integration
« Reply #41 on: June 17, 2014, 08:07:43 PM »
I dont typically use keyboard emulation, I've never encountered a need before, but I'm happy to investigate. I think that was part of the API that didn't work so well from my original plex forum searches.
I'm more than happy to try.
I also believe with the latest update to the Plex Server, some of the APIs changed, to the newer syntax. I'll have to repost some of the fixes I had to do.
It may have been the navigation controller you mention.
The new syntax I believe more directly engages the clients vs the server and it as much of Plex remains woefully under documented.

Sorry I haven't been as involved, I'm several VC updates behind for sure, finally switched jobs after the last one turned toxic....and then have been studying for MS cert exam (just passed). Still a bit unsettling being at a new place after a long stint.

Also I need to work out some performance improvements after I got my storage up and my library grew significantly I'd like to improve some of the scraping/map tables..etc.
So I need to work on some updates/refinements and such
« Last Edit: June 17, 2014, 08:17:33 PM by vulcanjedi »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: plex integration
« Reply #42 on: June 18, 2014, 11:40:21 AM »
Congrats on passing your exam, and good luck with the new gig.

It's a lot of work to figure out the Plex craziness. I was impressed with your video demo (at least, I think it's yours), not to mention your perseverence!

No surprise that you've had to put the project on the back burner. If/when you have the time to share some updated commands, hopefully your fellow Plex users can provide some productive feedback ... and even a bit of gratitude if you're lucky.  :biglaugh
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Cineman

  • Jr. Member
  • **
  • Posts: 12
  • Karma: 1
    • View Profile
Re: plex integration
« Reply #43 on: June 25, 2014, 03:00:01 PM »

   Enter the values for the machineIdentifier // IP // Port found above into the Map Table

Wie musst der Map Table aussehen.
Create New Map Table und was muss ich in welcher Spalte eintragen.
Bekomme es nicht hin >:(

Bitte um Hilfe.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: plex integration
« Reply #44 on: June 25, 2014, 03:17:11 PM »
Ja, es ist ein bisschen kompliziert.

Ich werde versuchen, mehr einfache Befehle und Klarstellungen zu geben ... aber in Englisch, irgendwann heute
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)