From 256c401ef9602721a96de9b2f2dbfe2f3639a57f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sun, 10 Oct 2021 19:23:13 +0200 Subject: [PATCH 1/6] Fix flake8 lints --- jellyfin_kodi/helper/playutils.py | 3 +++ jellyfin_kodi/helper/utils.py | 2 +- jellyfin_kodi/views.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/jellyfin_kodi/helper/playutils.py b/jellyfin_kodi/helper/playutils.py index d6d1ea27..b599ab33 100644 --- a/jellyfin_kodi/helper/playutils.py +++ b/jellyfin_kodi/helper/playutils.py @@ -19,6 +19,8 @@ from . import translate, settings, window, dialog, api ################################################################################################# LOG = LazyLogger(__name__) + + class Transcode(enum.IntEnum): Enabled = 0 Audio = 1 @@ -607,6 +609,7 @@ class PlayUtils(object): subs_streams.append(index) skip_dialog = Transcode(int(settings('skipDialogTranscode') or 0)) + def get_track_title(track_index): return streams[track_index]['DisplayTitle'] or ("Track %s" % track_index) diff --git a/jellyfin_kodi/helper/utils.py b/jellyfin_kodi/helper/utils.py index 42529ff3..bd6e7010 100644 --- a/jellyfin_kodi/helper/utils.py +++ b/jellyfin_kodi/helper/utils.py @@ -549,6 +549,7 @@ def find_library(server, item): LOG.error('No ancestor found, not syncing item with ID: {}'.format(item['Id'])) return {} + def translate_path(path): ''' Use new library location for translate path starting in Kodi 19 @@ -559,4 +560,3 @@ def translate_path(path): return xbmcvfs.translatePath(path) else: return xbmc.translatePath(path) - diff --git a/jellyfin_kodi/views.py b/jellyfin_kodi/views.py index e3ee07c0..7d046565 100644 --- a/jellyfin_kodi/views.py +++ b/jellyfin_kodi/views.py @@ -7,7 +7,7 @@ import os import xml.etree.ElementTree as etree from six.moves.urllib.parse import urlencode -from kodi_six import xbmc, xbmcvfs +from kodi_six import xbmcvfs from database import Database, jellyfin_db, get_sync, save_sync from helper import translate, api, window, event From 086a704f24970d17af6c457173007b7b82c5d5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sun, 10 Oct 2021 19:44:32 +0200 Subject: [PATCH 2/6] Remove path injection --- .env | 1 - .gitignore | 1 + context.py | 18 ------------------ context_play.py | 18 ------------------ default.py | 18 ------------------ service.py | 17 +---------------- tests/test_clean_none_dict_values.py | 6 +----- tests/test_helper_utils.py | 6 +----- 8 files changed, 4 insertions(+), 81 deletions(-) diff --git a/.env b/.env index a8471c01..e69de29b 100644 --- a/.env +++ b/.env @@ -1 +0,0 @@ -PYTHONPATH=jellyfin_kodi diff --git a/.gitignore b/.gitignore index fa83b3a9..a3b78682 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,7 @@ coverage.xml *.py,cover .hypothesis/ .pytest_cache/ +.mypy_cache/ flake8.output test.xml diff --git a/context.py b/context.py index 2a6b3d5a..1613b482 100644 --- a/context.py +++ b/context.py @@ -3,24 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################# -import os -import sys - -from kodi_six import xbmc, xbmcaddon, xbmcvfs - -################################################################################################# - -kodi_version = int(xbmc.getInfoLabel('System.BuildVersion')[:2]) -__addon__ = xbmcaddon.Addon(id='plugin.video.jellyfin') -if kodi_version > 18: - __base__ = xbmcvfs.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'jellyfin_kodi')) -else: - __base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'jellyfin_kodi')) - -sys.path.insert(0, __base__) - -################################################################################################# - from entrypoint import Context # noqa: E402 from helper import LazyLogger # noqa: E402 diff --git a/context_play.py b/context_play.py index 01513485..bb128969 100644 --- a/context_play.py +++ b/context_play.py @@ -3,24 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################# -import os -import sys - -from kodi_six import xbmc, xbmcaddon, xbmcvfs - -################################################################################################# - -kodi_version = int(xbmc.getInfoLabel('System.BuildVersion')[:2]) -__addon__ = xbmcaddon.Addon(id='plugin.video.jellyfin') -if kodi_version > 18: - __base__ = xbmcvfs.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'jellyfin_kodi')) -else: - __base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'jellyfin_kodi')) - -sys.path.insert(0, __base__) - -################################################################################################# - from entrypoint import Context # noqa: E402 from helper import LazyLogger # noqa: E402 diff --git a/default.py b/default.py index 06610631..cebf129b 100644 --- a/default.py +++ b/default.py @@ -3,24 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################# -import os -import sys - -from kodi_six import xbmc, xbmcaddon, xbmcvfs - -################################################################################################# - -kodi_version = int(xbmc.getInfoLabel('System.BuildVersion')[:2]) -__addon__ = xbmcaddon.Addon(id='plugin.video.jellyfin') -if kodi_version > 18: - __base__ = xbmcvfs.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'jellyfin_kodi')) -else: - __base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'jellyfin_kodi')) - -sys.path.insert(0, __base__) - -################################################################################################# - from entrypoint import Events # noqa: E402 from helper import LazyLogger # noqa: E402 diff --git a/service.py b/service.py index c0f47b84..2623a857 100644 --- a/service.py +++ b/service.py @@ -3,24 +3,9 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################# -import os import threading -import sys -from kodi_six import xbmc, xbmcaddon, xbmcvfs - -################################################################################################# - -kodi_version = int(xbmc.getInfoLabel('System.BuildVersion')[:2]) -__addon__ = xbmcaddon.Addon(id='plugin.video.jellyfin') -if kodi_version > 18: - __base__ = xbmcvfs.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'jellyfin_kodi')) -else: - __base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'jellyfin_kodi')) - -sys.path.insert(0, __base__) - -################################################################################################# +from kodi_six import xbmc from entrypoint import Service # noqa: E402 from helper.utils import settings # noqa: E402 diff --git a/tests/test_clean_none_dict_values.py b/tests/test_clean_none_dict_values.py index 9c094fb1..4a4f43d8 100644 --- a/tests/test_clean_none_dict_values.py +++ b/tests/test_clean_none_dict_values.py @@ -1,10 +1,6 @@ -import sys - import pytest -sys.path.insert(0, 'jellyfin_kodi') - -from jellyfin.utils import clean_none_dict_values # noqa: E402 +from jellyfin_kodi.jellyfin.utils import clean_none_dict_values @pytest.mark.parametrize("obj,expected", [ diff --git a/tests/test_helper_utils.py b/tests/test_helper_utils.py index 2be266ea..89732e0b 100644 --- a/tests/test_helper_utils.py +++ b/tests/test_helper_utils.py @@ -1,13 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import division, absolute_import, print_function, unicode_literals -import sys - import pytest -sys.path.insert(0, 'jellyfin_kodi') - -from helper.utils import values # noqa: E402 +from jellyfin_kodi.helper.utils import values item1 = {'foo': 123, 'bar': 456, 'baz': 789} From 53c887d3547ea4a5ab618d5f63b483cd2f036102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sun, 10 Oct 2021 20:38:25 +0200 Subject: [PATCH 3/6] Use module-relative imports --- context.py | 4 ++-- context_play.py | 4 ++-- default.py | 4 ++-- jellyfin_kodi/client.py | 5 ++-- jellyfin_kodi/connect.py | 15 ++++++------ jellyfin_kodi/database/__init__.py | 12 +++++----- jellyfin_kodi/database/jellyfin_db.py | 6 ++--- jellyfin_kodi/dialogs/context.py | 4 ++-- jellyfin_kodi/dialogs/loginmanual.py | 4 +--- jellyfin_kodi/dialogs/resume.py | 2 +- jellyfin_kodi/dialogs/serverconnect.py | 6 ++--- jellyfin_kodi/dialogs/servermanual.py | 6 ++--- jellyfin_kodi/dialogs/usersconnect.py | 2 +- jellyfin_kodi/downloader.py | 10 ++++---- jellyfin_kodi/entrypoint/__init__.py | 10 ++------ jellyfin_kodi/entrypoint/context.py | 11 ++++----- jellyfin_kodi/entrypoint/default.py | 25 ++++++++++---------- jellyfin_kodi/entrypoint/service.py | 19 +++++++-------- jellyfin_kodi/full_sync.py | 14 +++++------ jellyfin_kodi/helper/api.py | 4 +--- jellyfin_kodi/helper/lazylogger.py | 2 +- jellyfin_kodi/helper/loghandler.py | 9 +++---- jellyfin_kodi/helper/playutils.py | 9 ++++--- jellyfin_kodi/helper/translate.py | 2 +- jellyfin_kodi/helper/utils.py | 2 +- jellyfin_kodi/helper/wrapper.py | 2 +- jellyfin_kodi/helper/xmls.py | 6 ++--- jellyfin_kodi/jellyfin/__init__.py | 6 ++--- jellyfin_kodi/jellyfin/api.py | 4 ++-- jellyfin_kodi/jellyfin/client.py | 2 +- jellyfin_kodi/jellyfin/configuration.py | 2 +- jellyfin_kodi/jellyfin/connection_manager.py | 2 +- jellyfin_kodi/jellyfin/credentials.py | 2 +- jellyfin_kodi/jellyfin/http.py | 8 +++---- jellyfin_kodi/jellyfin/ws_client.py | 2 +- jellyfin_kodi/library.py | 19 +++++++-------- jellyfin_kodi/monitor.py | 16 ++++++------- jellyfin_kodi/objects/actions.py | 12 +++++----- jellyfin_kodi/objects/kodi/artwork.py | 2 +- jellyfin_kodi/objects/kodi/kodi.py | 3 +-- jellyfin_kodi/objects/kodi/movies.py | 2 +- jellyfin_kodi/objects/kodi/music.py | 2 +- jellyfin_kodi/objects/kodi/musicvideos.py | 2 +- jellyfin_kodi/objects/kodi/tvshows.py | 2 +- jellyfin_kodi/objects/movies.py | 12 +++++----- jellyfin_kodi/objects/music.py | 9 ++++--- jellyfin_kodi/objects/musicvideos.py | 9 ++++--- jellyfin_kodi/objects/obj.py | 2 +- jellyfin_kodi/objects/tvshows.py | 12 +++++----- jellyfin_kodi/objects/utils.py | 4 ++-- jellyfin_kodi/player.py | 10 ++++---- jellyfin_kodi/views.py | 10 ++++---- service.py | 6 ++--- 53 files changed, 166 insertions(+), 195 deletions(-) diff --git a/context.py b/context.py index 1613b482..0326e073 100644 --- a/context.py +++ b/context.py @@ -3,8 +3,8 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################# -from entrypoint import Context # noqa: E402 -from helper import LazyLogger # noqa: E402 +from jellyfin_kodi.entrypoint import Context +from jellyfin_kodi.helper import LazyLogger ################################################################################################# diff --git a/context_play.py b/context_play.py index bb128969..c2fcc774 100644 --- a/context_play.py +++ b/context_play.py @@ -3,8 +3,8 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################# -from entrypoint import Context # noqa: E402 -from helper import LazyLogger # noqa: E402 +from jellyfin_kodi.entrypoint import Context +from jellyfin_kodi.helper import LazyLogger ################################################################################################# diff --git a/default.py b/default.py index cebf129b..ac86b22a 100644 --- a/default.py +++ b/default.py @@ -3,8 +3,8 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################# -from entrypoint import Events # noqa: E402 -from helper import LazyLogger # noqa: E402 +from jellyfin_kodi.entrypoint import Events +from jellyfin_kodi.helper import LazyLogger ################################################################################################# diff --git a/jellyfin_kodi/client.py b/jellyfin_kodi/client.py index a521c7dd..0879225d 100644 --- a/jellyfin_kodi/client.py +++ b/jellyfin_kodi/client.py @@ -7,9 +7,8 @@ import os from kodi_six import xbmc, xbmcaddon, xbmcvfs -from helper import translate, window, settings, addon_id, dialog -from helper.utils import create_id, translate_path -from helper import LazyLogger # noqa: F402 +from .helper import translate, window, settings, addon_id, dialog, LazyLogger +from .helper.utils import create_id, translate_path ################################################################################################## diff --git a/jellyfin_kodi/connect.py b/jellyfin_kodi/connect.py index ec2fa325..7566ce90 100644 --- a/jellyfin_kodi/connect.py +++ b/jellyfin_kodi/connect.py @@ -5,14 +5,13 @@ from __future__ import division, absolute_import, print_function, unicode_litera from kodi_six import xbmc, xbmcaddon -import client -from database import get_credentials, save_credentials -from dialogs import ServerConnect, UsersConnect, LoginManual, ServerManual -from helper import settings, addon_id, event, api, window -from jellyfin import Jellyfin -from jellyfin.connection_manager import CONNECTION_STATE -from helper.exceptions import HTTPException -from helper import LazyLogger +from . import client +from .database import get_credentials, save_credentials +from .dialogs import ServerConnect, UsersConnect, LoginManual, ServerManual +from .helper import settings, addon_id, event, api, window, LazyLogger +from .jellyfin import Jellyfin +from .jellyfin.connection_manager import CONNECTION_STATE +from .helper.exceptions import HTTPException ################################################################################################## diff --git a/jellyfin_kodi/database/__init__.py b/jellyfin_kodi/database/__init__.py index fe7d62e1..af1bf859 100644 --- a/jellyfin_kodi/database/__init__.py +++ b/jellyfin_kodi/database/__init__.py @@ -12,11 +12,11 @@ import re from kodi_six import xbmc, xbmcvfs from six import text_type -from database import jellyfin_db -from helper import translate, settings, window, dialog -from helper.utils import translate_path -from objects import obj -from helper import LazyLogger +from . import jellyfin_db +from ..helper import translate, settings, window, dialog +from ..helper.utils import translate_path +from ..objects import obj +from ..helper import LazyLogger ################################################################################################# @@ -200,7 +200,7 @@ def reset(): ''' Reset both the jellyfin database and the kodi database. ''' - from views import Views + from ..views import Views views = Views() if not dialog("yesno", "{jellyfin}", translate(33074)): diff --git a/jellyfin_kodi/database/jellyfin_db.py b/jellyfin_kodi/database/jellyfin_db.py index 5683e740..a518b830 100644 --- a/jellyfin_kodi/database/jellyfin_db.py +++ b/jellyfin_kodi/database/jellyfin_db.py @@ -2,10 +2,10 @@ from __future__ import division, absolute_import, print_function, unicode_literals ################################################################################################# -from database import queries as QU -from helper import LazyLogger +from . import queries as QU +from ..helper import LazyLogger -from jellyfin.utils import sqlite_namedtuple_factory +from ..jellyfin.utils import sqlite_namedtuple_factory ################################################################################################## diff --git a/jellyfin_kodi/dialogs/context.py b/jellyfin_kodi/dialogs/context.py index d2b51e7a..6d48a503 100644 --- a/jellyfin_kodi/dialogs/context.py +++ b/jellyfin_kodi/dialogs/context.py @@ -8,8 +8,8 @@ import os from kodi_six import xbmcgui, xbmcaddon from six import ensure_text -from helper import window, addon_id -from helper import LazyLogger +from ..helper import window, addon_id +from ..helper import LazyLogger ################################################################################################## diff --git a/jellyfin_kodi/dialogs/loginmanual.py b/jellyfin_kodi/dialogs/loginmanual.py index eee28d41..1d70bec2 100644 --- a/jellyfin_kodi/dialogs/loginmanual.py +++ b/jellyfin_kodi/dialogs/loginmanual.py @@ -6,9 +6,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera from six import iteritems from kodi_six import xbmcgui -from helper import translate -from helper import LazyLogger -from helper import kodi_version +from ..helper import translate, LazyLogger, kodi_version ################################################################################################## diff --git a/jellyfin_kodi/dialogs/resume.py b/jellyfin_kodi/dialogs/resume.py index bee793f9..0357a413 100644 --- a/jellyfin_kodi/dialogs/resume.py +++ b/jellyfin_kodi/dialogs/resume.py @@ -5,7 +5,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera from kodi_six import xbmc, xbmcgui -from helper import LazyLogger +from ..helper import LazyLogger ################################################################################################## diff --git a/jellyfin_kodi/dialogs/serverconnect.py b/jellyfin_kodi/dialogs/serverconnect.py index c4c3afff..73d72058 100644 --- a/jellyfin_kodi/dialogs/serverconnect.py +++ b/jellyfin_kodi/dialogs/serverconnect.py @@ -6,9 +6,9 @@ from __future__ import division, absolute_import, print_function, unicode_litera from six import iteritems from kodi_six import xbmc, xbmcgui -from helper import translate -from jellyfin.connection_manager import CONNECTION_STATE -from helper import LazyLogger +from ..helper import translate +from ..jellyfin.connection_manager import CONNECTION_STATE +from ..helper import LazyLogger ################################################################################################## diff --git a/jellyfin_kodi/dialogs/servermanual.py b/jellyfin_kodi/dialogs/servermanual.py index 803e706a..551c840e 100644 --- a/jellyfin_kodi/dialogs/servermanual.py +++ b/jellyfin_kodi/dialogs/servermanual.py @@ -8,9 +8,9 @@ import re from six import iteritems from kodi_six import xbmcgui -from helper import translate -from jellyfin.connection_manager import CONNECTION_STATE -from helper import LazyLogger +from ..helper import translate +from ..jellyfin.connection_manager import CONNECTION_STATE +from ..helper import LazyLogger ################################################################################################## diff --git a/jellyfin_kodi/dialogs/usersconnect.py b/jellyfin_kodi/dialogs/usersconnect.py index a361756d..69312da7 100644 --- a/jellyfin_kodi/dialogs/usersconnect.py +++ b/jellyfin_kodi/dialogs/usersconnect.py @@ -6,7 +6,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera from six import iteritems from kodi_six import xbmc, xbmcgui -from helper import LazyLogger +from ..helper import LazyLogger ################################################################################################## diff --git a/jellyfin_kodi/downloader.py b/jellyfin_kodi/downloader.py index fa67facc..b52128c6 100644 --- a/jellyfin_kodi/downloader.py +++ b/jellyfin_kodi/downloader.py @@ -10,11 +10,11 @@ from datetime import date from six.moves import range, queue as Queue import requests -from helper import settings, stop, window -from jellyfin import Jellyfin -from jellyfin import api -from helper.exceptions import HTTPException -from helper import LazyLogger + +from .helper import settings, stop, window, LazyLogger +from .jellyfin import Jellyfin +from .jellyfin import api +from .helper.exceptions import HTTPException ################################################################################################# diff --git a/jellyfin_kodi/entrypoint/__init__.py b/jellyfin_kodi/entrypoint/__init__.py index 84a9e4b4..8fbf2c8d 100644 --- a/jellyfin_kodi/entrypoint/__init__.py +++ b/jellyfin_kodi/entrypoint/__init__.py @@ -3,19 +3,13 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################# -import logging - from kodi_six import xbmc, xbmcvfs -from helper import LazyLogger -from jellyfin import Jellyfin +from ..helper import LazyLogger +from ..jellyfin import Jellyfin from .default import Events from .service import Service from .context import Context ################################################################################################# - -LOG = LazyLogger(__name__) - -################################################################################################# diff --git a/jellyfin_kodi/entrypoint/context.py b/jellyfin_kodi/entrypoint/context.py index 0b0f1708..f1cfb690 100644 --- a/jellyfin_kodi/entrypoint/context.py +++ b/jellyfin_kodi/entrypoint/context.py @@ -8,12 +8,11 @@ import sys from kodi_six import xbmc, xbmcaddon -import database -from dialogs import context -from helper import translate, settings, dialog -from helper import LazyLogger -from helper.utils import translate_path -from jellyfin import Jellyfin +from .. import database +from ..dialogs import context +from ..helper import translate, settings, dialog, LazyLogger +from ..helper.utils import translate_path +from ..jellyfin import Jellyfin ################################################################################################# diff --git a/jellyfin_kodi/entrypoint/default.py b/jellyfin_kodi/entrypoint/default.py index d2b400a4..adc8009f 100644 --- a/jellyfin_kodi/entrypoint/default.py +++ b/jellyfin_kodi/entrypoint/default.py @@ -11,13 +11,12 @@ from six import iteritems from six.moves.urllib.parse import parse_qsl, urlencode from kodi_six import xbmc, xbmcvfs, xbmcgui, xbmcplugin, xbmcaddon -import client -from database import reset, get_sync, Database, jellyfin_db, get_credentials -from objects import Objects, Actions -from helper import translate, event, settings, window, dialog, api, JSONRPC -from helper.utils import JsonDebugPrinter, translate_path -from helper import LazyLogger -from jellyfin import Jellyfin +from .. import client +from ..database import reset, get_sync, Database, jellyfin_db, get_credentials +from ..objects import Objects, Actions +from ..helper import translate, event, settings, window, dialog, api, JSONRPC, LazyLogger +from ..helper.utils import JsonDebugPrinter, translate_path +from ..jellyfin import Jellyfin ################################################################################################# @@ -426,7 +425,7 @@ def browse_subfolders(media, view_id, server_id=None): ''' Display submenus for jellyfin views. ''' - from views import DYNNODES + from ..views import DYNNODES view = Jellyfin(server_id).get_client().jellyfin.get_item(view_id) xbmcplugin.setPluginCategory(PROCESS_HANDLE, view['Name']) @@ -792,9 +791,9 @@ def get_themes(api_client): ''' Add theme media locally, via strm. This is only for tv tunes. If another script is used, adjust this code. ''' - from helper.utils import normalize_string - from helper.playutils import PlayUtils - from helper.xmls import tvtunes_nfo + from ..helper.utils import normalize_string + from ..helper.playutils import PlayUtils + from ..helper.xmls import tvtunes_nfo library = translate_path("special://profile/addon_data/plugin.video.jellyfin/library") play = settings('useDirectPaths') == "1" @@ -863,7 +862,7 @@ def delete_item(): ''' Delete keymap action. ''' - import context + from . import context context.Context(delete=True) @@ -872,7 +871,7 @@ def backup(): ''' Jellyfin backup. ''' - from helper.utils import delete_folder, copytree + from ..helper.utils import delete_folder, copytree path = settings('backupPath') folder_name = "Kodi%s.%s" % (xbmc.getInfoLabel('System.BuildVersion')[:2], xbmc.getInfoLabel('System.Date(dd-mm-yy)')) diff --git a/jellyfin_kodi/entrypoint/service.py b/jellyfin_kodi/entrypoint/service.py index 8e30b27e..7d5a3bf5 100644 --- a/jellyfin_kodi/entrypoint/service.py +++ b/jellyfin_kodi/entrypoint/service.py @@ -12,16 +12,15 @@ import _strptime # noqa:F401 from kodi_six import xbmc, xbmcgui from six.moves import reload_module as reload -import objects -import connect -import client -import library -import monitor -from views import Views -from helper import translate, window, settings, event, dialog, set_addon_mode -from helper.utils import JsonDebugPrinter, translate_path -from jellyfin import Jellyfin -from helper import LazyLogger +from .. import objects +from .. import connect +from .. import client +from .. import library +from .. import monitor +from ..views import Views +from ..helper import translate, window, settings, event, dialog, set_addon_mode, LazyLogger +from ..helper.utils import JsonDebugPrinter, translate_path +from ..jellyfin import Jellyfin ################################################################################################# diff --git a/jellyfin_kodi/full_sync.py b/jellyfin_kodi/full_sync.py index 8ce9a7f8..9501d665 100644 --- a/jellyfin_kodi/full_sync.py +++ b/jellyfin_kodi/full_sync.py @@ -8,14 +8,12 @@ import datetime from kodi_six import xbmc -import downloader as server -import helper.xmls as xmls -from objects import Movies, TVShows, MusicVideos, Music -from database import Database, get_sync, save_sync, jellyfin_db -from helper import translate, settings, window, progress, dialog -from helper.utils import get_screensaver, set_screensaver -from helper import LazyLogger -from helper.exceptions import LibraryException, PathValidationException +from . import downloader as server +from .objects import Movies, TVShows, MusicVideos, Music +from .database import Database, get_sync, save_sync, jellyfin_db +from .helper import translate, settings, window, progress, dialog, LazyLogger, xmls +from .helper.utils import get_screensaver, set_screensaver +from .helper.exceptions import LibraryException, PathValidationException ################################################################################################## diff --git a/jellyfin_kodi/helper/api.py b/jellyfin_kodi/helper/api.py index 7ecf80ad..ea8e9ee9 100644 --- a/jellyfin_kodi/helper/api.py +++ b/jellyfin_kodi/helper/api.py @@ -3,9 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################## -from helper import LazyLogger - -from . import settings +from . import settings, LazyLogger ################################################################################################## diff --git a/jellyfin_kodi/helper/lazylogger.py b/jellyfin_kodi/helper/lazylogger.py index 52534ec2..c53ddefa 100644 --- a/jellyfin_kodi/helper/lazylogger.py +++ b/jellyfin_kodi/helper/lazylogger.py @@ -14,6 +14,6 @@ class LazyLogger(object): def __getattr__(self, name): if self.__logger is None: - from helper.loghandler import getLogger + from .loghandler import getLogger self.__logger = getLogger(self.__logger_name) return getattr(self.__logger, name) diff --git a/jellyfin_kodi/helper/loghandler.py b/jellyfin_kodi/helper/loghandler.py index 306a50f2..ce06ecb1 100644 --- a/jellyfin_kodi/helper/loghandler.py +++ b/jellyfin_kodi/helper/loghandler.py @@ -10,12 +10,9 @@ import traceback from six import ensure_text from kodi_six import xbmc, xbmcaddon -import database -from helper import get_filesystem_encoding -from helper.utils import translate_path - -from . import settings -from . import kodi_version +from .. import database +from . import get_filesystem_encoding, settings, kodi_version +from .utils import translate_path ################################################################################################## diff --git a/jellyfin_kodi/helper/playutils.py b/jellyfin_kodi/helper/playutils.py index b599ab33..ad9c377f 100644 --- a/jellyfin_kodi/helper/playutils.py +++ b/jellyfin_kodi/helper/playutils.py @@ -7,14 +7,13 @@ import enum import os from uuid import uuid4 +import requests from kodi_six import xbmc, xbmcvfs -import client -import requests -from helper import LazyLogger -from helper.utils import translate_path +from .. import client +from .utils import translate_path -from . import translate, settings, window, dialog, api +from . import translate, settings, window, dialog, api, LazyLogger ################################################################################################# diff --git a/jellyfin_kodi/helper/translate.py b/jellyfin_kodi/helper/translate.py index 8b75b1de..2714e9ee 100644 --- a/jellyfin_kodi/helper/translate.py +++ b/jellyfin_kodi/helper/translate.py @@ -5,7 +5,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera from kodi_six import xbmc, xbmcaddon -from helper import LazyLogger +from . import LazyLogger ################################################################################################## diff --git a/jellyfin_kodi/helper/utils.py b/jellyfin_kodi/helper/utils.py index bd6e7010..4d248b55 100644 --- a/jellyfin_kodi/helper/utils.py +++ b/jellyfin_kodi/helper/utils.py @@ -537,7 +537,7 @@ def get_filesystem_encoding(): def find_library(server, item): - from database import get_sync + from ..database import get_sync sync = get_sync() diff --git a/jellyfin_kodi/helper/wrapper.py b/jellyfin_kodi/helper/wrapper.py index 9077a48c..1b814da1 100644 --- a/jellyfin_kodi/helper/wrapper.py +++ b/jellyfin_kodi/helper/wrapper.py @@ -5,7 +5,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera from kodi_six import xbmcgui -from helper import LazyLogger +from . import LazyLogger from .utils import should_stop from .exceptions import LibraryException diff --git a/jellyfin_kodi/helper/xmls.py b/jellyfin_kodi/helper/xmls.py index 6e62ba9d..907e142c 100644 --- a/jellyfin_kodi/helper/xmls.py +++ b/jellyfin_kodi/helper/xmls.py @@ -8,10 +8,8 @@ import xml.etree.ElementTree as etree from kodi_six import xbmc -from helper import LazyLogger -from helper.utils import translate_path - -from . import translate, dialog, settings +from .utils import translate_path +from . import translate, dialog, settings, LazyLogger ################################################################################################# diff --git a/jellyfin_kodi/jellyfin/__init__.py b/jellyfin_kodi/jellyfin/__init__.py index 74178de7..6d0bcdec 100644 --- a/jellyfin_kodi/jellyfin/__init__.py +++ b/jellyfin_kodi/jellyfin/__init__.py @@ -3,9 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################# -import logging - -from helper import has_attribute, LazyLogger +from ..helper import has_attribute, LazyLogger from .client import JellyfinClient @@ -35,7 +33,7 @@ class Jellyfin(object): ''' This is your Jellyfinclient, you can create more than one. The server_id is only a temporary thing to communicate with the JellyfinClient(). - from jellyfin import Jellyfin + from jellyfin_kodi.jellyfin import Jellyfin Jellyfin('123456').config.data['app'] diff --git a/jellyfin_kodi/jellyfin/api.py b/jellyfin_kodi/jellyfin/api.py index a8702f0c..c9761025 100644 --- a/jellyfin_kodi/jellyfin/api.py +++ b/jellyfin_kodi/jellyfin/api.py @@ -5,8 +5,8 @@ import json import requests -from helper.utils import settings -from helper import LazyLogger +from ..helper.utils import settings +from ..helper import LazyLogger from six import ensure_str diff --git a/jellyfin_kodi/jellyfin/client.py b/jellyfin_kodi/jellyfin/client.py index 0da2975e..c22397c2 100644 --- a/jellyfin_kodi/jellyfin/client.py +++ b/jellyfin_kodi/jellyfin/client.py @@ -3,7 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################# -from helper import LazyLogger +from ..helper import LazyLogger from . import api from .configuration import Config diff --git a/jellyfin_kodi/jellyfin/configuration.py b/jellyfin_kodi/jellyfin/configuration.py index 0b6607e6..c8407dbf 100644 --- a/jellyfin_kodi/jellyfin/configuration.py +++ b/jellyfin_kodi/jellyfin/configuration.py @@ -7,7 +7,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################# -from helper import LazyLogger +from ..helper import LazyLogger ################################################################################################# diff --git a/jellyfin_kodi/jellyfin/connection_manager.py b/jellyfin_kodi/jellyfin/connection_manager.py index 669f23b3..bdba0652 100644 --- a/jellyfin_kodi/jellyfin/connection_manager.py +++ b/jellyfin_kodi/jellyfin/connection_manager.py @@ -11,7 +11,7 @@ import traceback import urllib3 -from helper import LazyLogger +from ..helper import LazyLogger from .credentials import Credentials from .api import API diff --git a/jellyfin_kodi/jellyfin/credentials.py b/jellyfin_kodi/jellyfin/credentials.py index 661792a7..638f4af3 100644 --- a/jellyfin_kodi/jellyfin/credentials.py +++ b/jellyfin_kodi/jellyfin/credentials.py @@ -6,7 +6,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera import time from datetime import datetime -from helper import LazyLogger +from ..helper import LazyLogger ################################################################################################# diff --git a/jellyfin_kodi/jellyfin/http.py b/jellyfin_kodi/jellyfin/http.py index 63c0f570..646dc071 100644 --- a/jellyfin_kodi/jellyfin/http.py +++ b/jellyfin_kodi/jellyfin/http.py @@ -8,10 +8,10 @@ import time import requests from six import string_types, ensure_str -from helper.utils import JsonDebugPrinter -from helper import LazyLogger -from helper.exceptions import HTTPException -from jellyfin.utils import clean_none_dict_values +from ..helper.utils import JsonDebugPrinter +from ..helper import LazyLogger +from ..helper.exceptions import HTTPException +from .utils import clean_none_dict_values ################################################################################################# diff --git a/jellyfin_kodi/jellyfin/ws_client.py b/jellyfin_kodi/jellyfin/ws_client.py index 30f4c831..72b81b80 100644 --- a/jellyfin_kodi/jellyfin/ws_client.py +++ b/jellyfin_kodi/jellyfin/ws_client.py @@ -8,7 +8,7 @@ import threading from kodi_six import xbmc -from helper import LazyLogger +from ..helper import LazyLogger # If numpy is installed, the websockets library tries to use it, and then # kodi hard crashes for reasons I don't even want to pretend to understand diff --git a/jellyfin_kodi/library.py b/jellyfin_kodi/library.py index 01bb4eac..b44e722d 100644 --- a/jellyfin_kodi/library.py +++ b/jellyfin_kodi/library.py @@ -10,16 +10,15 @@ from six.moves import queue as Queue from kodi_six import xbmc, xbmcgui -from objects import Movies, TVShows, MusicVideos, Music -from database import Database, jellyfin_db, get_sync, save_sync -from full_sync import FullSync -from views import Views -from downloader import GetItemWorker -from helper import translate, api, stop, settings, window, dialog, event -from helper.utils import split_list, set_screensaver, get_screensaver -from helper.exceptions import LibraryException -from jellyfin import Jellyfin -from helper import LazyLogger +from .objects import Movies, TVShows, MusicVideos, Music +from .database import Database, jellyfin_db, get_sync, save_sync +from .full_sync import FullSync +from .views import Views +from .downloader import GetItemWorker +from .helper import translate, api, stop, settings, window, dialog, event, LazyLogger +from .helper.utils import split_list, set_screensaver, get_screensaver +from .helper.exceptions import LibraryException +from .jellyfin import Jellyfin ################################################################################################## diff --git a/jellyfin_kodi/monitor.py b/jellyfin_kodi/monitor.py index d1928fa2..4b2e6bec 100644 --- a/jellyfin_kodi/monitor.py +++ b/jellyfin_kodi/monitor.py @@ -9,14 +9,14 @@ import threading from kodi_six import xbmc -import connect -import player -from client import get_device_id -from objects import PlaylistWorker, on_play, on_update, special_listener -from helper import translate, settings, window, dialog, api, JSONRPC -from helper.utils import JsonDebugPrinter -from jellyfin import Jellyfin -from helper import LazyLogger +from . import connect +from . import player +from .client import get_device_id +from .objects import PlaylistWorker, on_play, on_update, special_listener +from .helper import translate, settings, window, dialog, api, JSONRPC +from .helper.utils import JsonDebugPrinter +from .jellyfin import Jellyfin +from .helper import LazyLogger ################################################################################################# diff --git a/jellyfin_kodi/objects/actions.py b/jellyfin_kodi/objects/actions.py index 7eef6a3d..d49c6b46 100644 --- a/jellyfin_kodi/objects/actions.py +++ b/jellyfin_kodi/objects/actions.py @@ -10,12 +10,12 @@ from datetime import timedelta from kodi_six import xbmc, xbmcgui, xbmcplugin, xbmcaddon -import database -from helper import translate, playutils, api, window, settings, dialog -from dialogs import resume -from helper import LazyLogger -from jellyfin import Jellyfin -from helper.utils import translate_path +from .. import database +from ..helper import translate, playutils, api, window, settings, dialog +from ..dialogs import resume +from ..helper import LazyLogger +from ..jellyfin import Jellyfin +from ..helper.utils import translate_path from .obj import Objects diff --git a/jellyfin_kodi/objects/kodi/artwork.py b/jellyfin_kodi/objects/kodi/artwork.py index a986f96a..a37320a8 100644 --- a/jellyfin_kodi/objects/kodi/artwork.py +++ b/jellyfin_kodi/objects/kodi/artwork.py @@ -3,7 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################# -from helper import LazyLogger +from ...helper import LazyLogger from . import queries as QU diff --git a/jellyfin_kodi/objects/kodi/kodi.py b/jellyfin_kodi/objects/kodi/kodi.py index d0276c11..b9650149 100644 --- a/jellyfin_kodi/objects/kodi/kodi.py +++ b/jellyfin_kodi/objects/kodi/kodi.py @@ -3,8 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################## -from helper import values -from helper import LazyLogger +from ...helper import values, LazyLogger from . import artwork from . import queries as QU diff --git a/jellyfin_kodi/objects/kodi/movies.py b/jellyfin_kodi/objects/kodi/movies.py index 5d3dfb28..e0a20475 100644 --- a/jellyfin_kodi/objects/kodi/movies.py +++ b/jellyfin_kodi/objects/kodi/movies.py @@ -3,7 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################## -from helper import LazyLogger +from ...helper import LazyLogger from .kodi import Kodi from . import queries as QU diff --git a/jellyfin_kodi/objects/kodi/music.py b/jellyfin_kodi/objects/kodi/music.py index 8033f572..84d7a1a4 100644 --- a/jellyfin_kodi/objects/kodi/music.py +++ b/jellyfin_kodi/objects/kodi/music.py @@ -3,7 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################## -from helper import LazyLogger +from ...helper import LazyLogger from . import queries_music as QU from .kodi import Kodi diff --git a/jellyfin_kodi/objects/kodi/musicvideos.py b/jellyfin_kodi/objects/kodi/musicvideos.py index 14752a52..97f3f6b6 100644 --- a/jellyfin_kodi/objects/kodi/musicvideos.py +++ b/jellyfin_kodi/objects/kodi/musicvideos.py @@ -3,7 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################## -from helper import LazyLogger +from ...helper import LazyLogger from . import queries as QU from .kodi import Kodi diff --git a/jellyfin_kodi/objects/kodi/tvshows.py b/jellyfin_kodi/objects/kodi/tvshows.py index 81f1e4bf..e2a34449 100644 --- a/jellyfin_kodi/objects/kodi/tvshows.py +++ b/jellyfin_kodi/objects/kodi/tvshows.py @@ -3,7 +3,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################## -from helper import LazyLogger +from ...helper import LazyLogger from . import queries as QU from .kodi import Kodi diff --git a/jellyfin_kodi/objects/movies.py b/jellyfin_kodi/objects/movies.py index 2cf9ce53..45cf2e07 100644 --- a/jellyfin_kodi/objects/movies.py +++ b/jellyfin_kodi/objects/movies.py @@ -6,12 +6,12 @@ from __future__ import division, absolute_import, print_function, unicode_litera from six.moves.urllib.parse import urlencode from kodi_six.utils import py2_encode -import downloader as server -from database import jellyfin_db, queries as QUEM -from helper import api, stop, validate, validate_bluray_dir, validate_dvd_dir, jellyfin_item, values, Local -from helper import LazyLogger -from helper.utils import find_library -from helper.exceptions import PathValidationException +from .. import downloader as server +from ..database import jellyfin_db, queries as QUEM +from ..helper import api, stop, validate, validate_bluray_dir, validate_dvd_dir, jellyfin_item, values, Local +from ..helper import LazyLogger +from ..helper.utils import find_library +from ..helper.exceptions import PathValidationException from .obj import Objects from .kodi import Movies as KodiDb, queries as QU diff --git a/jellyfin_kodi/objects/music.py b/jellyfin_kodi/objects/music.py index 72631dae..2a95bfa7 100644 --- a/jellyfin_kodi/objects/music.py +++ b/jellyfin_kodi/objects/music.py @@ -5,11 +5,10 @@ from __future__ import division, absolute_import, print_function, unicode_litera import datetime -from database import jellyfin_db, queries as QUEM -from helper import api, stop, validate, jellyfin_item, values, Local -from helper import LazyLogger -from helper.utils import find_library -from helper.exceptions import PathValidationException +from ..database import jellyfin_db, queries as QUEM +from ..helper import api, stop, validate, jellyfin_item, values, Local, LazyLogger +from ..helper.utils import find_library +from ..helper.exceptions import PathValidationException from .obj import Objects from .kodi import Music as KodiDb, queries_music as QU diff --git a/jellyfin_kodi/objects/musicvideos.py b/jellyfin_kodi/objects/musicvideos.py index 8dff2c57..0d80dccd 100644 --- a/jellyfin_kodi/objects/musicvideos.py +++ b/jellyfin_kodi/objects/musicvideos.py @@ -9,11 +9,10 @@ import re from six.moves.urllib.parse import urlencode from kodi_six.utils import py2_encode -from database import jellyfin_db, queries as QUEM -from helper import api, stop, validate, jellyfin_item, values, Local -from helper import LazyLogger -from helper.utils import find_library -from helper.exceptions import PathValidationException +from ..database import jellyfin_db, queries as QUEM +from ..helper import api, stop, validate, jellyfin_item, values, Local, LazyLogger +from ..helper.utils import find_library +from ..helper.exceptions import PathValidationException from .obj import Objects from .kodi import MusicVideos as KodiDb, queries as QU diff --git a/jellyfin_kodi/objects/obj.py b/jellyfin_kodi/objects/obj.py index 5aedb80f..f9015791 100644 --- a/jellyfin_kodi/objects/obj.py +++ b/jellyfin_kodi/objects/obj.py @@ -8,7 +8,7 @@ import os from six import iteritems, ensure_text -from helper import LazyLogger, get_filesystem_encoding +from ..helper import LazyLogger, get_filesystem_encoding ################################################################################################## diff --git a/jellyfin_kodi/objects/tvshows.py b/jellyfin_kodi/objects/tvshows.py index 3da519a1..61809779 100644 --- a/jellyfin_kodi/objects/tvshows.py +++ b/jellyfin_kodi/objects/tvshows.py @@ -9,12 +9,12 @@ from ntpath import dirname from six.moves.urllib.parse import urlencode from kodi_six.utils import py2_encode -import downloader as server -from database import jellyfin_db, queries as QUEM -from helper import api, stop, validate, validate_bluray_dir, validate_dvd_dir, jellyfin_item, values, Local -from helper import LazyLogger -from helper.utils import find_library -from helper.exceptions import PathValidationException +from .. import downloader as server +from ..database import jellyfin_db, queries as QUEM +from ..helper import api, stop, validate, validate_bluray_dir, validate_dvd_dir, jellyfin_item, values, Local +from ..helper import LazyLogger +from ..helper.utils import find_library +from ..helper.exceptions import PathValidationException from .obj import Objects from .kodi import TVShows as KodiDb, queries as QU diff --git a/jellyfin_kodi/objects/utils.py b/jellyfin_kodi/objects/utils.py index 56f5876a..31bbf7d1 100644 --- a/jellyfin_kodi/objects/utils.py +++ b/jellyfin_kodi/objects/utils.py @@ -3,8 +3,8 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################# -from helper import JSONRPC -from helper import LazyLogger +from ..helper import JSONRPC +from ..helper import LazyLogger ################################################################################################# diff --git a/jellyfin_kodi/player.py b/jellyfin_kodi/player.py index 86c8eb34..e8a92985 100644 --- a/jellyfin_kodi/player.py +++ b/jellyfin_kodi/player.py @@ -7,11 +7,11 @@ import os from kodi_six import xbmc, xbmcvfs -from objects.obj import Objects -from helper import translate, api, window, settings, dialog, event, JSONRPC -from jellyfin import Jellyfin -from helper import LazyLogger -from helper.utils import translate_path +from .objects.obj import Objects +from .helper import translate, api, window, settings, dialog, event, JSONRPC +from .jellyfin import Jellyfin +from .helper import LazyLogger +from .helper.utils import translate_path ################################################################################################# diff --git a/jellyfin_kodi/views.py b/jellyfin_kodi/views.py index 7d046565..6ee678b0 100644 --- a/jellyfin_kodi/views.py +++ b/jellyfin_kodi/views.py @@ -9,11 +9,11 @@ import xml.etree.ElementTree as etree from six.moves.urllib.parse import urlencode from kodi_six import xbmcvfs -from database import Database, jellyfin_db, get_sync, save_sync -from helper import translate, api, window, event -from jellyfin import Jellyfin -from helper import LazyLogger -from helper.utils import translate_path +from .database import Database, jellyfin_db, get_sync, save_sync +from .helper import translate, api, window, event +from .jellyfin import Jellyfin +from .helper import LazyLogger +from .helper.utils import translate_path ################################################################################################# diff --git a/service.py b/service.py index 2623a857..d725b37c 100644 --- a/service.py +++ b/service.py @@ -7,9 +7,9 @@ import threading from kodi_six import xbmc -from entrypoint import Service # noqa: E402 -from helper.utils import settings # noqa: E402 -from helper import LazyLogger # noqa: E402 +from jellyfin_kodi.entrypoint import Service +from jellyfin_kodi.helper.utils import settings +from jellyfin_kodi.helper import LazyLogger ################################################################################################# From 390c1d5de888d212f556372fc37581438689a34e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Mon, 11 Oct 2021 09:15:27 +0200 Subject: [PATCH 4/6] Fix tests --- jellyfin_kodi/dialogs/usersconnect.py | 5 +++-- jellyfin_kodi/entrypoint/__init__.py | 2 -- jellyfin_kodi/entrypoint/default.py | 4 ++-- jellyfin_kodi/helper/utils.py | 5 ++++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/jellyfin_kodi/dialogs/usersconnect.py b/jellyfin_kodi/dialogs/usersconnect.py index 69312da7..8c1428ef 100644 --- a/jellyfin_kodi/dialogs/usersconnect.py +++ b/jellyfin_kodi/dialogs/usersconnect.py @@ -4,9 +4,10 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################## from six import iteritems -from kodi_six import xbmc, xbmcgui +from kodi_six import xbmcgui from ..helper import LazyLogger +from ..helper.utils import kodi_version ################################################################################################## @@ -30,7 +31,7 @@ class UsersConnect(xbmcgui.WindowXMLDialog): def __init__(self, *args, **kwargs): - self.kodi_version = int(xbmc.getInfoLabel('System.BuildVersion')[:2]) + self.kodi_version = kodi_version() xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs) def set_args(self, **kwargs): diff --git a/jellyfin_kodi/entrypoint/__init__.py b/jellyfin_kodi/entrypoint/__init__.py index 8fbf2c8d..82e8ff62 100644 --- a/jellyfin_kodi/entrypoint/__init__.py +++ b/jellyfin_kodi/entrypoint/__init__.py @@ -3,8 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera ################################################################################################# -from kodi_six import xbmc, xbmcvfs - from ..helper import LazyLogger from ..jellyfin import Jellyfin diff --git a/jellyfin_kodi/entrypoint/default.py b/jellyfin_kodi/entrypoint/default.py index adc8009f..a80c2edd 100644 --- a/jellyfin_kodi/entrypoint/default.py +++ b/jellyfin_kodi/entrypoint/default.py @@ -15,7 +15,7 @@ from .. import client from ..database import reset, get_sync, Database, jellyfin_db, get_credentials from ..objects import Objects, Actions from ..helper import translate, event, settings, window, dialog, api, JSONRPC, LazyLogger -from ..helper.utils import JsonDebugPrinter, translate_path +from ..helper.utils import JsonDebugPrinter, translate_path, kodi_version from ..jellyfin import Jellyfin ################################################################################################# @@ -874,7 +874,7 @@ def backup(): from ..helper.utils import delete_folder, copytree path = settings('backupPath') - folder_name = "Kodi%s.%s" % (xbmc.getInfoLabel('System.BuildVersion')[:2], xbmc.getInfoLabel('System.Date(dd-mm-yy)')) + folder_name = "Kodi%s.%s" % (kodi_version(), xbmc.getInfoLabel('System.Date(dd-mm-yy)')) folder_name = dialog("input", heading=translate(33089), defaultt=folder_name) if not folder_name: diff --git a/jellyfin_kodi/helper/utils.py b/jellyfin_kodi/helper/utils.py index 4d248b55..f9ef3c34 100644 --- a/jellyfin_kodi/helper/utils.py +++ b/jellyfin_kodi/helper/utils.py @@ -34,7 +34,10 @@ def addon_id(): def kodi_version(): - return int(xbmc.getInfoLabel('System.BuildVersion').split('.')[0]) + # Kodistubs returns empty string, causing Python 3 tests to choke on int() + # TODO: Make Kodistubs version configurable for testing purposes + version_string = xbmc.getInfoLabel('System.BuildVersion') or "19.1 (19.1.0) Git:20210509-85e05228b4" + return int(version_string.split(' ', 1)[0].split('.', 1)[0]) def window(key, value=None, clear=False, window_id=10000): From 17455c108241429ca3d88e57c38dd213bb7b414b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Mon, 11 Oct 2021 09:15:55 +0200 Subject: [PATCH 5/6] Move typing stubs --- typings/{ => jellyfin_kodi}/database/jellyfin_db.pyi | 0 typings/jellyfin_kodi/helper/utils.pyi | 1 + 2 files changed, 1 insertion(+) rename typings/{ => jellyfin_kodi}/database/jellyfin_db.pyi (100%) create mode 100644 typings/jellyfin_kodi/helper/utils.pyi diff --git a/typings/database/jellyfin_db.pyi b/typings/jellyfin_kodi/database/jellyfin_db.pyi similarity index 100% rename from typings/database/jellyfin_db.pyi rename to typings/jellyfin_kodi/database/jellyfin_db.pyi diff --git a/typings/jellyfin_kodi/helper/utils.pyi b/typings/jellyfin_kodi/helper/utils.pyi new file mode 100644 index 00000000..3629bba0 --- /dev/null +++ b/typings/jellyfin_kodi/helper/utils.pyi @@ -0,0 +1 @@ +def kodi_version(self) -> int: ... From d5ec17d11184402c97394bfd3d80b235ea053a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Tue, 12 Oct 2021 18:08:32 +0200 Subject: [PATCH 6/6] Fix coverage source Python 2 version of coverage actually ignores the *.py lines in coverage Python 3 version recognizes them as files and tries to import them. --- tox.ini | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tox.ini b/tox.ini index a8463728..cd2729f9 100644 --- a/tox.ini +++ b/tox.ini @@ -13,12 +13,7 @@ testpaths = tests [coverage:run] -source = - jellyfin_kodi - context.py - context_play.py - default.py - service.py +source = . omit = tests/* build.py