diff --git a/CHANGELOG.md b/CHANGELOG.md index 787f27e..9096a87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +* [v2.3.0](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-2.3.0): + * Add concurrency error handling + * [v2.2.0](https://github.com/newt-sc/a4kSubtitles/releases/tag/service.subtitles.a4ksubtitles%2Fservice.subtitles.a4ksubtitles-2.2.0): * Fix KODI 19 Matrix support diff --git a/a4kSubtitles/api.py b/a4kSubtitles/api.py index 16bb966..153bb75 100644 --- a/a4kSubtitles/api.py +++ b/a4kSubtitles/api.py @@ -103,3 +103,15 @@ def download(self, params, settings=None): finally: if restore_settings: restore_settings() + + def auto_load_enabled(self, settings=None): + restore_settings = None + + try: + if settings: + restore_settings = self.mock_settings(settings) + + return self.core.kodi.get_bool_setting('general.auto_search') and self.core.kodi.get_bool_setting('general.auto_download') + finally: + if restore_settings: + restore_settings() diff --git a/a4kSubtitles/download.py b/a4kSubtitles/download.py index b6f9334..6e0d300 100644 --- a/a4kSubtitles/download.py +++ b/a4kSubtitles/download.py @@ -48,12 +48,18 @@ def __extract_zip(core, archivepath, filename, episodeid): try: return __extract_gzip(core, archivepath, filename) except: - core.os.rename(archivepath, dest) + try: core.os.remove(dest) + except: pass + try: core.os.rename(archivepath, dest) + except: pass return dest if not using_libvfs: src = core.utils.extract_zipfile_member(zipfile, subfile, core.utils.temp_dir) - core.os.rename(src, dest) + try: core.os.remove(dest) + except: pass + try: core.os.rename(src, dest) + except: pass else: src = 'archive://' + archivepath_ + '/' + subfile core.kodi.xbmcvfs.copy(src, dest) diff --git a/addon.xml b/addon.xml index da2a214..0bfae44 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ @@ -27,6 +27,9 @@ Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, Subscene, Addic7ed screenshot-03.png +[v2.3.0]: + * Add concurrency error handling + [v2.2.0]: * Fix KODI 19 Matrix support diff --git a/packages/addons.xml b/packages/addons.xml index 8a0bb03..2bb98c1 100644 --- a/packages/addons.xml +++ b/packages/addons.xml @@ -4,7 +4,7 @@ @@ -30,6 +30,9 @@ Supports: OpenSubtitles, BSPlayer, Podnadpisi.NET, Subscene, Addic7ed screenshot-03.png +[v2.3.0]: + * Add concurrency error handling + [v2.2.0]: * Fix KODI 19 Matrix support diff --git a/packages/addons.xml.crc b/packages/addons.xml.crc index 2051618..d083771 100644 --- a/packages/addons.xml.crc +++ b/packages/addons.xml.crc @@ -1 +1 @@ -76debceb64549a9e810cd1110ff064bbfd26a338 \ No newline at end of file +1cf652272d659fb7b413a06ee24601b01c3945c4 \ No newline at end of file diff --git a/tests/test_api.py b/tests/test_api.py index b5717b3..a4f1f7e 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -28,3 +28,34 @@ def get_error_msg(e): api.A4kSubtitlesApi({'xbmc': True, 'xbmcaddon': True, 'xbmcplugin': True, 'xbmcgui': True, 'xbmcvfs': True}) api.A4kSubtitlesApi({'kodi': True}) + +def test_auto_load_enabled(): + a4ksubtitles_api = api.A4kSubtitlesApi({'kodi': True}) + + settings = { + 'general.auto_search': 'true', + 'general.auto_download': 'true', + } + auto_load_enabled = a4ksubtitles_api.auto_load_enabled(settings) + assert auto_load_enabled is True + + settings = { + 'general.auto_search': 'false', + 'general.auto_download': 'true', + } + auto_load_enabled = a4ksubtitles_api.auto_load_enabled(settings) + assert auto_load_enabled is False + + settings = { + 'general.auto_search': 'true', + 'general.auto_download': 'false', + } + auto_load_enabled = a4ksubtitles_api.auto_load_enabled(settings) + assert auto_load_enabled is False + + settings = { + 'general.auto_search': 'false', + 'general.auto_download': 'false', + } + auto_load_enabled = a4ksubtitles_api.auto_load_enabled(settings) + assert auto_load_enabled is False