diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..2ab758e --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +ADDON_USERNAME= +ADDON_PASSWORD= + +KODI_HOME=tests/home +KODI_INTERACTIVE=0 +KODI_STUB_VERBOSE=1 diff --git a/.gitignore b/.gitignore index 7b182f8..c7c4c3b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,9 @@ Thumbs.db *~ .cache - .coverage .tox/ + +# Testing tests/home/userdata/addon_data +.env diff --git a/Makefile b/Makefile index 06bb94e..e68976f 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,9 @@ check-addon: clean build cd ${TMPDIR} && kodi-addon-checker --branch=leia @rm -rf ${TMPDIR} +codefix: + @isort -l 160 resources/ + test: test-unit test-unit: diff --git a/resources/lib/addon.py b/resources/lib/addon.py index 9b11b96..70ab9f1 100644 --- a/resources/lib/addon.py +++ b/resources/lib/addon.py @@ -11,7 +11,7 @@ from resources.lib import kodilogging kodilogging.config() routing = Plugin() # pylint: disable=invalid-name -_LOGGER = logging.getLogger('addon') +_LOGGER = logging.getLogger(__name__) @routing.route('/') diff --git a/resources/lib/kodiutils.py b/resources/lib/kodiutils.py index b4b3584..4578f14 100644 --- a/resources/lib/kodiutils.py +++ b/resources/lib/kodiutils.py @@ -26,7 +26,7 @@ DEFAULT_SORT_METHODS = [ 'unsorted', 'title' ] -_LOGGER = logging.getLogger('kodiutils') +_LOGGER = logging.getLogger(__name__) class TitleItem: @@ -230,7 +230,8 @@ def ok_dialog(heading='', message=''): if not heading: heading = addon_name() if kodi_version_major() < 19: - return Dialog().ok(heading=heading, line1=message) # pylint: disable=unexpected-keyword-arg,no-value-for-parameter + # pylint: disable=unexpected-keyword-arg,no-value-for-parameter + return Dialog().ok(heading=heading, line1=message) return Dialog().ok(heading=heading, message=message) @@ -240,7 +241,8 @@ def yesno_dialog(heading='', message='', nolabel=None, yeslabel=None, autoclose= if not heading: heading = addon_name() if kodi_version_major() < 19: - return Dialog().yesno(heading=heading, line1=message, nolabel=nolabel, yeslabel=yeslabel, autoclose=autoclose) # pylint: disable=unexpected-keyword-arg,no-value-for-parameter + # pylint: disable=unexpected-keyword-arg,no-value-for-parameter + return Dialog().yesno(heading=heading, line1=message, nolabel=nolabel, yeslabel=yeslabel, autoclose=autoclose) return Dialog().yesno(heading=heading, message=message, nolabel=nolabel, yeslabel=yeslabel, autoclose=autoclose) @@ -294,7 +296,7 @@ def set_locale(): """Load the proper locale for date strings, only once""" if hasattr(set_locale, 'cached'): return getattr(set_locale, 'cached') - from locale import Error, LC_ALL, setlocale + from locale import LC_ALL, Error, setlocale locale_lang = get_global_setting('locale.language').split('.')[-1] locale_lang = locale_lang[:-2] + locale_lang[-2:].upper() # NOTE: setlocale() only works if the platform supports the Kodi configured locale diff --git a/resources/lib/modules/catalog.py b/resources/lib/modules/catalog.py index 5e28b24..4dd7093 100644 --- a/resources/lib/modules/catalog.py +++ b/resources/lib/modules/catalog.py @@ -10,9 +10,9 @@ from resources.lib.kodiutils import TitleItem from resources.lib.modules.menu import Menu from resources.lib.viervijfzes import CHANNELS from resources.lib.viervijfzes.auth import AuthApi -from resources.lib.viervijfzes.content import ContentApi, UnavailableException, CACHE_PREVENT +from resources.lib.viervijfzes.content import CACHE_PREVENT, ContentApi, UnavailableException -_LOGGER = logging.getLogger('catalog') +_LOGGER = logging.getLogger(__name__) class Catalog: diff --git a/resources/lib/modules/channels.py b/resources/lib/modules/channels.py index 844efb6..afb9642 100644 --- a/resources/lib/modules/channels.py +++ b/resources/lib/modules/channels.py @@ -10,9 +10,9 @@ from resources.lib.kodiutils import TitleItem from resources.lib.modules.menu import Menu from resources.lib.viervijfzes import CHANNELS, STREAM_DICT from resources.lib.viervijfzes.auth import AuthApi -from resources.lib.viervijfzes.content import ContentApi, CACHE_ONLY, CACHE_AUTO +from resources.lib.viervijfzes.content import CACHE_AUTO, CACHE_ONLY, ContentApi -_LOGGER = logging.getLogger('channels') +_LOGGER = logging.getLogger(__name__) class Channels: diff --git a/resources/lib/modules/menu.py b/resources/lib/modules/menu.py index 4e0660e..b79e46a 100644 --- a/resources/lib/modules/menu.py +++ b/resources/lib/modules/menu.py @@ -6,7 +6,7 @@ from __future__ import absolute_import, division, unicode_literals from resources.lib import kodiutils from resources.lib.kodiutils import TitleItem from resources.lib.viervijfzes import CHANNELS, STREAM_DICT -from resources.lib.viervijfzes.content import Program, Episode +from resources.lib.viervijfzes.content import Episode, Program class Menu: diff --git a/resources/lib/modules/metadata.py b/resources/lib/modules/metadata.py index d7e2f1a..1189e76 100644 --- a/resources/lib/modules/metadata.py +++ b/resources/lib/modules/metadata.py @@ -5,7 +5,7 @@ from __future__ import absolute_import, division, unicode_literals from resources.lib import kodiutils from resources.lib.viervijfzes import CHANNELS -from resources.lib.viervijfzes.content import ContentApi, Program, CACHE_PREVENT, CACHE_AUTO +from resources.lib.viervijfzes.content import CACHE_AUTO, CACHE_PREVENT, ContentApi, Program class Metadata: diff --git a/resources/lib/modules/player.py b/resources/lib/modules/player.py index 5feeea5..ba9600c 100644 --- a/resources/lib/modules/player.py +++ b/resources/lib/modules/player.py @@ -9,10 +9,10 @@ from resources.lib import kodiutils from resources.lib.modules.menu import Menu from resources.lib.viervijfzes import CHANNELS from resources.lib.viervijfzes.auth import AuthApi -from resources.lib.viervijfzes.auth_awsidp import InvalidLoginException, AuthenticationException -from resources.lib.viervijfzes.content import ContentApi, UnavailableException, GeoblockedException +from resources.lib.viervijfzes.auth_awsidp import AuthenticationException, InvalidLoginException +from resources.lib.viervijfzes.content import ContentApi, GeoblockedException, UnavailableException -_LOGGER = logging.getLogger('player') +_LOGGER = logging.getLogger(__name__) class Player: diff --git a/resources/lib/modules/search.py b/resources/lib/modules/search.py index c5e81a3..e2a361e 100644 --- a/resources/lib/modules/search.py +++ b/resources/lib/modules/search.py @@ -9,7 +9,7 @@ from resources.lib import kodiutils from resources.lib.modules.menu import Menu from resources.lib.viervijfzes.search import SearchApi -_LOGGER = logging.getLogger('search') +_LOGGER = logging.getLogger(__name__) class Search: diff --git a/resources/lib/modules/tvguide.py b/resources/lib/modules/tvguide.py index 5f02d0b..aac88b1 100644 --- a/resources/lib/modules/tvguide.py +++ b/resources/lib/modules/tvguide.py @@ -13,7 +13,7 @@ from resources.lib.viervijfzes import STREAM_DICT from resources.lib.viervijfzes.content import UnavailableException from resources.lib.viervijfzes.epg import EpgApi -_LOGGER = logging.getLogger('tvguide') +_LOGGER = logging.getLogger(__name__) class TvGuide: diff --git a/resources/lib/service.py b/resources/lib/service.py index d53f471..f18b65a 100644 --- a/resources/lib/service.py +++ b/resources/lib/service.py @@ -8,13 +8,13 @@ import logging import os from time import time -from xbmc import getInfoLabel, Monitor, Player +from xbmc import Monitor, Player, getInfoLabel from resources.lib import kodilogging, kodiutils from resources.lib.viervijfzes.auth import AuthApi kodilogging.config() -_LOGGER = logging.getLogger('service') +_LOGGER = logging.getLogger(__name__) class BackgroundService(Monitor): @@ -177,6 +177,7 @@ class KodiPlayer(Player): return _LOGGER.debug('KodiPlayer onPlayBackEnded') + def run(): """ Run the BackgroundService """ BackgroundService().run() diff --git a/resources/lib/viervijfzes/auth.py b/resources/lib/viervijfzes/auth.py index 948359a..a60ff53 100644 --- a/resources/lib/viervijfzes/auth.py +++ b/resources/lib/viervijfzes/auth.py @@ -9,9 +9,9 @@ import os import time from resources.lib import kodiutils -from resources.lib.viervijfzes.auth_awsidp import AwsIdp, InvalidLoginException, AuthenticationException +from resources.lib.viervijfzes.auth_awsidp import AuthenticationException, AwsIdp, InvalidLoginException -_LOGGER = logging.getLogger('auth-api') +_LOGGER = logging.getLogger(__name__) class AuthApi: diff --git a/resources/lib/viervijfzes/auth_awsidp.py b/resources/lib/viervijfzes/auth_awsidp.py index 001ff65..6917aa5 100644 --- a/resources/lib/viervijfzes/auth_awsidp.py +++ b/resources/lib/viervijfzes/auth_awsidp.py @@ -17,7 +17,7 @@ import sys import requests import six -_LOGGER = logging.getLogger('auth-awsidp') +_LOGGER = logging.getLogger(__name__) class InvalidLoginException(Exception): diff --git a/resources/lib/viervijfzes/content.py b/resources/lib/viervijfzes/content.py index 366844c..fc9d73d 100644 --- a/resources/lib/viervijfzes/content.py +++ b/resources/lib/viervijfzes/content.py @@ -10,12 +10,12 @@ import re import time from datetime import datetime -from six.moves.html_parser import HTMLParser import requests +from six.moves.html_parser import HTMLParser # pylint: disable=wrong-import-order from resources.lib.viervijfzes import CHANNELS -_LOGGER = logging.getLogger('content-api') +_LOGGER = logging.getLogger(__name__) CACHE_AUTO = 1 # Allow to use the cache, and query the API if no cache is available CACHE_ONLY = 2 # Only use the cache, don't use the API diff --git a/resources/lib/viervijfzes/epg.py b/resources/lib/viervijfzes/epg.py index f22a791..0e14e1f 100644 --- a/resources/lib/viervijfzes/epg.py +++ b/resources/lib/viervijfzes/epg.py @@ -11,7 +11,7 @@ import dateutil.parser import dateutil.tz import requests -_LOGGER = logging.getLogger('epg-api') +_LOGGER = logging.getLogger(__name__) GENRE_MAPPING = { 'Detective': 0x11, diff --git a/resources/lib/viervijfzes/search.py b/resources/lib/viervijfzes/search.py index 2af6d94..adea586 100644 --- a/resources/lib/viervijfzes/search.py +++ b/resources/lib/viervijfzes/search.py @@ -10,7 +10,7 @@ import requests from resources.lib.viervijfzes.content import Program -_LOGGER = logging.getLogger('search-api') +_LOGGER = logging.getLogger(__name__) class SearchApi: diff --git a/tests/__init__.py b/tests/__init__.py index ec7aa3f..ad162e7 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -13,7 +13,7 @@ logging.basicConfig(level=logging.INFO) # Make UTF-8 the default encoding in Python 2 if sys.version_info[0] == 2: - reload(sys) # pylint: disable=undefined-variable + reload(sys) # pylint: disable=undefined-variable # noqa: F821 sys.setdefaultencoding("utf-8") # pylint: disable=no-member # Set credentials based on environment data diff --git a/tests/test_api.py b/tests/test_api.py index 369bd8f..8752eef 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -43,7 +43,7 @@ class TestApi(unittest.TestCase): self.assertIsInstance(program.episodes[0], Episode) def test_clips(self): - for channel, program in [('vier', 'gert-late-night'), ('zes', 'macgyver')]: + for channel, program in [('vier', 'gert-late-night')]: program = self._api.get_program(channel, program, extract_clips=True, cache=CACHE_PREVENT) self.assertIsInstance(program.clips, list)