Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to Python 3 (Kodi v19) #45

Closed
Dinth opened this issue Sep 8, 2020 · 19 comments · Fixed by #46
Closed

update to Python 3 (Kodi v19) #45

Dinth opened this issue Sep 8, 2020 · 19 comments · Fixed by #46

Comments

@Dinth
Copy link

Dinth commented Sep 8, 2020

Can the addon be updated to Python 3 so it works with Kodi v19?

@Lxtxs
Copy link

Lxtxs commented Mar 4, 2021

Yes Please. That would be really great.

@Caligo82
Copy link

Yes please, that would be highly appreciated. Can't get around Netflix these days. And afaik this is the only way to make it happen on Shield TVs.

@xzxzard
Copy link

xzxzard commented Mar 31, 2021

Guys, you can use platform capture, it works with kodi. Just set environment for your display in hyperion systemd unit.

@tigertim08
Copy link

Guys, you can use platform capture, it works with kodi. Just set environment for your display in hyperion systemd unit.

And how do I send the information via lan to the pi running the Hyperion.ng?

@xzxzard
Copy link

xzxzard commented Mar 31, 2021

Guys, you can use platform capture, it works with kodi. Just set environment for your display in hyperion systemd unit.

And how do I send the information via lan to the pi running the Hyperion.ng?

May be it is possible use DISPLAY=your_kodi_host:0.0 env, if you running kodi on linux.

@locutus
Copy link

locutus commented Apr 1, 2021

Guys, you can use platform capture

Not if you are running Wayland.

BTW, I tried around a bit to upgrade the plugin to Python 3, but it seems to be more complicated. The plugin depends on the script.plugin.protobuf plugin (https://github.com/WoLpH/kodi-protobuf) which also is only available for python2 (and has not been updated since 5 years?).
With the Python-Tool 2to3, I was able to convert all files of hyperion.kodi as well as script.plugin.protobuf to python3. However, there also seem to be some deprecated functions in kodi, at least "xbmc.abortRequested" does not work anymore, but can apparently be replaced with: "xbmc.Monitor().abortRequested()". With this fix, the plugin loads in kodi and settings seem to work. However, it does not seem to properly connect to Hyperion, so there's that. I guess this will take a lot more work, probably somewhere in the whole protobuf-fu, but that seems beyond my capabilities.

@ghostface
Copy link

I got a little further.

Installed python3 protobuf (pip3 install protobuf)

Changed line101 in resources/lib/state.py to
hexdata = bytes.hex(binascii.b2a_hex(self.__data))

as binascii.b2a_hex no no longer returns a string, but it still aint working, not sure if that was the right approach not seeing any errors in the log either.

@ghostface
Copy link

I got it working again - will cleanup the code and post fork later

Basically

        hexdata = binascii.b2a_hex(self.__data)
        if len(self.__data) > 0 and not hexdata.startswith(bytes.fromhex('0000000000000000')) and not hexdata.startswith(bytes.fromhex('000000ff000000ff')):
(...)
                self.__hyperion.sendImage(self.__capture.getWidth(), self.__capture.getHeight(), self.__data,
                                          self.__settings.priority, -1)

and this in Hyperion.py is needed

imageRequest.imagedata = bytes(data)

@pety3bi
Copy link

pety3bi commented May 14, 2021

Could you please provide a patch with working solution or even better, a pull-request?

@ghostface
Copy link

Could you please provide a patch with working solution or even better, a pull-request?

yes I will

@ghostface
Copy link

There you go: https://github.com/ghostface/hyperion.kodi
Due to direct monkey patching script.module.protobuf and a small additional change regarding flickering issues I had, I didn't create a direct pullrequest.

Feel free to rework it into a proper pullrequest or cherry pick the changes (I tried to segment them logically)

@ghostface
Copy link

I also just noticed someone else also forked a version that according to the commits may work with kodi matrix and python3 but I haven't tested it personally https://github.com/CPVprogrammer/kodi-matrix-hyperion-addon

@chrisvte
Copy link

I also just noticed someone else also forked a version that according to the commits may work with kodi matrix and python3 but I haven't tested it personally https://github.com/CPVprogrammer/kodi-matrix-hyperion-addon

It seems it just works. I uninstalled the version 1.0.2, preserved the old configuration and I installed the 1.0.3 from CPVprogrammer repository.

@rtehok
Copy link

rtehok commented Sep 12, 2021

Did someone try https://github.com/CPVprogrammer/kodi-matrix-hyperion-addon v1.0.3 on kodi 19.1 with an Android TV? I have Hyperion.ng installed on a rpi4 and I can't make them work together.

2021-09-12 14:40:45.149 T:6646    ERROR <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'AttributeError'>
                                                   Error Contents: module 'pkg_resources' has no attribute 'declare_namespace'
                                                   Traceback (most recent call last):
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.service.hyperion/addon.py", line 36, in <module>
                                                       from state import DisconnectedState
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.service.hyperion/resources/lib/state.py", line 27, in <module>
                                                       from hyperion.Hyperion import Hyperion
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.service.hyperion/resources/lib/hyperion/Hyperion.py", line 28, in <module>
                                                       from .message_pb2 import HyperionRequest
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.service.hyperion/resources/lib/hyperion/message_pb2.py", line 5, in <module>
                                                       from google.protobuf import descriptor as _descriptor
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.service.hyperion/resources/lib/google/__init__.py", line 2, in <module>
                                                       __import__('pkg_resources').declare_namespace(__name__)
                                                   AttributeError: module 'pkg_resources' has no attribute 'declare_namespace'
                                                   -->End of Python script error report<--

@PeterMalast
Copy link

Did someone try https://github.com/CPVprogrammer/kodi-matrix-hyperion-addon v1.0.3 on kodi 19.1 with an Android TV? I have Hyperion.ng installed on a rpi4 and I can't make them work together.

2021-09-12 14:40:45.149 T:6646    ERROR <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'AttributeError'>
                                                   Error Contents: module 'pkg_resources' has no attribute 'declare_namespace'
                                                   Traceback (most recent call last):
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.service.hyperion/addon.py", line 36, in <module>
                                                       from state import DisconnectedState
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.service.hyperion/resources/lib/state.py", line 27, in <module>
                                                       from hyperion.Hyperion import Hyperion
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.service.hyperion/resources/lib/hyperion/Hyperion.py", line 28, in <module>
                                                       from .message_pb2 import HyperionRequest
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.service.hyperion/resources/lib/hyperion/message_pb2.py", line 5, in <module>
                                                       from google.protobuf import descriptor as _descriptor
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.service.hyperion/resources/lib/google/__init__.py", line 2, in <module>
                                                       __import__('pkg_resources').declare_namespace(__name__)
                                                   AttributeError: module 'pkg_resources' has no attribute 'declare_namespace'
                                                   -->End of Python script error report<--

Same problem, any updates ?

@eadmaster
Copy link

eadmaster commented Dec 2, 2022

Same problem, any updates ?

I was able to pass the error by adding this in the kodi launcher script:

export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python

EDIT: also make sure the priority is set to 150.

@FragMenthor
Copy link

anything working in kodi nexus? any other option?

@Dinth
Copy link
Author

Dinth commented Mar 14, 2023 via email

@FragMenthor
Copy link

One option is running https://sabaatworld.github.io/HyperionScreenCap/

On Tue, 14 Mar 2023 at 11:29, FragMenthor @.> wrote: anything working in kodi nexus? any other option? — Reply to this email directly, view it on GitHub <#45 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACMSST7UEXY5N2FY44D7HLW4BJCNANCNFSM4Q7SH4SA . You are receiving this because you authored the thread.Message ID: @.>
-- Kind regards, Michal Gawronski-Kot @.***

Thanks! but i'm using an AndroidTV box, so i'm searching for some grabber that could work on android... Inside kodi or as a atandalone apk. I can get the menu's to work( I've got hyperion.ng runnning as addon on HomeAssistant), just not the content of some apps... the leds all turn green (using android screen grabber). The kodi addon I can't manage to get it working right now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.