asciidisco / plugin.video.netflix

Inputstream based Netflix plugin for Kodi
MIT License
1.24k stars 226 forks source link

Authentication fails with "TypeError: Incorrect padding" #279

Open Cyberwizzard opened 6 years ago

Cyberwizzard commented 6 years ago

I'm submitting a ...

General information

Updated my RaspberryPi3 running latest stable LibreElec to the latest Leia build (build no. 125), installed widevine using the standard script, installed Netflix plugin by downloading the latest master from this git repo as a ZIP.

Prerequisites

Description

Plugin installs, on first run, it asks for credentials. When these are provided, the entry in the folder listing shows the user, selecting the user results in the message that the Netflix addon encountered an error.

When Kodi now starts, Netflix already throws an error.

Steps to Reproduce

  1. Boot LibreElec
  2. Done

Expected behavior: No errors, Netflix at least browsable.

Actual behavior: Error when Kodi is started, Netflix not browsable (or playable)

Context (Environment)

Installation

Tried both:

Operating System

Debug log

https://pastebin.com/VvcgQe8E

Other information

It looks like this is the issue:

17:18:34.354 T:1631515536   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.TypeError'>
                                            Error Contents: Incorrect padding
                                            Traceback (most recent call last):
                                              File "/storage/.kodi/addons/plugin.video.netflix/service.py", line 16, in <module>
                                                from resources.lib.NetflixHttpRequestHandler import NetflixHttpRequestHandler
                                              File "/storage/.kodi/addons/plugin.video.netflix/resources/lib/NetflixHttpRequestHandler.py", line 30, in <module>
                                                netflix_session=NETFLIX_SESSION)
                                              File "/storage/.kodi/addons/plugin.video.netflix/resources/lib/NetflixHttpSubRessourceHandler.py", line 28, in __init__
                                                self.credentials = self.kodi_helper.get_credentials()
                                              File "/storage/.kodi/addons/plugin.video.netflix/resources/lib/KodiHelper.py", line 173, in get_credentials
                                                'password': self.decode(enc=password)
                                              File "/storage/.kodi/addons/plugin.video.netflix/resources/lib/KodiHelper.py", line 203, in decode
                                                enc = base64.b64decode(enc)
                                              File "/usr/lib/python2.7/base64.py", line 78, in b64decode
                                            TypeError: Incorrect padding
                                            -->End of Python script error report<--
Cyberwizzard commented 6 years ago

It looks like there is a bug in the way the credentials are stored; changing line 173 in plugin.video.netflix/resources/lib/KodiHelper.py to hardcode the password fixes the issue.

Looking at the settings.xml, I can see the password without base64 encoding.

Since I first installed master and then 0.12.7, perhaps this issue originated from that?

sjuk commented 5 years ago

I get this error after trying out release 0.14.0 beta 18 and going back to 0.13.9. Is there any chance bringing 0.13.9 back to work again?

13:21:23.482 T:139696378189568   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.ValueError'>
                                            Error Contents: Padding is incorrect.
                                            Traceback (most recent call last):
                                              File "/var/lib/kodi/.kodi/addons/plugin.video.netflix/service.py", line 243, in <module>
                                                NetflixService().run()
                                              File "/var/lib/kodi/.kodi/addons/plugin.video.netflix/service.py", line 101, in __init__
                                                self.nx_common)
                                              File "/var/lib/kodi/.kodi/addons/plugin.video.netflix/resources/lib/NetflixHttpRequestHandler.py", line 81, in __init__
                                                netflix_session=netflix_session)
                                              File "/var/lib/kodi/.kodi/addons/plugin.video.netflix/resources/lib/NetflixHttpSubRessourceHandler.py", line 28, in __init__
                                                self.credentials = self.nx_common.get_credentials()
                                              File "/var/lib/kodi/.kodi/addons/plugin.video.netflix/resources/lib/NetflixCommon.py", line 75, in get_credentials
                                                return NetflixCredentials().decode_credentials(email, password)
                                              File "/var/lib/kodi/.kodi/addons/plugin.video.netflix/resources/lib/NetflixCredentials.py", line 47, in decode_credentials
                                                'email': self.decode(enc=email),
                                              File "/var/lib/kodi/.kodi/addons/plugin.video.netflix/resources/lib/NetflixCredentials.py", line 83, in decode
                                                block_size=self.bs).decode('utf-8')
                                              File "/usr/lib/python2.7/dist-packages/Cryptodome/Util/Padding.py", line 90, in unpad
                                                raise ValueError("Padding is incorrect.")
                                            ValueError: Padding is incorrect.
                                            -->End of Python script error report<--
breakbeats573 commented 5 years ago

My fix for this on Kodi 18.2-RC1 OSMC was pip install pycryptodomex