siku2 / script.service.sponsorblock

Kodi add-on for SponsorBlock
MIT License
126 stars 15 forks source link

fix: return early if unsupported app #53

Closed SethFalco closed 1 year ago

SethFalco commented 1 year ago

Whenever I open a video on an app SponsorBlock doesn't support, it throws an exception. This adds a check if get_api returns a None object, if so then do nothing and exit early.

Example exception:

2023-06-21 18:32:28.072 T:922      info <general>: VideoPlayer::OpenFile: plugin://plugin.video.imdb.trailers/?action=play&videoid=vi105104409
2023-06-21 18:32:28.232 T:18516    info <general>: Creating InputStream
2023-06-21 18:32:28.242 T:29736   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: 'NoneType' object has no attribute 'get_video_id'
                                                   Traceback (most recent call last):
                                                     File "/storage/.kodi/addons/script.service.sponsorblock/resources/lib/player_listener.py", line 131, in onPlayBackStarted
                                                       video_id = get_api(addon_id).get_video_id()
                                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                   AttributeError: 'NoneType' object has no attribute 'get_video_id'
                                                   -->End of Python script error report<--

Related