raptor2101 / Mediathek

GNU General Public License v3.0
45 stars 16 forks source link

Import error for `lxml.html` on LibreELEC #83

Closed Herrminator closed 8 years ago

Herrminator commented 8 years ago

Since version 0.7.2, Mediathek throws an error on startup in LibreELEC (and possibly OpenELEC) installations, because LibreELEC doesn't ship with the lxml library and there are no dependencies defined in addon.xml:

Log file:

 09:29:25 66943.226562 T:1146090400   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                         - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                        Error Type: <type 'exceptions.ImportError'>
                                        Error Contents: No module named lxml.html
                                        Traceback (most recent call last):
                                         File "/storage/.kodi/addons/plugin.video.mediathek/default.py", line 21, in <module>
                                            from mediathek.factory import MediathekFactory
                                          File "/storage/.kodi/addons/plugin.video.mediathek/mediathek/factory.py", line 27, in <module>
                                            from mediathek.kika import *
                                          File "/storage/.kodi/addons/plugin.video.mediathek/mediathek/kika.py", line 19, in <module>
                                            import lxml.html
                                        ImportError: No module named lxml.html
                                        -->End of Python script error report<--
raptor2101 commented 8 years ago

Hello Herminator

via Requires-Attribut a addon is only able to "reference" another Kodi-Addon. I'am not able to tell the System "please do a apt-get install lib[....]lxml" (for good reasons ;))

On the other hand without the Python-Lib lxml the KiKA part runs useless at all. The ongoing Site-Changes makes it very hard to parse the side only via "Regular Expression" (or in other words extreme ineffective). my last attemp was able to render the main page within 5 minutes.

So i had to make a choice. Drop KiKa Support or switch to xml/xpath based approach.

Because of all my Kodi Setups are based on ubuntu and i'am unaware of LibreELEC or the underlying JeOS i'am unable to give you the correct command how to install lib_lxml.

if pip is available the following should help pip install lxml

if there is apt-get sudo apt-get install python3-lxml

Herrminator commented 8 years ago

LibreELEC / OpenELEC is more or less a read-only OS. Installing additional components other than Kodi add-ons is generally not supported.

But i just tried Mediathek in a standard Windows installation of Kodi and i'm getting the same error. Kodi for Windows has its own Python interpreter, which also doesn't allow installation of additional modules (and I guess it would be too much to ask for a regular user).

I would guess the same is true for Kodi for Android and most of the Kodi-based appliances out there.

P.S.: How about using xml.etree? I know it's not as powerful as lxml, but it's included in Python since 2.7...

raptor2101 commented 8 years ago

will look into this, or at least a check, that Kika isn.t supportet if lxml isnt found ...

Herrminator commented 8 years ago

xml.etree doesn't really play well with pure HTML (not XHTML) input :-( But another powerful HTML-Parser would be Beautiful Soup 4, which is available as a Kodi add-on (<import addon="script.module.beautifulsoup4" version="4.3.1"/>). It doesn't support XPATH searches, but it allows for complex search arguments and CSS-selectors.

raptor2101 commented 8 years ago

CSS Selectors is yust fine ... will take a look into this. as long simply uncomment the importing of kika.py...

ebora commented 8 years ago

Same issue here with OSMC (4.4.13-5-osmc). As I don't watch kika, I opted for commenting the lines instead of installing python3-lxml.

denbue commented 8 years ago

Same issue on windows though (0.7.1 is fine):

`22:59:08 T:3228 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--

raptor2101 commented 8 years ago

fix released -> pushing it to kodi

raptor2101 commented 8 years ago

New version pulled by kodi.

sorry for the inconvenience and thanks for the hints.