jellyfin / jellyfin-plugin-opensubtitles

https://jellyfin.org
GNU General Public License v3.0
119 stars 25 forks source link

Add automatic invalidation of credentials #128

Closed MBR-0001 closed 1 year ago

MBR-0001 commented 1 year ago

Opensubtitles detected that the plugin sends a lot of bad requests, after some investigation the following was determined:

Currently, when the user sets up the login credentials/API key in the plugin settings page, the plugin stores the credentials and uses them for API requests. If the user changes their opensubtitles credentials (or deletes the API key), the plugin will try (and fail) to log in every time a subtitle search is attempted, which means that the plugin will spam the opensubtitles API with bad login attempts during the "download missing subtitles" task.

This PR adds automatic credentials invalidation by checking if the login attempt resulted in HTTP 400/401/403 (invalid api key), if yes it sets the CredentialsInvalid field to true and all further login attempts are ignored, until the user enters new credentials.

EDIT: draft because I'm waiting for the opensubtitles API to come back online to test this thoroughly EDIT 2: draft because I'm waiting for some info about possible 400s on login

Closes #127