I am trying to add an ADDITIONAL header to the URL request (for authentication)
I call:
Mypage = XML.ElementFromURL(url, True, None, {‘Authorization’: ‘Basic bm10Om5tdA==’})
I get an EXCEPTION:
File “…/init.py”, line 320, in ZDF
ZDFpage = XML.ElementFromURL(url, True, None, {‘Authorization’: ‘Basic bm10Om5tdA==’})
TypeError: ElementFromURL() takes at most 2 arguments (4 given)
Q1: Why the exception ? What do I do wrong?
Q2: The encoding DEFAULT value in the def “utf8” … should that not be “utf-8” ?
Here is the DEF as shown in the XML.py file (version 1)
def ElementFromURL(url, isHTML=False, values=None, headers={}, cacheTime=None, encoding=“utf8”, errors=“strict”):
Looking at the VERSION 0 of the XML file, I see this DEF:
def ElementFromURL(url, use_html_parser=False):
ANSWER for Q1 ==> apparently I use VERSION 0 of the framework ==> How do I force to use VERSION 1 ?
You need to add the PlexFrameworkVersion key to the Info.plist file & set its value to 1:
<key>PlexFrameworkVersion</key><br />
<string>1</string>
That will cause the media server to start the plug-in using the v1 framework instead of v0. Be warned that there have been many changes to the operation of plug-ins, so you'll probably have to change your existing code to work with v1. If you need any help with it, please post again!
Regarding the encoding, Python treats "utf8" and "utf-8" the same :)
Thanks for the feedback, now I have changed the “Info.plist file” within my plug-in bundle.
Now when I run my plug-in I get stuck here :
# Attempt to import the plug-in module - if debugging is enabled, don't catch exceptions<br />
<br />
if Debug:<br />
PMS.Log("(Framework) Next Step 1")<br />
import Code as _plugin<br />
PMS.Log("(Framework) Next Step 2")<br />
PMS.Log("(Framework) Imported plug-in module")
The plug-in log:
(Framework) Bundle verification complete
(Framework) Debugging is enabled
(Framework) Configured framework modules
(Framework) Next Step 1
Looking inside the Plugin.py ... I do not see "Code" being initialized?
Any clues?
Is there a PLUG-IN which uses Version 1 of the framework?
There have been quite a few changes to v1 to make things cleaner and easier. You can check Vimeo, Democracy Now, Charlie Rose, The New York Times, and The Sixty One, to name a few.
Good documentation is being worked on as we speak :)