diff --git a/addon.xml b/addon.xml index 906e7fc..e94213f 100644 --- a/addon.xml +++ b/addon.xml @@ -1,11 +1,10 @@ - - - - - + + + + diff --git a/lib/srgssr.py b/lib/srgssr.py index 6596589..78964d4 100644 --- a/lib/srgssr.py +++ b/lib/srgssr.py @@ -28,16 +28,16 @@ import json import requests -try: # Python 3 - from urllib.parse import quote_plus, parse_qsl, ParseResult - from urllib.parse import urlparse as urlps -except ImportError: # Python 2 - from urllib import quote_plus - from urlparse import parse_qsl, ParseResult - from urlparse import urlparse as urlps - -from kodi_six import xbmc, xbmcgui, xbmcplugin, xbmcaddon, xbmcvfs -from simplecache import SimpleCache +from urllib.parse import quote_plus, parse_qsl, ParseResult +from urllib.parse import urlparse as urlps + +import xbmc +import xbmcgui +import xbmcplugin +import xbmcaddon +import xbmcvfs + +import simplecache import utils import youtube_channels @@ -78,7 +78,7 @@ class SRGSSR(object): """ def __init__(self, plugin_handle, bu='srf', addon_id=ADDON_ID): self.handle = plugin_handle - self.cache = SimpleCache() + self.cache = simplecache.SimpleCache() self.real_settings = xbmcaddon.Addon(id=addon_id) self.bu = bu self.addon_id = addon_id @@ -1307,8 +1307,6 @@ def build_search_media_menu(self, mode=28, name='', page=1, else: # `name` is provided by previously performed search, so it # needs to be processed first - if utils.is_python_2(): - query_string = query_string.encode('utf8') query_string = quote_plus(query_string) query_url = url_layout % ( name, self.number_of_episodes, media_type) @@ -1319,8 +1317,6 @@ def build_search_media_menu(self, mode=28, name='', page=1, if not query_string: self.log('build_search_media_menu: No input provided') return - if utils.is_python_2(): - query_string = query_string.encode('utf8') if True: self.write_search(RECENT_MEDIA_SEARCHES_FILENAME, query_string) query_string = quote_plus(query_string) @@ -1372,16 +1368,12 @@ def build_search_show_menu(self, name='', audio=False): url_layout = self.host_url + '/play/search/shows?searchQuery=%s' if name: query_string = name - if utils.is_python_2(): - query_string = query_string.encode('utf8') else: dialog = xbmcgui.Dialog() query_string = dialog.input(LANGUAGE(30115)) if not query_string: self.log('build_search_show_menu: No input provided') return - if utils.is_python_2(): - query_string = query_string.encode('utf8') if True: self.write_search(RECENT_SHOW_SEARCHES_FILENAME, query_string) query_string = quote_plus(query_string) diff --git a/lib/utils.py b/lib/utils.py index 77b1c32..6ea4447 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -23,13 +23,7 @@ import re import sys -try: - CompatStr = unicode # Python2 -except NameError: - CompatStr = str # Python3 - - -def try_get(dictionary, keys, data_type=CompatStr, default=''): +def try_get(dictionary, keys, data_type=str, default=''): """ Accesses a nested dictionary in a save way. @@ -39,7 +33,7 @@ def try_get(dictionary, keys, data_type=CompatStr, default=''): accessed, or a string/int if only one key should be accessed data_type -- the expected data type of the final element - (default: CompatStr) + (default: str) default -- a default value to return (default: '') """ d = dictionary @@ -82,7 +76,7 @@ def str_or_none(inp, default=None): if inp is None: return default try: - return CompatStr(inp, 'utf-8') + return str(inp, 'utf-8') except TypeError: return inp @@ -102,7 +96,7 @@ def get_duration(duration_string): Keyword arguments: duration_string -- a string of the above Form. """ - if not isinstance(duration_string, CompatStr): + if not isinstance(duration_string, str): return None durrex = r'(((?P\d+):)?(?P\d+):)?(?P\d+)' match = re.match(durrex, duration_string) @@ -373,11 +367,3 @@ def generate_unique_list(input, unique_key): unique_keys.append(elem[unique_key]) output.append(elem) return output - - -def is_python_2(): - """ - Returns true if the major version number of the systems Python - is less than 2, otherwise false. - """ - return sys.version_info[0] < 3