Various fixes (#46)
* Various fixes * Order imports * Use __name__ for _LOGGER
This commit is contained in:
parent
e7c06c7966
commit
ed36677694
6
.env.example
Normal file
6
.env.example
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
ADDON_USERNAME=
|
||||||
|
ADDON_PASSWORD=
|
||||||
|
|
||||||
|
KODI_HOME=tests/home
|
||||||
|
KODI_INTERACTIVE=0
|
||||||
|
KODI_STUB_VERBOSE=1
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -9,7 +9,9 @@
|
|||||||
Thumbs.db
|
Thumbs.db
|
||||||
*~
|
*~
|
||||||
.cache
|
.cache
|
||||||
|
|
||||||
.coverage
|
.coverage
|
||||||
.tox/
|
.tox/
|
||||||
|
|
||||||
|
# Testing
|
||||||
tests/home/userdata/addon_data
|
tests/home/userdata/addon_data
|
||||||
|
.env
|
||||||
|
3
Makefile
3
Makefile
@ -41,6 +41,9 @@ check-addon: clean build
|
|||||||
cd ${TMPDIR} && kodi-addon-checker --branch=leia
|
cd ${TMPDIR} && kodi-addon-checker --branch=leia
|
||||||
@rm -rf ${TMPDIR}
|
@rm -rf ${TMPDIR}
|
||||||
|
|
||||||
|
codefix:
|
||||||
|
@isort -l 160 resources/
|
||||||
|
|
||||||
test: test-unit
|
test: test-unit
|
||||||
|
|
||||||
test-unit:
|
test-unit:
|
||||||
|
@ -11,7 +11,7 @@ from resources.lib import kodilogging
|
|||||||
|
|
||||||
kodilogging.config()
|
kodilogging.config()
|
||||||
routing = Plugin() # pylint: disable=invalid-name
|
routing = Plugin() # pylint: disable=invalid-name
|
||||||
_LOGGER = logging.getLogger('addon')
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@routing.route('/')
|
@routing.route('/')
|
||||||
|
@ -26,7 +26,7 @@ DEFAULT_SORT_METHODS = [
|
|||||||
'unsorted', 'title'
|
'unsorted', 'title'
|
||||||
]
|
]
|
||||||
|
|
||||||
_LOGGER = logging.getLogger('kodiutils')
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class TitleItem:
|
class TitleItem:
|
||||||
@ -230,7 +230,8 @@ def ok_dialog(heading='', message=''):
|
|||||||
if not heading:
|
if not heading:
|
||||||
heading = addon_name()
|
heading = addon_name()
|
||||||
if kodi_version_major() < 19:
|
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)
|
return Dialog().ok(heading=heading, message=message)
|
||||||
|
|
||||||
|
|
||||||
@ -240,7 +241,8 @@ def yesno_dialog(heading='', message='', nolabel=None, yeslabel=None, autoclose=
|
|||||||
if not heading:
|
if not heading:
|
||||||
heading = addon_name()
|
heading = addon_name()
|
||||||
if kodi_version_major() < 19:
|
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)
|
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"""
|
"""Load the proper locale for date strings, only once"""
|
||||||
if hasattr(set_locale, 'cached'):
|
if hasattr(set_locale, 'cached'):
|
||||||
return getattr(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 = get_global_setting('locale.language').split('.')[-1]
|
||||||
locale_lang = locale_lang[:-2] + locale_lang[-2:].upper()
|
locale_lang = locale_lang[:-2] + locale_lang[-2:].upper()
|
||||||
# NOTE: setlocale() only works if the platform supports the Kodi configured locale
|
# NOTE: setlocale() only works if the platform supports the Kodi configured locale
|
||||||
|
@ -10,9 +10,9 @@ from resources.lib.kodiutils import TitleItem
|
|||||||
from resources.lib.modules.menu import Menu
|
from resources.lib.modules.menu import Menu
|
||||||
from resources.lib.viervijfzes import CHANNELS
|
from resources.lib.viervijfzes import CHANNELS
|
||||||
from resources.lib.viervijfzes.auth import AuthApi
|
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:
|
class Catalog:
|
||||||
|
@ -10,9 +10,9 @@ from resources.lib.kodiutils import TitleItem
|
|||||||
from resources.lib.modules.menu import Menu
|
from resources.lib.modules.menu import Menu
|
||||||
from resources.lib.viervijfzes import CHANNELS, STREAM_DICT
|
from resources.lib.viervijfzes import CHANNELS, STREAM_DICT
|
||||||
from resources.lib.viervijfzes.auth import AuthApi
|
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:
|
class Channels:
|
||||||
|
@ -6,7 +6,7 @@ from __future__ import absolute_import, division, unicode_literals
|
|||||||
from resources.lib import kodiutils
|
from resources.lib import kodiutils
|
||||||
from resources.lib.kodiutils import TitleItem
|
from resources.lib.kodiutils import TitleItem
|
||||||
from resources.lib.viervijfzes import CHANNELS, STREAM_DICT
|
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:
|
class Menu:
|
||||||
|
@ -5,7 +5,7 @@ from __future__ import absolute_import, division, unicode_literals
|
|||||||
|
|
||||||
from resources.lib import kodiutils
|
from resources.lib import kodiutils
|
||||||
from resources.lib.viervijfzes import CHANNELS
|
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:
|
class Metadata:
|
||||||
|
@ -9,10 +9,10 @@ from resources.lib import kodiutils
|
|||||||
from resources.lib.modules.menu import Menu
|
from resources.lib.modules.menu import Menu
|
||||||
from resources.lib.viervijfzes import CHANNELS
|
from resources.lib.viervijfzes import CHANNELS
|
||||||
from resources.lib.viervijfzes.auth import AuthApi
|
from resources.lib.viervijfzes.auth import AuthApi
|
||||||
from resources.lib.viervijfzes.auth_awsidp import InvalidLoginException, AuthenticationException
|
from resources.lib.viervijfzes.auth_awsidp import AuthenticationException, InvalidLoginException
|
||||||
from resources.lib.viervijfzes.content import ContentApi, UnavailableException, GeoblockedException
|
from resources.lib.viervijfzes.content import ContentApi, GeoblockedException, UnavailableException
|
||||||
|
|
||||||
_LOGGER = logging.getLogger('player')
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Player:
|
class Player:
|
||||||
|
@ -9,7 +9,7 @@ from resources.lib import kodiutils
|
|||||||
from resources.lib.modules.menu import Menu
|
from resources.lib.modules.menu import Menu
|
||||||
from resources.lib.viervijfzes.search import SearchApi
|
from resources.lib.viervijfzes.search import SearchApi
|
||||||
|
|
||||||
_LOGGER = logging.getLogger('search')
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Search:
|
class Search:
|
||||||
|
@ -13,7 +13,7 @@ from resources.lib.viervijfzes import STREAM_DICT
|
|||||||
from resources.lib.viervijfzes.content import UnavailableException
|
from resources.lib.viervijfzes.content import UnavailableException
|
||||||
from resources.lib.viervijfzes.epg import EpgApi
|
from resources.lib.viervijfzes.epg import EpgApi
|
||||||
|
|
||||||
_LOGGER = logging.getLogger('tvguide')
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class TvGuide:
|
class TvGuide:
|
||||||
|
@ -8,13 +8,13 @@ import logging
|
|||||||
import os
|
import os
|
||||||
from time import time
|
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 import kodilogging, kodiutils
|
||||||
from resources.lib.viervijfzes.auth import AuthApi
|
from resources.lib.viervijfzes.auth import AuthApi
|
||||||
|
|
||||||
kodilogging.config()
|
kodilogging.config()
|
||||||
_LOGGER = logging.getLogger('service')
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class BackgroundService(Monitor):
|
class BackgroundService(Monitor):
|
||||||
@ -177,6 +177,7 @@ class KodiPlayer(Player):
|
|||||||
return
|
return
|
||||||
_LOGGER.debug('KodiPlayer onPlayBackEnded')
|
_LOGGER.debug('KodiPlayer onPlayBackEnded')
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
""" Run the BackgroundService """
|
""" Run the BackgroundService """
|
||||||
BackgroundService().run()
|
BackgroundService().run()
|
||||||
|
@ -9,9 +9,9 @@ import os
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from resources.lib import kodiutils
|
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:
|
class AuthApi:
|
||||||
|
@ -17,7 +17,7 @@ import sys
|
|||||||
import requests
|
import requests
|
||||||
import six
|
import six
|
||||||
|
|
||||||
_LOGGER = logging.getLogger('auth-awsidp')
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class InvalidLoginException(Exception):
|
class InvalidLoginException(Exception):
|
||||||
|
@ -10,12 +10,12 @@ import re
|
|||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from six.moves.html_parser import HTMLParser
|
|
||||||
import requests
|
import requests
|
||||||
|
from six.moves.html_parser import HTMLParser # pylint: disable=wrong-import-order
|
||||||
|
|
||||||
from resources.lib.viervijfzes import CHANNELS
|
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_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
|
CACHE_ONLY = 2 # Only use the cache, don't use the API
|
||||||
|
@ -11,7 +11,7 @@ import dateutil.parser
|
|||||||
import dateutil.tz
|
import dateutil.tz
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
_LOGGER = logging.getLogger('epg-api')
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
GENRE_MAPPING = {
|
GENRE_MAPPING = {
|
||||||
'Detective': 0x11,
|
'Detective': 0x11,
|
||||||
|
@ -10,7 +10,7 @@ import requests
|
|||||||
|
|
||||||
from resources.lib.viervijfzes.content import Program
|
from resources.lib.viervijfzes.content import Program
|
||||||
|
|
||||||
_LOGGER = logging.getLogger('search-api')
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class SearchApi:
|
class SearchApi:
|
||||||
|
@ -13,7 +13,7 @@ logging.basicConfig(level=logging.INFO)
|
|||||||
|
|
||||||
# Make UTF-8 the default encoding in Python 2
|
# Make UTF-8 the default encoding in Python 2
|
||||||
if sys.version_info[0] == 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
|
sys.setdefaultencoding("utf-8") # pylint: disable=no-member
|
||||||
|
|
||||||
# Set credentials based on environment data
|
# Set credentials based on environment data
|
||||||
|
@ -43,7 +43,7 @@ class TestApi(unittest.TestCase):
|
|||||||
self.assertIsInstance(program.episodes[0], Episode)
|
self.assertIsInstance(program.episodes[0], Episode)
|
||||||
|
|
||||||
def test_clips(self):
|
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)
|
program = self._api.get_program(channel, program, extract_clips=True, cache=CACHE_PREVENT)
|
||||||
|
|
||||||
self.assertIsInstance(program.clips, list)
|
self.assertIsInstance(program.clips, list)
|
||||||
|
Loading…
Reference in New Issue
Block a user