From 0e80c7cbccd29b614d5ae7af11de4f0c1f1aa4f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Tue, 11 Jun 2024 02:56:52 +0000 Subject: [PATCH 01/11] Remove six.moves: range, queue --- jellyfin_kodi/downloader.py | 4 ++-- jellyfin_kodi/library.py | 46 ++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/jellyfin_kodi/downloader.py b/jellyfin_kodi/downloader.py index 899464981..147efece8 100644 --- a/jellyfin_kodi/downloader.py +++ b/jellyfin_kodi/downloader.py @@ -7,7 +7,7 @@ import concurrent.futures from datetime import date -from six.moves import range, queue as Queue +import queue import requests @@ -308,7 +308,7 @@ def run(self): while True: try: item_ids = self.queue.get(timeout=1) - except Queue.Empty: + except queue.Empty: self.is_done = True LOG.info("--<[ q:download/%s ]", id(self)) diff --git a/jellyfin_kodi/library.py b/jellyfin_kodi/library.py index a200f37de..5c1b5a90f 100644 --- a/jellyfin_kodi/library.py +++ b/jellyfin_kodi/library.py @@ -6,7 +6,7 @@ import threading from datetime import datetime, timedelta -from six.moves import queue as Queue +import queue from kodi_six import xbmc, xbmcgui @@ -48,13 +48,13 @@ def __init__(self, monitor): self.monitor = monitor self.player = monitor.monitor.player self.server = Jellyfin().get_client() - self.updated_queue = Queue.Queue() - self.userdata_queue = Queue.Queue() - self.removed_queue = Queue.Queue() + self.updated_queue = queue.Queue() + self.userdata_queue = queue.Queue() + self.removed_queue = queue.Queue() self.updated_output = self.__new_queues__() self.userdata_output = self.__new_queues__() self.removed_output = self.__new_queues__() - self.notify_output = Queue.Queue() + self.notify_output = queue.Queue() self.jellyfin_threads = [] self.download_threads = [] @@ -67,16 +67,16 @@ def __init__(self, monitor): def __new_queues__(self): return { - "Movie": Queue.Queue(), - "BoxSet": Queue.Queue(), - "MusicVideo": Queue.Queue(), - "Series": Queue.Queue(), - "Season": Queue.Queue(), - "Episode": Queue.Queue(), - "MusicAlbum": Queue.Queue(), - "MusicArtist": Queue.Queue(), - "AlbumArtist": Queue.Queue(), - "Audio": Queue.Queue(), + "Movie": queue.Queue(), + "BoxSet": queue.Queue(), + "MusicVideo": queue.Queue(), + "Series": queue.Queue(), + "Season": queue.Queue(), + "Episode": queue.Queue(), + "MusicAlbum": queue.Queue(), + "MusicArtist": queue.Queue(), + "AlbumArtist": queue.Queue(), + "Audio": queue.Queue(), } def run(self): @@ -271,13 +271,13 @@ def worker_queue_size(self): def worker_downloads(self): """Get items from jellyfin and place them in the appropriate queues.""" - for queue in ( + for work_queue in ( (self.updated_queue, self.updated_output), (self.userdata_queue, self.userdata_output), ): - if queue[0].qsize() and len(self.download_threads) < DTHREADS: + if work_queue[0].qsize() and len(self.download_threads) < DTHREADS: - new_thread = GetItemWorker(self.server, queue[0], queue[1]) + new_thread = GetItemWorker(self.server, work_queue[0], work_queue[1]) new_thread.start() LOG.info("-->[ q:download/%s ]", id(new_thread)) self.download_threads.append(new_thread) @@ -722,7 +722,7 @@ def run(self): try: item = self.queue.get(timeout=1) - except Queue.Empty: + except queue.Empty: break try: @@ -801,7 +801,7 @@ def run(self): try: item = self.queue.get(timeout=1) - except Queue.Empty: + except queue.Empty: break try: @@ -852,7 +852,7 @@ def run(self): try: item_id = self.queue.get(timeout=1) - except Queue.Empty: + except queue.Empty: break try: @@ -918,7 +918,7 @@ def run(self): try: item = self.queue.get(timeout=1) - except Queue.Empty: + except queue.Empty: break if item["Type"] == "Movie": @@ -970,7 +970,7 @@ def run(self): try: item = self.queue.get(timeout=3) - except Queue.Empty: + except queue.Empty: break time = self.music_time if item[0] == "Audio" else self.video_time From a00a1951cb6548e045260818cf675005afe1bc79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Tue, 11 Jun 2024 03:14:07 +0000 Subject: [PATCH 02/11] Remove six: iteritems --- jellyfin_kodi/dialogs/loginmanual.py | 3 +-- jellyfin_kodi/dialogs/serverconnect.py | 3 +-- jellyfin_kodi/dialogs/servermanual.py | 3 +-- jellyfin_kodi/dialogs/usersconnect.py | 3 +-- jellyfin_kodi/entrypoint/default.py | 3 +-- jellyfin_kodi/helper/utils.py | 5 +++-- jellyfin_kodi/objects/obj.py | 6 +++--- 7 files changed, 11 insertions(+), 15 deletions(-) diff --git a/jellyfin_kodi/dialogs/loginmanual.py b/jellyfin_kodi/dialogs/loginmanual.py index c63dd519f..d147cdade 100644 --- a/jellyfin_kodi/dialogs/loginmanual.py +++ b/jellyfin_kodi/dialogs/loginmanual.py @@ -3,7 +3,6 @@ ################################################################################################## -from six import iteritems from kodi_six import xbmcgui from ..helper import translate, LazyLogger, kodi_version @@ -34,7 +33,7 @@ def __init__(self, *args, **kwargs): def set_args(self, **kwargs): # connect_manager, user_image, servers - for key, value in iteritems(kwargs): + for key, value in kwargs.items(): setattr(self, key, value) def is_logged_in(self): diff --git a/jellyfin_kodi/dialogs/serverconnect.py b/jellyfin_kodi/dialogs/serverconnect.py index adeffbe5a..9030edb89 100644 --- a/jellyfin_kodi/dialogs/serverconnect.py +++ b/jellyfin_kodi/dialogs/serverconnect.py @@ -3,7 +3,6 @@ ################################################################################################## -from six import iteritems from kodi_six import xbmc, xbmcgui from ..helper import translate @@ -44,7 +43,7 @@ def __init__(self, *args, **kwargs): def set_args(self, **kwargs): # connect_manager, user_image, servers - for key, value in iteritems(kwargs): + for key, value in kwargs.items(): setattr(self, key, value) def is_server_selected(self): diff --git a/jellyfin_kodi/dialogs/servermanual.py b/jellyfin_kodi/dialogs/servermanual.py index 8f4b44bb9..138edb875 100644 --- a/jellyfin_kodi/dialogs/servermanual.py +++ b/jellyfin_kodi/dialogs/servermanual.py @@ -5,7 +5,6 @@ import re -from six import iteritems from kodi_six import xbmcgui from ..helper import translate @@ -41,7 +40,7 @@ def __init__(self, *args, **kwargs): def set_args(self, **kwargs): # connect_manager, user_image, servers, jellyfin_connect - for key, value in iteritems(kwargs): + for key, value in kwargs.items(): setattr(self, key, value) def is_connected(self): diff --git a/jellyfin_kodi/dialogs/usersconnect.py b/jellyfin_kodi/dialogs/usersconnect.py index 1abb8949c..b6a4af521 100644 --- a/jellyfin_kodi/dialogs/usersconnect.py +++ b/jellyfin_kodi/dialogs/usersconnect.py @@ -3,7 +3,6 @@ ################################################################################################## -from six import iteritems from kodi_six import xbmcgui from ..helper import LazyLogger @@ -36,7 +35,7 @@ def __init__(self, *args, **kwargs): def set_args(self, **kwargs): # connect_manager, user_image, servers - for key, value in iteritems(kwargs): + for key, value in kwargs.items(): setattr(self, key, value) def is_user_selected(self): diff --git a/jellyfin_kodi/entrypoint/default.py b/jellyfin_kodi/entrypoint/default.py index e91192044..26079504e 100644 --- a/jellyfin_kodi/entrypoint/default.py +++ b/jellyfin_kodi/entrypoint/default.py @@ -7,7 +7,6 @@ import sys import os -from six import iteritems from six.moves.urllib.parse import parse_qsl, urlencode from kodi_six import xbmc, xbmcvfs, xbmcgui, xbmcplugin, xbmcaddon @@ -1073,7 +1072,7 @@ def create_listitem(item): li.setProperty("dbid", str(item["episodeid"])) li.setProperty("fanart_image", item["art"].get("tvshow.fanart", "")) - for key, value in iteritems(item["streamdetails"]): + for key, value in item["streamdetails"].items(): for stream in value: li.addStreamInfo(key, stream) diff --git a/jellyfin_kodi/helper/utils.py b/jellyfin_kodi/helper/utils.py index fb651cf68..454109666 100644 --- a/jellyfin_kodi/helper/utils.py +++ b/jellyfin_kodi/helper/utils.py @@ -12,7 +12,7 @@ from uuid import uuid4 from dateutil import tz, parser -from six import text_type, string_types, iteritems, ensure_text, ensure_binary +from six import text_type, string_types, ensure_text, ensure_binary from six.moves.urllib.parse import quote_plus from kodi_six import xbmc, xbmcaddon, xbmcgui, xbmcvfs @@ -103,11 +103,12 @@ def create_id(): def find(dict, item): + # FIXME: dead code """Find value in dictionary.""" if item in dict: return dict[item] - for key, value in sorted(iteritems(dict), key=lambda kv: (kv[1], kv[0])): + for key, value in sorted(dict.items(), key=lambda kv: (kv[1], kv[0])): if re.match(key, item, re.I): return dict[key] diff --git a/jellyfin_kodi/objects/obj.py b/jellyfin_kodi/objects/obj.py index 7c89f3547..02b051069 100644 --- a/jellyfin_kodi/objects/obj.py +++ b/jellyfin_kodi/objects/obj.py @@ -6,7 +6,7 @@ import json import os -from six import iteritems, ensure_text +from six import ensure_text from ..helper import LazyLogger, get_filesystem_encoding @@ -54,7 +54,7 @@ def map(self, item, mapping_name): mapping = self.objects[mapping_name] - for key, value in iteritems(mapping): + for key, value in mapping.items(): self.mapped_item[key] = None params = value.split(",") @@ -151,7 +151,7 @@ def __filters__(self, obj, filters): result = False - for key, value in iteritems(filters): + for key, value in filters.items(): inverse = False From 76ac99fc61505d4f27fd1f03a3baaca773599a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Tue, 11 Jun 2024 03:19:25 +0000 Subject: [PATCH 03/11] Remove six.moves: urllib --- jellyfin_kodi/entrypoint/default.py | 2 +- jellyfin_kodi/helper/utils.py | 2 +- jellyfin_kodi/objects/movies.py | 3 ++- jellyfin_kodi/objects/musicvideos.py | 2 +- jellyfin_kodi/objects/tvshows.py | 2 +- jellyfin_kodi/views.py | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/jellyfin_kodi/entrypoint/default.py b/jellyfin_kodi/entrypoint/default.py index 26079504e..32ab68ebd 100644 --- a/jellyfin_kodi/entrypoint/default.py +++ b/jellyfin_kodi/entrypoint/default.py @@ -6,8 +6,8 @@ import json import sys import os +from urllib.parse import parse_qsl, urlencode -from six.moves.urllib.parse import parse_qsl, urlencode from kodi_six import xbmc, xbmcvfs, xbmcgui, xbmcplugin, xbmcaddon from .. import client diff --git a/jellyfin_kodi/helper/utils.py b/jellyfin_kodi/helper/utils.py index 454109666..eea2ae264 100644 --- a/jellyfin_kodi/helper/utils.py +++ b/jellyfin_kodi/helper/utils.py @@ -10,10 +10,10 @@ import re import unicodedata from uuid import uuid4 +from urllib.parse import quote_plus from dateutil import tz, parser from six import text_type, string_types, ensure_text, ensure_binary -from six.moves.urllib.parse import quote_plus from kodi_six import xbmc, xbmcaddon, xbmcgui, xbmcvfs diff --git a/jellyfin_kodi/objects/movies.py b/jellyfin_kodi/objects/movies.py index 44927b69c..58b960595 100644 --- a/jellyfin_kodi/objects/movies.py +++ b/jellyfin_kodi/objects/movies.py @@ -3,7 +3,8 @@ ################################################################################################## -from six.moves.urllib.parse import urlencode +from urllib.parse import urlencode + from kodi_six.utils import py2_encode from .. import downloader as server diff --git a/jellyfin_kodi/objects/musicvideos.py b/jellyfin_kodi/objects/musicvideos.py index c2d280e44..1157f75a6 100644 --- a/jellyfin_kodi/objects/musicvideos.py +++ b/jellyfin_kodi/objects/musicvideos.py @@ -5,8 +5,8 @@ import datetime import re +from urllib.parse import urlencode -from six.moves.urllib.parse import urlencode from kodi_six.utils import py2_encode from ..database import jellyfin_db, queries as QUEM diff --git a/jellyfin_kodi/objects/tvshows.py b/jellyfin_kodi/objects/tvshows.py index 09485509e..02016cf3f 100644 --- a/jellyfin_kodi/objects/tvshows.py +++ b/jellyfin_kodi/objects/tvshows.py @@ -5,8 +5,8 @@ import sqlite3 from ntpath import dirname +from urllib.parse import urlencode -from six.moves.urllib.parse import urlencode from kodi_six.utils import py2_encode from .. import downloader as server diff --git a/jellyfin_kodi/views.py b/jellyfin_kodi/views.py index 6a72a2b6d..d13cec4c8 100644 --- a/jellyfin_kodi/views.py +++ b/jellyfin_kodi/views.py @@ -5,8 +5,8 @@ import os import xml.etree.ElementTree as etree +from urllib.parse import urlencode -from six.moves.urllib.parse import urlencode from kodi_six import xbmcvfs from .database import Database, jellyfin_db, get_sync, save_sync From d96a907eab8a8ba6aad288e7b2b0265fbcc50ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Tue, 11 Jun 2024 03:24:27 +0000 Subject: [PATCH 04/11] Remove six.moves: collections_abc --- jellyfin_kodi/jellyfin/utils.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/jellyfin_kodi/jellyfin/utils.py b/jellyfin_kodi/jellyfin/utils.py index af5cab59e..05944e568 100644 --- a/jellyfin_kodi/jellyfin/utils.py +++ b/jellyfin_kodi/jellyfin/utils.py @@ -1,14 +1,14 @@ from collections import namedtuple +from collections.abc import Iterable, Mapping, MutableMapping from six import string_types -from six.moves import collections_abc def clean_none_dict_values(obj): """ Recursively remove keys with a value of None """ - if not isinstance(obj, collections_abc.Iterable) or isinstance(obj, string_types): + if not isinstance(obj, Iterable) or isinstance(obj, string_types): return obj queue = [obj] @@ -16,8 +16,8 @@ def clean_none_dict_values(obj): while queue: item = queue.pop() - if isinstance(item, collections_abc.Mapping): - mutable = isinstance(item, collections_abc.MutableMapping) + if isinstance(item, Mapping): + mutable = isinstance(item, MutableMapping) remove = [] for key, value in item.items(): @@ -27,7 +27,7 @@ def clean_none_dict_values(obj): elif isinstance(value, string_types): continue - elif isinstance(value, collections_abc.Iterable): + elif isinstance(value, Iterable): queue.append(value) if mutable: @@ -35,11 +35,11 @@ def clean_none_dict_values(obj): for key in remove: item.pop(key) - elif isinstance(item, collections_abc.Iterable): + elif isinstance(item, Iterable): for value in item: if value is None or isinstance(value, string_types): continue - elif isinstance(value, collections_abc.Iterable): + elif isinstance(value, Iterable): queue.append(value) return obj From 0e5c5e4c078b4e9a65f57f8008df1e105612c160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Tue, 11 Jun 2024 03:27:14 +0000 Subject: [PATCH 05/11] Remove six.moves: reload_module --- jellyfin_kodi/entrypoint/service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jellyfin_kodi/entrypoint/service.py b/jellyfin_kodi/entrypoint/service.py index aaf0d03d8..78019e5fc 100644 --- a/jellyfin_kodi/entrypoint/service.py +++ b/jellyfin_kodi/entrypoint/service.py @@ -6,11 +6,11 @@ import json import sys from datetime import datetime +from importlib import reload # Workaround for threads using datetime: _striptime is locked import _strptime # noqa:F401 from kodi_six import xbmc, xbmcgui -from six.moves import reload_module as reload from .. import objects from .. import connect From 57ed8bdedd659f7e591ae9bf5636fe5a988aefe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Tue, 11 Jun 2024 04:46:20 +0000 Subject: [PATCH 06/11] Remove six: string coercion --- jellyfin_kodi/database/__init__.py | 5 ++--- jellyfin_kodi/dialogs/context.py | 3 +-- jellyfin_kodi/helper/loghandler.py | 8 +------- jellyfin_kodi/helper/utils.py | 11 ++++------- jellyfin_kodi/jellyfin/api.py | 3 +-- jellyfin_kodi/jellyfin/http.py | 7 +++---- jellyfin_kodi/jellyfin/utils.py | 8 +++----- jellyfin_kodi/objects/obj.py | 6 ++---- 8 files changed, 17 insertions(+), 34 deletions(-) diff --git a/jellyfin_kodi/database/__init__.py b/jellyfin_kodi/database/__init__.py index b92ff1892..c55cd6dac 100644 --- a/jellyfin_kodi/database/__init__.py +++ b/jellyfin_kodi/database/__init__.py @@ -11,7 +11,6 @@ import re from kodi_six import xbmc, xbmcvfs -from six import text_type from . import jellyfin_db from ..helper import translate, settings, window, dialog @@ -362,7 +361,7 @@ def save_sync(sync): with open(os.path.join(ADDON_DATA, "sync.json"), "wb") as outfile: data = json.dumps(sync, sort_keys=True, indent=4, ensure_ascii=False) - if isinstance(data, text_type): + if isinstance(data, str): data = data.encode("utf-8") outfile.write(data) @@ -411,7 +410,7 @@ def save_credentials(credentials): try: with open(os.path.join(ADDON_DATA, "data.json"), "wb") as outfile: data = json.dumps(credentials, sort_keys=True, indent=4, ensure_ascii=False) - if isinstance(data, text_type): + if isinstance(data, str): data = data.encode("utf-8") outfile.write(data) except Exception: diff --git a/jellyfin_kodi/dialogs/context.py b/jellyfin_kodi/dialogs/context.py index 8e8eb5db2..a0d4c6c25 100644 --- a/jellyfin_kodi/dialogs/context.py +++ b/jellyfin_kodi/dialogs/context.py @@ -6,7 +6,6 @@ import os from kodi_six import xbmcgui, xbmcaddon -from six import ensure_text from ..helper import window, addon_id from ..helper import LazyLogger @@ -69,7 +68,7 @@ def onAction(self, action): ): option = self.list_.getSelectedItem() - self.selected_option = ensure_text(option.getLabel()) + self.selected_option = option.getLabel() LOG.info("option selected: %s", self.selected_option) self.close() diff --git a/jellyfin_kodi/helper/loghandler.py b/jellyfin_kodi/helper/loghandler.py index 9d234324b..e4181ad1b 100644 --- a/jellyfin_kodi/helper/loghandler.py +++ b/jellyfin_kodi/helper/loghandler.py @@ -7,11 +7,10 @@ import logging import traceback -from six import ensure_text from kodi_six import xbmc, xbmcaddon from .. import database -from . import get_filesystem_encoding, settings, kodi_version +from . import settings, kodi_version from .utils import translate_path ################################################################################################## @@ -92,9 +91,6 @@ def __init__( logging.Formatter.__init__(self, fmt) def format(self, record): - if record.pathname: - record.pathname = ensure_text(record.pathname, get_filesystem_encoding()) - self._gen_rel_path(record) # Call the original formatter class to do the grunt work @@ -107,8 +103,6 @@ def formatException(self, exc_info): res = [] for o in traceback.format_exception(*exc_info): - o = ensure_text(o, get_filesystem_encoding()) - if o.startswith(' File "'): # If this split can't handle your file names, you should seriously consider renaming your files. fn = o.split(' File "', 2)[1].split('", line ', 1)[0] diff --git a/jellyfin_kodi/helper/utils.py b/jellyfin_kodi/helper/utils.py index eea2ae264..e6e1be3eb 100644 --- a/jellyfin_kodi/helper/utils.py +++ b/jellyfin_kodi/helper/utils.py @@ -13,7 +13,6 @@ from urllib.parse import quote_plus from dateutil import tz, parser -from six import text_type, string_types, ensure_text, ensure_binary from kodi_six import xbmc, xbmcaddon, xbmcgui, xbmcvfs @@ -120,7 +119,7 @@ def event(method, data=None, sender=None, hexlify=False): sender = sender or "plugin.video.jellyfin" if hexlify: - data = ensure_text(binascii.hexlify(ensure_binary(json.dumps(data)))) + data = str(binascii.hexlify(json.dumps(data).encode())) data = '"[%s]"' % json.dumps(data).replace('"', '\\"') @@ -273,7 +272,7 @@ def values(item, keys): return ( ( item[key.replace("{", "").replace("}", "")] - if isinstance(key, text_type) and key.startswith("{") + if isinstance(key, str) and key.startswith("{") else key ) for key in keys @@ -423,9 +422,7 @@ def normalize_string(text): text = text.strip() text = text.rstrip(".") - text = unicodedata.normalize("NFKD", text_type(text, "utf-8")).encode( - "ascii", "ignore" - ) + text = unicodedata.normalize("NFKD", str(text, "utf-8")).encode("ascii", "ignore") return text @@ -438,7 +435,7 @@ def split_list(itemlist, size): def convert_to_local(date, timezone=tz.tzlocal()): """Convert the local datetime to local.""" try: - date = parser.parse(date) if isinstance(date, string_types) else date + date = parser.parse(date) if isinstance(date, str) else date date = date.replace(tzinfo=tz.tzutc()) date = date.astimezone(timezone) # Bad metadata defaults to date 1-1-1. Catch it and don't throw errors diff --git a/jellyfin_kodi/jellyfin/api.py b/jellyfin_kodi/jellyfin/api.py index 4ec7ce312..1c2bb02fc 100644 --- a/jellyfin_kodi/jellyfin/api.py +++ b/jellyfin_kodi/jellyfin/api.py @@ -4,7 +4,6 @@ import json import requests -from six import ensure_str from ..helper.exceptions import HTTPException from ..helper.utils import settings @@ -416,7 +415,7 @@ def get_default_headers(self): "User-Agent": self.config.data["http.user_agent"] or "%s/%s" % (self.config.data["app.name"], self.config.data["app.version"]), - "x-emby-authorization": ensure_str(auth, "utf-8"), + "x-emby-authorization": auth, } def send_request( diff --git a/jellyfin_kodi/jellyfin/http.py b/jellyfin_kodi/jellyfin/http.py index 0c3282137..a58ad9616 100644 --- a/jellyfin_kodi/jellyfin/http.py +++ b/jellyfin_kodi/jellyfin/http.py @@ -6,7 +6,6 @@ import time import requests -from six import string_types, ensure_str from ..helper.utils import JsonDebugPrinter from ..helper import LazyLogger @@ -218,7 +217,7 @@ def _process_params(self, params): if isinstance(value, dict): self._process_params(value) - if isinstance(value, string_types): + if isinstance(value, str): params[key] = self._replace_user_info(value) def _get_header(self, data): @@ -257,14 +256,14 @@ def _authorization(self, data): ) auth += "Version=%s" % self.config.data.get("app.version", "0.0.0") - data["headers"].update({"x-emby-authorization": ensure_str(auth, "utf-8")}) + data["headers"].update({"x-emby-authorization": auth}) if self.config.data.get("auth.token") and self.config.data.get("auth.user_id"): auth += ", UserId=%s" % self.config.data.get("auth.user_id") data["headers"].update( { - "x-emby-authorization": ensure_str(auth, "utf-8"), + "x-emby-authorization": auth, "X-MediaBrowser-Token": self.config.data.get("auth.token"), } ) diff --git a/jellyfin_kodi/jellyfin/utils.py b/jellyfin_kodi/jellyfin/utils.py index 05944e568..036859811 100644 --- a/jellyfin_kodi/jellyfin/utils.py +++ b/jellyfin_kodi/jellyfin/utils.py @@ -1,14 +1,12 @@ from collections import namedtuple from collections.abc import Iterable, Mapping, MutableMapping -from six import string_types - def clean_none_dict_values(obj): """ Recursively remove keys with a value of None """ - if not isinstance(obj, Iterable) or isinstance(obj, string_types): + if not isinstance(obj, Iterable) or isinstance(obj, str): return obj queue = [obj] @@ -24,7 +22,7 @@ def clean_none_dict_values(obj): if value is None and mutable: remove.append(key) - elif isinstance(value, string_types): + elif isinstance(value, str): continue elif isinstance(value, Iterable): @@ -37,7 +35,7 @@ def clean_none_dict_values(obj): elif isinstance(item, Iterable): for value in item: - if value is None or isinstance(value, string_types): + if value is None or isinstance(value, str): continue elif isinstance(value, Iterable): queue.append(value) diff --git a/jellyfin_kodi/objects/obj.py b/jellyfin_kodi/objects/obj.py index 02b051069..958388cd6 100644 --- a/jellyfin_kodi/objects/obj.py +++ b/jellyfin_kodi/objects/obj.py @@ -6,9 +6,7 @@ import json import os -from six import ensure_text - -from ..helper import LazyLogger, get_filesystem_encoding +from ..helper import LazyLogger ################################################################################################## @@ -29,7 +27,7 @@ def __init__(self): def mapping(self): """Load objects mapping.""" - file_dir = os.path.dirname(ensure_text(__file__, get_filesystem_encoding())) + file_dir = os.path.dirname(__file__) with open(os.path.join(file_dir, "obj_map.json")) as infile: self.objects = json.load(infile) From 8cabd4e2a3dbd059fe83d59a5adbd3a8915e5487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Tue, 11 Jun 2024 04:54:39 +0000 Subject: [PATCH 07/11] Remove six from dependencies --- .pre-commit-config.yaml | 1 - release.yaml | 2 -- requirements-dev.txt | 2 -- 3 files changed, 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ecb3d46e0..468029fd3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,7 +37,6 @@ repos: # - pytest # - types-requests >= 2.31 # - types-PyYAML >= 6.0 - # - types-six >= 1.13 # - types-python-dateutil >= 2.8.1 # - types-setuptools >= 44.1.1 # - types-Pygments diff --git a/release.yaml b/release.yaml index d5ba20076..f6bcd6fbc 100644 --- a/release.yaml +++ b/release.yaml @@ -11,8 +11,6 @@ dependencies: version: '2.22.0+matrix.1' - addon: 'script.module.dateutil' version: '2.8.1+matrix.1' - - addon: 'script.module.six' - version: '1.14.0+matrix.2' - addon: 'script.module.kodi-six' version: '0.1.3+1' - addon: 'script.module.addon.signals' diff --git a/requirements-dev.txt b/requirements-dev.txt index 889770b27..6c345d2b2 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,4 @@ setuptools >= 44.1.1 # Old setuptools causes script.module.addon.signals to fail installing -six >= 1.13 python-dateutil >= 2.8.1 requests >= 2.22 PyYAML >= 6.0 @@ -21,7 +20,6 @@ websocket-client >= 1.6.4 types-requests >= 2.31 types-PyYAML >= 6.0 -types-six >= 1.13 types-python-dateutil >= 2.8.1 types-setuptools >= 44.1.1 From cd53329fb9832d4cd942ba07f77814c48f1b5bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Tue, 11 Jun 2024 05:10:57 +0000 Subject: [PATCH 08/11] Remove kodi_six: import directly --- jellyfin_kodi/client.py | 4 +++- jellyfin_kodi/connect.py | 3 ++- jellyfin_kodi/database/__init__.py | 3 ++- jellyfin_kodi/dialogs/context.py | 3 ++- jellyfin_kodi/dialogs/loginmanual.py | 2 +- jellyfin_kodi/dialogs/resume.py | 3 ++- jellyfin_kodi/dialogs/serverconnect.py | 3 ++- jellyfin_kodi/dialogs/servermanual.py | 2 +- jellyfin_kodi/dialogs/usersconnect.py | 2 +- jellyfin_kodi/entrypoint/context.py | 3 ++- jellyfin_kodi/entrypoint/default.py | 6 +++++- jellyfin_kodi/entrypoint/service.py | 3 ++- jellyfin_kodi/full_sync.py | 2 +- jellyfin_kodi/helper/loghandler.py | 3 ++- jellyfin_kodi/helper/playutils.py | 3 ++- jellyfin_kodi/helper/translate.py | 3 ++- jellyfin_kodi/helper/utils.py | 5 ++++- jellyfin_kodi/helper/wrapper.py | 2 +- jellyfin_kodi/helper/xmls.py | 3 ++- jellyfin_kodi/jellyfin/ws_client.py | 2 +- jellyfin_kodi/library.py | 3 ++- jellyfin_kodi/monitor.py | 2 +- jellyfin_kodi/objects/actions.py | 5 ++++- jellyfin_kodi/player.py | 3 ++- jellyfin_kodi/views.py | 2 +- service.py | 2 +- 26 files changed, 51 insertions(+), 26 deletions(-) diff --git a/jellyfin_kodi/client.py b/jellyfin_kodi/client.py index e38e52f7c..cf8c3315a 100644 --- a/jellyfin_kodi/client.py +++ b/jellyfin_kodi/client.py @@ -5,7 +5,9 @@ import os -from kodi_six import xbmc, xbmcaddon, xbmcvfs +import xbmc +import xbmcaddon +import xbmcvfs 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 8a3f2b1db..6dac14502 100644 --- a/jellyfin_kodi/connect.py +++ b/jellyfin_kodi/connect.py @@ -3,7 +3,8 @@ ################################################################################################## -from kodi_six import xbmc, xbmcaddon +import xbmc +import xbmcaddon from . import client from .database import get_credentials, save_credentials diff --git a/jellyfin_kodi/database/__init__.py b/jellyfin_kodi/database/__init__.py index c55cd6dac..d90f9607c 100644 --- a/jellyfin_kodi/database/__init__.py +++ b/jellyfin_kodi/database/__init__.py @@ -10,7 +10,8 @@ import sys import re -from kodi_six import xbmc, xbmcvfs +import xbmc +import xbmcvfs from . import jellyfin_db from ..helper import translate, settings, window, dialog diff --git a/jellyfin_kodi/dialogs/context.py b/jellyfin_kodi/dialogs/context.py index a0d4c6c25..53ae909d9 100644 --- a/jellyfin_kodi/dialogs/context.py +++ b/jellyfin_kodi/dialogs/context.py @@ -5,7 +5,8 @@ import os -from kodi_six import xbmcgui, xbmcaddon +import xbmcgui +import xbmcaddon 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 d147cdade..61c89492c 100644 --- a/jellyfin_kodi/dialogs/loginmanual.py +++ b/jellyfin_kodi/dialogs/loginmanual.py @@ -3,7 +3,7 @@ ################################################################################################## -from kodi_six import xbmcgui +import xbmcgui from ..helper import translate, LazyLogger, kodi_version diff --git a/jellyfin_kodi/dialogs/resume.py b/jellyfin_kodi/dialogs/resume.py index 0357a413f..9f2cf3ed5 100644 --- a/jellyfin_kodi/dialogs/resume.py +++ b/jellyfin_kodi/dialogs/resume.py @@ -3,7 +3,8 @@ ################################################################################################## -from kodi_six import xbmc, xbmcgui +import xbmc +import xbmcgui from ..helper import LazyLogger diff --git a/jellyfin_kodi/dialogs/serverconnect.py b/jellyfin_kodi/dialogs/serverconnect.py index 9030edb89..b20b161f6 100644 --- a/jellyfin_kodi/dialogs/serverconnect.py +++ b/jellyfin_kodi/dialogs/serverconnect.py @@ -3,7 +3,8 @@ ################################################################################################## -from kodi_six import xbmc, xbmcgui +import xbmc +import xbmcgui from ..helper import translate from ..jellyfin.connection_manager import CONNECTION_STATE diff --git a/jellyfin_kodi/dialogs/servermanual.py b/jellyfin_kodi/dialogs/servermanual.py index 138edb875..eaaabc884 100644 --- a/jellyfin_kodi/dialogs/servermanual.py +++ b/jellyfin_kodi/dialogs/servermanual.py @@ -5,7 +5,7 @@ import re -from kodi_six import xbmcgui +import xbmcgui from ..helper import translate from ..jellyfin.connection_manager import CONNECTION_STATE diff --git a/jellyfin_kodi/dialogs/usersconnect.py b/jellyfin_kodi/dialogs/usersconnect.py index b6a4af521..6df02d711 100644 --- a/jellyfin_kodi/dialogs/usersconnect.py +++ b/jellyfin_kodi/dialogs/usersconnect.py @@ -3,7 +3,7 @@ ################################################################################################## -from kodi_six import xbmcgui +import xbmcgui from ..helper import LazyLogger from ..helper.utils import kodi_version diff --git a/jellyfin_kodi/entrypoint/context.py b/jellyfin_kodi/entrypoint/context.py index e5d383b8c..572fd7e03 100644 --- a/jellyfin_kodi/entrypoint/context.py +++ b/jellyfin_kodi/entrypoint/context.py @@ -6,7 +6,8 @@ import json import sys -from kodi_six import xbmc, xbmcaddon +import xbmc +import xbmcaddon from .. import database from ..dialogs import context diff --git a/jellyfin_kodi/entrypoint/default.py b/jellyfin_kodi/entrypoint/default.py index 32ab68ebd..e2868bb3d 100644 --- a/jellyfin_kodi/entrypoint/default.py +++ b/jellyfin_kodi/entrypoint/default.py @@ -8,7 +8,11 @@ import os from urllib.parse import parse_qsl, urlencode -from kodi_six import xbmc, xbmcvfs, xbmcgui, xbmcplugin, xbmcaddon +import xbmc +import xbmcvfs +import xbmcgui +import xbmcplugin +import xbmcaddon from .. import client from ..database import reset, get_sync, Database, jellyfin_db, get_credentials diff --git a/jellyfin_kodi/entrypoint/service.py b/jellyfin_kodi/entrypoint/service.py index 78019e5fc..e267571d9 100644 --- a/jellyfin_kodi/entrypoint/service.py +++ b/jellyfin_kodi/entrypoint/service.py @@ -10,7 +10,8 @@ # Workaround for threads using datetime: _striptime is locked import _strptime # noqa:F401 -from kodi_six import xbmc, xbmcgui +import xbmc +import xbmcgui from .. import objects from .. import connect diff --git a/jellyfin_kodi/full_sync.py b/jellyfin_kodi/full_sync.py index 6143e960a..36453ada5 100644 --- a/jellyfin_kodi/full_sync.py +++ b/jellyfin_kodi/full_sync.py @@ -6,7 +6,7 @@ from contextlib import contextmanager import datetime -from kodi_six import xbmc +import xbmc from . import downloader as server from .objects import Movies, TVShows, MusicVideos, Music diff --git a/jellyfin_kodi/helper/loghandler.py b/jellyfin_kodi/helper/loghandler.py index e4181ad1b..9e57f103e 100644 --- a/jellyfin_kodi/helper/loghandler.py +++ b/jellyfin_kodi/helper/loghandler.py @@ -7,7 +7,8 @@ import logging import traceback -from kodi_six import xbmc, xbmcaddon +import xbmc +import xbmcaddon from .. import database from . import settings, kodi_version diff --git a/jellyfin_kodi/helper/playutils.py b/jellyfin_kodi/helper/playutils.py index baec4b56e..614f79f0e 100644 --- a/jellyfin_kodi/helper/playutils.py +++ b/jellyfin_kodi/helper/playutils.py @@ -7,7 +7,8 @@ from uuid import uuid4 import requests -from kodi_six import xbmc, xbmcvfs +import xbmc +import xbmcvfs from .. import client from .utils import translate_path diff --git a/jellyfin_kodi/helper/translate.py b/jellyfin_kodi/helper/translate.py index 6844fe7c6..cd6dd037d 100644 --- a/jellyfin_kodi/helper/translate.py +++ b/jellyfin_kodi/helper/translate.py @@ -3,7 +3,8 @@ ################################################################################################## -from kodi_six import xbmc, xbmcaddon +import xbmc +import xbmcaddon from . import LazyLogger diff --git a/jellyfin_kodi/helper/utils.py b/jellyfin_kodi/helper/utils.py index e6e1be3eb..c7c31567a 100644 --- a/jellyfin_kodi/helper/utils.py +++ b/jellyfin_kodi/helper/utils.py @@ -14,7 +14,10 @@ from dateutil import tz, parser -from kodi_six import xbmc, xbmcaddon, xbmcgui, xbmcvfs +import xbmc +import xbmcaddon +import xbmcgui +import xbmcvfs from . import LazyLogger from .translate import translate diff --git a/jellyfin_kodi/helper/wrapper.py b/jellyfin_kodi/helper/wrapper.py index 73f19982d..b1cb41991 100644 --- a/jellyfin_kodi/helper/wrapper.py +++ b/jellyfin_kodi/helper/wrapper.py @@ -3,7 +3,7 @@ ################################################################################################# -from kodi_six import xbmcgui +import xbmcgui from . import LazyLogger diff --git a/jellyfin_kodi/helper/xmls.py b/jellyfin_kodi/helper/xmls.py index fdf9e3a9f..9c3fbb5fa 100644 --- a/jellyfin_kodi/helper/xmls.py +++ b/jellyfin_kodi/helper/xmls.py @@ -6,7 +6,8 @@ import os import xml.etree.ElementTree as etree -from kodi_six import xbmc, xbmcvfs +import xbmc +import xbmcvfs from .utils import translate_path from . import translate, dialog, settings, LazyLogger diff --git a/jellyfin_kodi/jellyfin/ws_client.py b/jellyfin_kodi/jellyfin/ws_client.py index 38a17f8b4..4c0d91bb7 100644 --- a/jellyfin_kodi/jellyfin/ws_client.py +++ b/jellyfin_kodi/jellyfin/ws_client.py @@ -7,7 +7,7 @@ import threading import time -from kodi_six import xbmc +import xbmc from ..helper import LazyLogger, settings diff --git a/jellyfin_kodi/library.py b/jellyfin_kodi/library.py index 5c1b5a90f..452429761 100644 --- a/jellyfin_kodi/library.py +++ b/jellyfin_kodi/library.py @@ -8,7 +8,8 @@ import queue -from kodi_six import xbmc, xbmcgui +import xbmc +import xbmcgui from .objects import Movies, TVShows, MusicVideos, Music from .objects.kodi import Movies as KodiDb diff --git a/jellyfin_kodi/monitor.py b/jellyfin_kodi/monitor.py index 4f02226bb..1123a5c88 100644 --- a/jellyfin_kodi/monitor.py +++ b/jellyfin_kodi/monitor.py @@ -7,7 +7,7 @@ import json import threading -from kodi_six import xbmc +import xbmc from . import connect from . import player diff --git a/jellyfin_kodi/objects/actions.py b/jellyfin_kodi/objects/actions.py index 4711e1e11..7b91038e7 100644 --- a/jellyfin_kodi/objects/actions.py +++ b/jellyfin_kodi/objects/actions.py @@ -8,7 +8,10 @@ import json from datetime import timedelta -from kodi_six import xbmc, xbmcgui, xbmcplugin, xbmcaddon +import xbmc +import xbmcgui +import xbmcplugin +import xbmcaddon from ..helper import translate, playutils, api, window, settings, dialog from ..dialogs import resume diff --git a/jellyfin_kodi/player.py b/jellyfin_kodi/player.py index ac7092082..a71122bf3 100644 --- a/jellyfin_kodi/player.py +++ b/jellyfin_kodi/player.py @@ -5,7 +5,8 @@ import os -from kodi_six import xbmc, xbmcvfs +import xbmc +import xbmcvfs from .objects.obj import Objects from .helper import translate, api, window, settings, dialog, event, JSONRPC diff --git a/jellyfin_kodi/views.py b/jellyfin_kodi/views.py index d13cec4c8..310be87f6 100644 --- a/jellyfin_kodi/views.py +++ b/jellyfin_kodi/views.py @@ -7,7 +7,7 @@ import xml.etree.ElementTree as etree from urllib.parse import urlencode -from kodi_six import xbmcvfs +import xbmcvfs from .database import Database, jellyfin_db, get_sync, save_sync from .helper import translate, api, window, event diff --git a/service.py b/service.py index c19472d5b..a28e27aa4 100644 --- a/service.py +++ b/service.py @@ -5,7 +5,7 @@ import threading -from kodi_six import xbmc +import xbmc from jellyfin_kodi.entrypoint.service import Service from jellyfin_kodi.helper.utils import settings From 794f9c8b85def2ecb50056c901f926dc771a4c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Tue, 11 Jun 2024 05:11:56 +0000 Subject: [PATCH 09/11] Remove kodi_six: py2_encode --- jellyfin_kodi/objects/movies.py | 4 +--- jellyfin_kodi/objects/musicvideos.py | 4 +--- jellyfin_kodi/objects/tvshows.py | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/jellyfin_kodi/objects/movies.py b/jellyfin_kodi/objects/movies.py index 58b960595..cc180338b 100644 --- a/jellyfin_kodi/objects/movies.py +++ b/jellyfin_kodi/objects/movies.py @@ -5,8 +5,6 @@ from urllib.parse import urlencode -from kodi_six.utils import py2_encode - from .. import downloader as server from ..database import jellyfin_db, queries as QUEM from ..helper import ( @@ -241,7 +239,7 @@ def get_path_filename(self, obj): else: obj["Path"] = "plugin://plugin.video.jellyfin/%s/" % obj["LibraryId"] params = { - "filename": py2_encode(obj["Filename"], "utf-8"), + "filename": obj["Filename"], "id": obj["Id"], "dbid": obj["MovieId"], "mode": "play", diff --git a/jellyfin_kodi/objects/musicvideos.py b/jellyfin_kodi/objects/musicvideos.py index 1157f75a6..22632d3d1 100644 --- a/jellyfin_kodi/objects/musicvideos.py +++ b/jellyfin_kodi/objects/musicvideos.py @@ -7,8 +7,6 @@ import re from 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, LazyLogger from ..helper.utils import find_library @@ -210,7 +208,7 @@ def get_path_filename(self, obj): else: obj["Path"] = "plugin://plugin.video.jellyfin/%s/" % obj["LibraryId"] params = { - "filename": py2_encode(obj["Filename"], "utf-8"), + "filename": obj["Filename"], "id": obj["Id"], "dbid": obj["MvideoId"], "mode": "play", diff --git a/jellyfin_kodi/objects/tvshows.py b/jellyfin_kodi/objects/tvshows.py index 02016cf3f..ee6dbd7c3 100644 --- a/jellyfin_kodi/objects/tvshows.py +++ b/jellyfin_kodi/objects/tvshows.py @@ -7,8 +7,6 @@ from ntpath import dirname from urllib.parse import urlencode -from kodi_six.utils import py2_encode - from .. import downloader as server from ..database import jellyfin_db, queries as QUEM from ..helper import ( @@ -535,7 +533,7 @@ def get_episode_path_filename(self, obj): obj["SeriesId"], ) params = { - "filename": py2_encode(obj["Filename"], "utf-8"), + "filename": obj["Filename"], "id": obj["Id"], "dbid": obj["EpisodeId"], "mode": "play", From cc0cabf38a683d3bc7802ec9775fe4708ed7bafd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Tue, 11 Jun 2024 05:13:33 +0000 Subject: [PATCH 10/11] Remove kodi_six from dependencies --- release.yaml | 2 -- requirements-dev.txt | 1 - 2 files changed, 3 deletions(-) diff --git a/release.yaml b/release.yaml index f6bcd6fbc..31862dbd4 100644 --- a/release.yaml +++ b/release.yaml @@ -11,8 +11,6 @@ dependencies: version: '2.22.0+matrix.1' - addon: 'script.module.dateutil' version: '2.8.1+matrix.1' - - addon: 'script.module.kodi-six' - version: '0.1.3+1' - addon: 'script.module.addon.signals' version: '0.0.5+matrix.1' - addon: 'script.module.websocket' diff --git a/requirements-dev.txt b/requirements-dev.txt index 6c345d2b2..af40f310f 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,7 +8,6 @@ tzdata; platform_system == "Windows" Kodistubs ~=21.0 -git+https://github.com/romanvm/kodi.six git+https://github.com/ruuk/script.module.addon.signals pre-commit >= 3.7.1 From 876e940283825ea348162637852fb3a4aff16ab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Tue, 11 Jun 2024 05:46:17 +0000 Subject: [PATCH 11/11] Fix normalize_string --- jellyfin_kodi/helper/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jellyfin_kodi/helper/utils.py b/jellyfin_kodi/helper/utils.py index c7c31567a..3e2b58cd1 100644 --- a/jellyfin_kodi/helper/utils.py +++ b/jellyfin_kodi/helper/utils.py @@ -425,7 +425,7 @@ def normalize_string(text): text = text.strip() text = text.rstrip(".") - text = unicodedata.normalize("NFKD", str(text, "utf-8")).encode("ascii", "ignore") + text = unicodedata.normalize("NFKD", text).encode("ascii", "ignore") return text