1 # -*- coding: UTF-8 -*-
3 # Copyright (C) 2020, Team Kodi
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # pylint: disable=missing-docstring
21 from __future__
import absolute_import
, unicode_literals
24 from xbmcaddon
import Addon
27 from typing
import Text
, Optional
, Any
, Dict
# pylint: disable=unused-import
31 ADDON_ID
= 'metadata.tvshows.themoviedb.org.python'
36 log_message_prefix
= '[{} ({})]: '.format(
37 ADDON_ID
, ADDON
.getAddonInfo('version'))
40 def log(message
, level
=xbmc
.LOGDEBUG
):
41 # type: (Text, int) -> None
42 if isinstance(message
, bytes
):
43 message
= message
.decode('utf-8')
44 message
= logger
.log_message_prefix
+ message
45 xbmc
.log(message
, level
)
49 # type: (Text) -> None
50 logger
.log(message
, xbmc
.LOGINFO
)
54 # type: (Text) -> None
55 logger
.log(message
, xbmc
.LOGERROR
)
59 # type: (Text) -> None
60 logger
.log(message
, xbmc
.LOGDEBUG
)
63 def safe_get(dct
, key
, default
=None):
64 # type: (Dict[Text, Any], Text, Any) -> Any
68 Returns the respective value or default if key is missing or the value is None.
70 if key
in dct
and dct
[key
] is not None: