Plugin Log Question

HTML.ElementFromURL
I am receiving this error in my log:

    <br />
content = HTML.ElementFromURL(pageUrl)<br />
NameError: global name 'HTML' is not defined<br />




I've been working through some examples and references other plugins and it is the same syntax used in each one. Does anyone have any idea what the issue might be?

Only difference I can find is that I a using an IP address for the URL rather than a domain name. I assumed this would not cause any problems.


I assume you are using Plex Framework v1, in which case you would need to use the equivalent:

content = XML.ElementFromURL(pageUrl, isHTML=True)

How is the framework version specified?

That did seem to fix it but should I be using V.2?



Also, all of the information I want to use for my objects is stored in a table. No usable div tags or much of anything.



XPath Checker found this: id(‘Main’)/x:table/x:tbody/x:tr but Plex doesn’t like it. I’ve been able to get my list of object displaying using: //table/descendant::a but I can’t get the additional information I want to be able to display.



To do that, I need a way to find out how many rows are in the table so I can loop through them to pull out the necessary information.

I can use this: id(‘Main’)/x:table/x:tbody/x:tr[19]/x:td[4] and increment the row/column count --> but again, Plex doesn’t like this syntax.



Help!? Not a complete noob but new to Python and XPath. I’m sure there is a more efficient way to grab the info I need.





Website, for reference: http://88.80.11.29

V1 plugins are still very common and still being developed. When I started developing plugins I decided to dive right into V2. I assumed (right or wrong) that the goal is to eventually migrate all the plugins to V2. From a development standpoint, there really are only a few differences which are laid out pretty well in Sander’s thread about upgrading from V1 to V2.



When you’re using xpath checker it will throw in a ‘x:’ in fron t of the items in the path. So, for your table you could probably use something like:


data = content.xpath('//table/tbody/tr')


to return a list of all the elements in the table. Then if you put that in a for loop, you can cycle through each element to pull out the relevent info you want.



How do I fix the 'global name HTML is not defined' error if I go that route? Since that is a v2 call...


That xpath should work for v1 as well. Just use the XML.ElementFromUrl example Dbl_A provided.

Something like this...

content = XML.ElementFromUrl(pageUrl, isHTML=True<br />
fot data in content.xpath('//table/tbody/tr'):<br />
### here's where you process each item ###<br />
### make sure to indent properly###



If you want to dive into v2, you need to update the Info.plist file.
I would just look at an existing v2 plugin and compare the Info.plist's between the two.

Sander’s post here (http://forums.plexapp.com/index.php/topic/18324-updating-plugins-to-v2-framework/page__view__getnewpost) also does a good job of explaining the necessary changes to get going in v2.

I’ve got my menu populated. Now working on the site configuration. Most of the videos I’m trying to use are embedded from other locations so I’m not sure how to find the ‘plugin’. Any direction?

Hmm. Found an alternative site that might be easier to work with… That definitely through a wrench in my plans… :slight_smile:

Ok, so having some issues. After making some edits the plugin doesn’t appear in Plex any more. I undid the changes and still nothing… :huh:





All I get in the Log is:

Bundle Verification complete

Debugging is enabled

Default encoding is utf-8

Loaded en Strings

Couldn’t find en-us strings

Configured framework modules

Try restarting PMS. I’ve found that on occasion it takes a little extra effort to get it to ‘see’ the changes you made to the code.

Yeah, I’ve tried that a few times… still no luck. <_<

It’s odd. Terminal is telling me invalid syntax, referring to my dir.Append



specifically pointing to the ‘r’…



This line hasn’t changed.

it looks to be the 3rd line of my MainMenu() - no matter what is there…



found it!

Anyone willing to help with some XPath?



I am looking at www.fromsport.com and using: //table//tr once I have the row items, how can I loop through each column to assign my variables?



Also, the titles that show up on the website are being generated through a script (I think)… is there a way to translate that for my use in Plex?

I’m no xpath expert but, if you post a sample of the code your trying to match, I can can try to give you a hand.

It might be helpful if you also post an excerpt of the code that you have so far.




Thanks, Mike. I moved my questions to a more specific topic, here: http://forums.plexapp.com/index.php/topic/23120-plugin-help/page__gopid__144163#entry144163

and have had some others chime in and got my questions answered.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.