From a37ef4a418835e184c1d7d9780cfeb13e6ed929e Mon Sep 17 00:00:00 2001 From: josdion Date: Sun, 26 Apr 2020 11:06:00 +0300 Subject: [PATCH] opensubtitles - add get_fps function - added get_fps() function - getting of the authentication token from the cache is fixed --- libs/subliminal_patch/providers/opensubtitles.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libs/subliminal_patch/providers/opensubtitles.py b/libs/subliminal_patch/providers/opensubtitles.py index 012fe6c13..27f1e5e89 100644 --- a/libs/subliminal_patch/providers/opensubtitles.py +++ b/libs/subliminal_patch/providers/opensubtitles.py @@ -44,6 +44,12 @@ class OpenSubtitlesSubtitle(_OpenSubtitlesSubtitle): self.wrong_fps = False self.skip_wrong_fps = skip_wrong_fps + def get_fps(self): + try: + return float(self.fps) + except: + return None + def get_matches(self, video, hearing_impaired=False): matches = super(OpenSubtitlesSubtitle, self).get_matches(video) @@ -175,9 +181,10 @@ class OpenSubtitlesProvider(ProviderRetryMixin, _OpenSubtitlesProvider): logger.info('Logging in') - token = str(region.get("os_token")) - if token is not NO_VALUE: + token_cache = region.get("os_token") + if token_cache is not NO_VALUE: try: + token = token_cache.decode("utf-8") logger.debug('Trying previous token: %r', token[:10]+"X"*(len(token)-10)) checked(lambda: self.server.NoOperation(token)) self.token = token