putdotio / putio-kodi

Official Put.io Kodi addon
GNU General Public License v3.0
11 stars 2 forks source link

Check for status OK instead of status_code 200 #21

Closed joelpurra closed 1 month ago

joelpurra commented 1 month ago

Fixes #16.

See

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: 'dict' object has no attribute 'status_code'
                 Traceback (most recent call last):
                   File "/home/_kodi/.kodi/addons/plugin.video.putio/main.py", line 205, in <module>
                     main()
                   File "/home/_kodi/.kodi/addons/plugin.video.putio/main.py", line 199, in main
                     play(item=item)
                   File "/home/_kodi/.kodi/addons/plugin.video.putio/main.py", line 135, in play
                     li.setSubtitles(item.subtitles())
                                     ^^^^^^^^^^^^^^^^
                   File "/home/_kodi/.kodi/addons/plugin.video.putio/resources/lib/putio.py", line 189, in subtitles
                     assert subtitles_list_response.status_code == 200
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                 AttributeError: 'dict' object has no attribute 'status_code'
                 -->End of Python script error report<--

error <general>: Playlist Player: skipping unplayable item: 0, path [plugin://plugin.video.putio/?action=play&item=00000000000]
joelpurra commented 1 month ago

@berkanteber: only tested on Kodi v20.5.0. If you haven't seen any crashes on putio-kodi v3.1.0 on more recent Kodi versions, as you mentioned when closing #16, perhaps there's some other issue?

berkanteber commented 1 month ago

Seems like all asserts are stripped on v21 (or at least on my Kodi). That's why I assumed it's no longer an issue. If that's the case, it would be best to remove all asserts since they are misleading. But for now, let's just fix it.

berkanteber commented 1 month ago

If that's the case, it would be best to remove all asserts since they are misleading. But for now, let's just fix it.

Actually, it may be better to skip on subtitle-related errors.

joelpurra commented 1 month ago

@berkanteber: didn't know about this change in Kodi v21, but guess they see it as "production" mode. This assert is a valuable sanity check; removing it might lead to follow-up errors. Sure, skipping subtitles instead of crashing might be alright -- assuming that such future errors are merely intermittent.