Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.module.srgssr" name="SRG SSR" version="1.7.0" provider-name="Alexander Seiler">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
<import addon="script.module.simplecache" version="1.0.0"/>
<import addon="script.module.requests" version="2.19.1"/>
<import addon="script.module.youtube_channels" version="0.1.0"/>
<import addon="script.module.kodi-six" version="0.0.2"/>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.simplecache" version="2.0.2"/>
<import addon="script.module.requests" version="2.22.0"/>
<import addon="script.module.youtube_channels" version="0.2.0"/>
</requires>
<extension point="xbmc.python.module" library="lib"/>
<extension point="xbmc.addon.metadata">
Expand Down
30 changes: 11 additions & 19 deletions lib/srgssr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 4 additions & 18 deletions lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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<hour>\d+):)?(?P<minute>\d+):)?(?P<second>\d+)'
match = re.match(durrex, duration_string)
Expand Down Expand Up @@ -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