Use lxml-library in a plugin
#16
I was able to get lxml to work on Dharma + Ubuntu 11.10 x86-64 by extracting the contents of the following RPM to /usr/share/xbmc/system/python/lib/python2.4/ (specifically the directory within the RPM: /./usr/lib64/python2.4/site-packages/lxml/)

I tried a few other RPMs that I found but they either were rejected by python (ImportError) or they caused XBMC to die. This one works like a charm.

I would prefer to not need lxml, unfortunately I am using a library that depends upon it. I would be willing to sacrifice speed for a full python implementation. In Python 2.5 (Dharma is 2.4), there is xml.etree.ElementTree.fromstring for XML parsing, but there is no comparable lxml.html.document_fromstring. BeautifulSoup is a great library, unfortunately the API is different from lxml so it is not a drop in replacement.

Any thoughts on a full python implementation of lxml's API (especially lxml.html)?
Reply
#17
cancan101 Wrote:I was able to get lxml to work on Dharma + Ubuntu 11.10 x86-64 by extracting the contents of the following RPM to /usr/share/xbmc/system/python/lib/python2.4/ (specifically the directory within the RPM: /./usr/lib64/python2.4/site-packages/lxml/)

I tried a few other RPMs that I found but they either were rejected by python (ImportError) or they caused XBMC to die. This one works like a charm.

I would prefer to not need lxml, unfortunately I am using a library that depends upon it. I would be willing to sacrifice speed for a full python implementation. In Python 2.5 (Dharma is 2.4), there is xml.etree.ElementTree.fromstring for XML parsing, but there is no comparable lxml.html.document_fromstring. BeautifulSoup is a great library, unfortunately the API is different from lxml so it is not a drop in replacement.

Any thoughts on a full python implementation of lxml's API (especially lxml.html)?

Since this is an external library(it is not part of the default python) there is two ways to bring the module into your addon. First you can physically add it to your addon(ie resources/lib/lxml/) or secondly XBMC has an addon called script.module, this is where you can put the module into. This is how BeautifulSoup is created.
Reply
#18
My question is if anyone knows of a Python implementation of the lxml API?

I just wanted to see if it were possible to use the binary lxml library from XBMC and it is possible, but this is not a good solution (I would need to distribute binaries of that library with the plugin).

What I want is something like BeautifulSoup that I can use as a drop in replacement for lxlml.
Reply
#19
some discussions:
http://trac.xbmc.org/ticket/11189
http://forum.xbmc.org/showthread.php?tid...light=lxml
Reply
#20
queeup Wrote:some discussions:
http://trac.xbmc.org/ticket/11189
http://forum.xbmc.org/showthread.php?tid...light=lxml

This looks like it needs to be moved to a pull request.
Reply
#21
Does cElementTree have .cssselect() method? Can cElementTree parse html at all? You have not used cElementTree very well.
Code:
>>> xml.etree.cElementTree.fromstring("<a><p></a>")
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "<string>", line 124, in XML
ParseError: mismatched tag: line 1, column 8
So how to require dependencies for addon and what about binary dependencies on Windows and other slow systems or systems w/o compiler out-of-the-box?
Reply
#22
PLEASE ADD IT! REGEX PARSING SUX! AT LEAST ONE PLUGIN WAS SCREWED BECAUSE OF REGEX PARSING (BESTOFYOUTUBE), WHICH WASN'T SCREWED IF IT HAS USED A REAL PARSER!
Reply

Logout Mark Read Team Forum Stats Members Help
Use lxml-library in a plugin0