From 42258c699aa295c12e4cd594c82b218fcbe45396 Mon Sep 17 00:00:00 2001 From: Abby Date: Sun, 5 Jan 2020 23:41:26 +0000 Subject: [PATCH] Removed unnecessary log messages and changed some to debug (#167) --- jellyfin_kodi/client.py | 7 +++--- jellyfin_kodi/database/__init__.py | 6 ++--- jellyfin_kodi/jellyfin/configuration.py | 14 +++++------ jellyfin_kodi/jellyfin/http.py | 31 +++++++++++++------------ jellyfin_kodi/monitor.py | 22 +++++++++--------- jellyfin_kodi/objects/movies.py | 14 +++++------ jellyfin_kodi/objects/music.py | 18 +++++++------- jellyfin_kodi/objects/musicvideos.py | 8 +++---- jellyfin_kodi/objects/tvshows.py | 12 +++++----- 9 files changed, 65 insertions(+), 67 deletions(-) diff --git a/jellyfin_kodi/client.py b/jellyfin_kodi/client.py index de03fcdd..2eb63e4b 100644 --- a/jellyfin_kodi/client.py +++ b/jellyfin_kodi/client.py @@ -95,17 +95,16 @@ def get_device_id(reset=False): client_id = file_guid.read() if not client_id or reset: - LOG.info("Generating a new GUID.") + LOG.debug("Generating a new GUID.") client_id = str(create_id()) file_guid = xbmcvfs.File(jellyfin_guid, 'w') file_guid.write(client_id) file_guid.close() - - LOG.info("DeviceId loaded: %s", client_id) + LOG.debug("DeviceId loaded: %s", client_id) window('jellyfin_deviceId', value=client_id) - + return client_id diff --git a/jellyfin_kodi/database/__init__.py b/jellyfin_kodi/database/__init__.py index 844d38a4..cefac240 100644 --- a/jellyfin_kodi/database/__init__.py +++ b/jellyfin_kodi/database/__init__.py @@ -124,7 +124,7 @@ class Database(object): modified['time'] = modified_int modified['file'] = file - LOG.info("Discovered database: %s", modified) + LOG.debug("Discovered database: %s", modified) self.discovered_file = modified['file'] return xbmc.translatePath("special://database/%s" % modified['file']) @@ -184,7 +184,7 @@ class Database(object): if self.commit_close and changes: - LOG.info("[%s] %s rows updated.", self.db_file, changes) + LOG.debug("[%s] %s rows updated.", self.db_file, changes) self.conn.commit() LOG.debug("---<[ database: %s ] %s", self.db_file, id(self.conn)) @@ -210,7 +210,7 @@ def jellyfin_tables(cursor): columns = cursor.execute("SELECT * FROM jellyfin") if 'jellyfin_parent_id' not in [description[0] for description in columns.description]: - LOG.info("Add missing column jellyfin_parent_id") + LOG.debug("Add missing column jellyfin_parent_id") cursor.execute("ALTER TABLE jellyfin ADD COLUMN jellyfin_parent_id 'TEXT'") diff --git a/jellyfin_kodi/jellyfin/configuration.py b/jellyfin_kodi/jellyfin/configuration.py index b73f23ca..1d93ef9e 100644 --- a/jellyfin_kodi/jellyfin/configuration.py +++ b/jellyfin_kodi/jellyfin/configuration.py @@ -27,8 +27,8 @@ class Config(object): self.http() def app(self, name, version, device_name, device_id, capabilities=None, device_pixel_ratio=None): - LOG.info("Begin app constructor.") - + + LOG.debug("Begin app constructor.") self.data['app.name'] = name self.data['app.version'] = version self.data['app.device_name'] = device_name @@ -38,18 +38,16 @@ class Config(object): self.data['app.default'] = False def auth(self, server, user_id, token=None, ssl=None): - - LOG.info("Begin auth constructor.") - + + LOG.debug("Begin auth constructor.") self.data['auth.server'] = server self.data['auth.user_id'] = user_id self.data['auth.token'] = token self.data['auth.ssl'] = ssl def http(self, user_agent=None, max_retries=DEFAULT_HTTP_MAX_RETRIES, timeout=DEFAULT_HTTP_TIMEOUT): - - LOG.info("Begin http constructor.") - + + LOG.debug("Begin http constructor.") self.data['http.max_retries'] = max_retries self.data['http.timeout'] = timeout self.data['http.user_agent'] = user_agent diff --git a/jellyfin_kodi/jellyfin/http.py b/jellyfin_kodi/jellyfin/http.py index e324676c..63c58f3b 100644 --- a/jellyfin_kodi/jellyfin/http.py +++ b/jellyfin_kodi/jellyfin/http.py @@ -51,16 +51,16 @@ class HTTP(object): def _replace_user_info(self, string): if '{server}' in string: - if self.config.data['auth.server']: + if self.config.data.get('auth.server', None): string = string.replace("{server}", self.config.data['auth.server']) else: - raise Exception("Server address not set.") + LOG.debug("Server address not set") if '{UserId}'in string: - if self.config.data['auth.user_id']: + if self.config.data.get('auth.user_id', None): string = string.replace("{UserId}", self.config.data['auth.user_id']) else: - raise Exception("UserId is not set.") + LOG.debug("UserId is not set.") return string @@ -150,7 +150,8 @@ class HTTP(object): raise HTTPException(r.status_code, error) except requests.exceptions.MissingSchema as error: - raise HTTPException("MissingSchema", {'Id': self.config.data['auth.server']}) + LOG.error("Request missing Schema. " + str(error)) + raise HTTPException("MissingSchema", {'Id': self.config.data.get('auth.server', "None")}) except Exception as error: raise @@ -170,11 +171,11 @@ class HTTP(object): def _request(self, data): if 'url' not in data: - data['url'] = "%s/%s" % (self.config.data['auth.server'], data.pop('handler', "")) + data['url'] = "%s/%s" % (self.config.data.get("auth.server", ""), data.pop('handler', "")) self._get_header(data) data['timeout'] = data.get('timeout') or self.config.data['http.timeout'] - data['verify'] = data.get('verify') or self.config.data['auth.ssl'] or False + data['verify'] = data.get('verify') or self.config.data.get('auth.ssl', False) data['url'] = self._replace_user_info(data['url']) self._process_params(data.get('params') or {}) self._process_params(data.get('json') or {}) @@ -201,7 +202,7 @@ class HTTP(object): 'Content-type': "application/json", 'Accept-Charset': "UTF-8,*", 'Accept-encoding': "gzip", - 'User-Agent': self.config.data['http.user_agent'] or "%s/%s" % (self.config.data['app.name'], self.config.data['app.version']) + 'User-Agent': self.config.data['http.user_agent'] or "%s/%s" % (self.config.data.get('app.name', 'Jellyfin for Kodi'), self.config.data.get('app.version', "0.0.0")) }) if 'x-emby-authorization' not in data['headers']: @@ -212,17 +213,17 @@ class HTTP(object): def _authorization(self, data): auth = "MediaBrowser " - auth += "Client=%s, " % self.config.data['app.name'] - auth += "Device=%s, " % self.config.data['app.device_name'] - auth += "DeviceId=%s, " % self.config.data['app.device_id'] - auth += "Version=%s" % self.config.data['app.version'] + auth += "Client=%s, " % self.config.data.get('app.name', "Jellyfin for Kodi") + auth += "Device=%s, " % self.config.data.get('app.device_name', 'Unknown Device') + auth += "DeviceId=%s, " % self.config.data.get('app.device_id', 'Unknown Device id') + auth += "Version=%s" % self.config.data.get('app.version', '0.0.0') data['headers'].update({'x-emby-authorization': auth}) if self.config.data.get('auth.token') and self.config.data.get('auth.user_id'): - - auth += ', UserId=%s' % self.config.data['auth.user_id'] - data['headers'].update({'x-emby-authorization': auth, 'X-MediaBrowser-Token': self.config.data['auth.token']}) + + auth += ', UserId=%s' % self.config.data.get('auth.user_id') + data['headers'].update({'x-emby-authorization': auth, 'X-MediaBrowser-Token': self.config.data.get('auth.token')}) return data diff --git a/jellyfin_kodi/monitor.py b/jellyfin_kodi/monitor.py index a423303e..00f88d12 100644 --- a/jellyfin_kodi/monitor.py +++ b/jellyfin_kodi/monitor.py @@ -105,21 +105,21 @@ class Monitor(xbmc.Monitor): try: if not data.get('ServerId'): - raise Exception("ServerId undefined.") + server = Jellyfin() + else: + if method != 'LoadServer' and data['ServerId'] not in self.servers: - if method != 'LoadServer' and data['ServerId'] not in self.servers: + try: + connect.Connect().register(data['ServerId']) + self.server_instance(data['ServerId']) + except Exception as error: - try: - connect.Connect().register(data['ServerId']) - self.server_instance(data['ServerId']) - except Exception as error: + LOG.exception(error) + dialog("ok", heading="{jellyfin}", line1=translate(33142)) - LOG.exception(error) - dialog("ok", heading="{jellyfin}", line1=translate(33142)) + return - return - - server = Jellyfin(data['ServerId']) + server = Jellyfin(data['ServerId']) except Exception as error: LOG.exception(error) server = Jellyfin() diff --git a/jellyfin_kodi/objects/movies.py b/jellyfin_kodi/objects/movies.py index 99808f9f..826c5f08 100644 --- a/jellyfin_kodi/objects/movies.py +++ b/jellyfin_kodi/objects/movies.py @@ -132,7 +132,7 @@ class Movies(KodiDb): self.add(*values(obj, QU.add_movie_obj)) self.jellyfin_db.add_reference(*values(obj, QUEM.add_reference_movie_obj)) - LOG.info("ADD movie [%s/%s/%s] %s: %s", obj['PathId'], obj['FileId'], obj['MovieId'], obj['Id'], obj['Title']) + LOG.debug("ADD movie [%s/%s/%s] %s: %s", obj['PathId'], obj['FileId'], obj['MovieId'], obj['Id'], obj['Title']) def movie_update(self, obj): @@ -146,7 +146,7 @@ class Movies(KodiDb): self.update(*values(obj, QU.update_movie_obj)) self.jellyfin_db.update_reference(*values(obj, QUEM.update_reference_obj)) - LOG.info("UPDATE movie [%s/%s/%s] %s: %s", obj['PathId'], obj['FileId'], obj['MovieId'], obj['Id'], obj['Title']) + LOG.debug("UPDATE movie [%s/%s/%s] %s: %s", obj['PathId'], obj['FileId'], obj['MovieId'], obj['Id'], obj['Title']) def trailer(self, obj): @@ -219,11 +219,11 @@ class Movies(KodiDb): temp_obj['MovieId'] = obj['Current'][temp_obj['Movie']] self.remove_from_boxset(*values(temp_obj, QU.delete_movie_set_obj)) self.jellyfin_db.update_parent_id(*values(temp_obj, QUEM.delete_parent_boxset_obj)) - LOG.info("DELETE from boxset [%s] %s: %s", temp_obj['SetId'], temp_obj['Title'], temp_obj['MovieId']) + LOG.debug("DELETE from boxset [%s] %s: %s", temp_obj['SetId'], temp_obj['Title'], temp_obj['MovieId']) self.artwork.add(obj['Artwork'], obj['SetId'], "set") self.jellyfin_db.add_reference(*values(obj, QUEM.add_reference_boxset_obj)) - LOG.info("UPDATE boxset [%s] %s", obj['SetId'], obj['Title']) + LOG.debug("UPDATE boxset [%s] %s", obj['SetId'], obj['Title']) def boxset_current(self, obj): @@ -255,7 +255,7 @@ class Movies(KodiDb): self.set_boxset(*values(temp_obj, QU.update_movie_set_obj)) self.jellyfin_db.update_parent_id(*values(temp_obj, QUEM.update_parent_movie_obj)) - LOG.info("ADD to boxset [%s/%s] %s: %s to boxset", temp_obj['SetId'], temp_obj['MovieId'], temp_obj['Title'], temp_obj['Id']) + LOG.debug("ADD to boxset [%s/%s] %s: %s to boxset", temp_obj['SetId'], temp_obj['MovieId'], temp_obj['Title'], temp_obj['Id']) else: obj['Current'].pop(temp_obj['Id']) @@ -299,7 +299,7 @@ class Movies(KodiDb): LOG.debug("New resume point %s: %s", obj['Id'], obj['Resume']) self.add_playstate(*values(obj, QU.add_bookmark_obj)) self.jellyfin_db.update_reference(*values(obj, QUEM.update_reference_obj)) - LOG.info("USERDATA movie [%s/%s] %s: %s", obj['FileId'], obj['MovieId'], obj['Id'], obj['Title']) + LOG.debug("USERDATA movie [%s/%s] %s: %s", obj['FileId'], obj['MovieId'], obj['Id'], obj['Title']) @stop() @jellyfin_item() @@ -334,4 +334,4 @@ class Movies(KodiDb): self.delete_boxset(*values(obj, QU.delete_set_obj)) self.jellyfin_db.remove_item(*values(obj, QUEM.delete_item_obj)) - LOG.info("DELETE %s [%s/%s] %s", obj['Media'], obj['FileId'], obj['KodiId'], obj['Id']) + LOG.debug("DELETE %s [%s/%s] %s", obj['Media'], obj['FileId'], obj['KodiId'], obj['Id']) diff --git a/jellyfin_kodi/objects/music.py b/jellyfin_kodi/objects/music.py index be8b5922..1dff5387 100644 --- a/jellyfin_kodi/objects/music.py +++ b/jellyfin_kodi/objects/music.py @@ -92,14 +92,14 @@ class Music(KodiDb): ''' obj['ArtistId'] = self.get(*values(obj, QU.get_artist_obj)) self.jellyfin_db.add_reference(*values(obj, QUEM.add_reference_artist_obj)) - LOG.info("ADD artist [%s] %s: %s", obj['ArtistId'], obj['Name'], obj['Id']) + LOG.debug("ADD artist [%s] %s: %s", obj['ArtistId'], obj['Name'], obj['Id']) def artist_update(self, obj): ''' Update object to kodi. ''' self.jellyfin_db.update_reference(*values(obj, QUEM.update_reference_obj)) - LOG.info("UPDATE artist [%s] %s: %s", obj['ArtistId'], obj['Name'], obj['Id']) + LOG.debug("UPDATE artist [%s] %s: %s", obj['ArtistId'], obj['Name'], obj['Id']) @stop() @jellyfin_item() @@ -154,14 +154,14 @@ class Music(KodiDb): ''' obj['AlbumId'] = self.get_album(*values(obj, QU.get_album_obj)) self.jellyfin_db.add_reference(*values(obj, QUEM.add_reference_album_obj)) - LOG.info("ADD album [%s] %s: %s", obj['AlbumId'], obj['Title'], obj['Id']) + LOG.debug("ADD album [%s] %s: %s", obj['AlbumId'], obj['Title'], obj['Id']) def album_update(self, obj): ''' Update object to kodi. ''' self.jellyfin_db.update_reference(*values(obj, QUEM.update_reference_obj)) - LOG.info("UPDATE album [%s] %s: %s", obj['AlbumId'], obj['Title'], obj['Id']) + LOG.debug("UPDATE album [%s] %s: %s", obj['AlbumId'], obj['Title'], obj['Id']) def artist_discography(self, obj): @@ -312,7 +312,7 @@ class Music(KodiDb): self.update_song(*values(obj, QU.update_song_obj)) self.jellyfin_db.update_reference(*values(obj, QUEM.update_reference_obj)) - LOG.info("UPDATE song [%s/%s/%s] %s: %s", obj['PathId'], obj['AlbumId'], obj['SongId'], obj['Id'], obj['Title']) + LOG.debug("UPDATE song [%s/%s/%s] %s: %s", obj['PathId'], obj['AlbumId'], obj['SongId'], obj['Id'], obj['Title']) def get_song_path_filename(self, obj, api): @@ -426,7 +426,7 @@ class Music(KodiDb): self.rate_song(*values(obj, QU.update_song_rating_obj)) self.jellyfin_db.update_reference(*values(obj, QUEM.update_reference_obj)) - LOG.info("USERDATA %s [%s] %s: %s", obj['Media'], obj['KodiId'], obj['Id'], obj['Title']) + LOG.debug("USERDATA %s [%s] %s: %s", obj['Media'], obj['KodiId'], obj['Id'], obj['Title']) @stop() @jellyfin_item() @@ -495,19 +495,19 @@ class Music(KodiDb): self.artwork.delete(kodi_id, "artist") self.delete(kodi_id) - LOG.info("DELETE artist [%s] %s", kodi_id, item_id) + LOG.debug("DELETE artist [%s] %s", kodi_id, item_id) def remove_album(self, kodi_id, item_id): self.artwork.delete(kodi_id, "album") self.delete_album(kodi_id) - LOG.info("DELETE album [%s] %s", kodi_id, item_id) + LOG.debug("DELETE album [%s] %s", kodi_id, item_id) def remove_song(self, kodi_id, item_id): self.artwork.delete(kodi_id, "song") self.delete_song(kodi_id) - LOG.info("DELETE song [%s] %s", kodi_id, item_id) + LOG.debug("DELETE song [%s] %s", kodi_id, item_id) @jellyfin_item() def get_child(self, item_id, e_item): diff --git a/jellyfin_kodi/objects/musicvideos.py b/jellyfin_kodi/objects/musicvideos.py index c106c8a1..e6c8aa82 100644 --- a/jellyfin_kodi/objects/musicvideos.py +++ b/jellyfin_kodi/objects/musicvideos.py @@ -141,7 +141,7 @@ class MusicVideos(KodiDb): self.add(*values(obj, QU.add_musicvideo_obj)) self.jellyfin_db.add_reference(*values(obj, QUEM.add_reference_mvideo_obj)) - LOG.info("ADD mvideo [%s/%s/%s] %s: %s", obj['PathId'], obj['FileId'], obj['MvideoId'], obj['Id'], obj['Title']) + LOG.debug("ADD mvideo [%s/%s/%s] %s: %s", obj['PathId'], obj['FileId'], obj['MvideoId'], obj['Id'], obj['Title']) def musicvideo_update(self, obj): @@ -149,7 +149,7 @@ class MusicVideos(KodiDb): ''' self.update(*values(obj, QU.update_musicvideo_obj)) self.jellyfin_db.update_reference(*values(obj, QUEM.update_reference_obj)) - LOG.info("UPDATE mvideo [%s/%s/%s] %s: %s", obj['PathId'], obj['FileId'], obj['MvideoId'], obj['Id'], obj['Title']) + LOG.debug("UPDATE mvideo [%s/%s/%s] %s: %s", obj['PathId'], obj['FileId'], obj['MvideoId'], obj['Id'], obj['Title']) def get_path_filename(self, obj): @@ -205,7 +205,7 @@ class MusicVideos(KodiDb): self.add_playstate(*values(obj, QU.add_bookmark_obj)) self.jellyfin_db.update_reference(*values(obj, QUEM.update_reference_obj)) - LOG.info("USERDATA mvideo [%s/%s] %s: %s", obj['FileId'], obj['MvideoId'], obj['Id'], obj['Title']) + LOG.debug("USERDATA mvideo [%s/%s] %s: %s", obj['FileId'], obj['MvideoId'], obj['Id'], obj['Title']) @stop() @jellyfin_item() @@ -229,4 +229,4 @@ class MusicVideos(KodiDb): self.remove_path(*values(obj, QU.delete_path_obj)) self.jellyfin_db.remove_item(*values(obj, QUEM.delete_item_obj)) - LOG.info("DELETE musicvideo %s [%s/%s] %s", obj['MvideoId'], obj['PathId'], obj['FileId'], obj['Id']) + LOG.debug("DELETE musicvideo %s [%s/%s] %s", obj['MvideoId'], obj['PathId'], obj['FileId'], obj['Id']) diff --git a/jellyfin_kodi/objects/tvshows.py b/jellyfin_kodi/objects/tvshows.py index 0e67c131..e8442bc9 100644 --- a/jellyfin_kodi/objects/tvshows.py +++ b/jellyfin_kodi/objects/tvshows.py @@ -164,7 +164,7 @@ class TVShows(KodiDb): self.add(*values(obj, QU.add_tvshow_obj)) self.jellyfin_db.add_reference(*values(obj, QUEM.add_reference_tvshow_obj)) - LOG.info("ADD tvshow [%s/%s/%s] %s: %s", obj['TopPathId'], obj['PathId'], obj['ShowId'], obj['Title'], obj['Id']) + LOG.debug("ADD tvshow [%s/%s/%s] %s: %s", obj['TopPathId'], obj['PathId'], obj['ShowId'], obj['Title'], obj['Id']) def tvshow_update(self, obj): @@ -178,7 +178,7 @@ class TVShows(KodiDb): self.update(*values(obj, QU.update_tvshow_obj)) self.jellyfin_db.update_reference(*values(obj, QUEM.update_reference_obj)) - LOG.info("UPDATE tvshow [%s/%s] %s: %s", obj['PathId'], obj['ShowId'], obj['Title'], obj['Id']) + LOG.debug("UPDATE tvshow [%s/%s] %s: %s", obj['PathId'], obj['ShowId'], obj['Title'], obj['Id']) def get_path_filename(self, obj): @@ -230,7 +230,7 @@ class TVShows(KodiDb): self.item_ids.append(obj['Id']) self.artwork.add(obj['Artwork'], obj['SeasonId'], "season") - LOG.info("UPDATE season [%s/%s] %s: %s", obj['ShowId'], obj['SeasonId'], obj['Title'] or obj['Index'], obj['Id']) + LOG.debug("UPDATE season [%s/%s] %s: %s", obj['ShowId'], obj['SeasonId'], obj['Title'] or obj['Index'], obj['Id']) @stop() @jellyfin_item() @@ -480,7 +480,7 @@ class TVShows(KodiDb): self.add_playstate(*values(temp_obj, QU.add_bookmark_obj)) self.jellyfin_db.update_reference(*values(obj, QUEM.update_reference_obj)) - LOG.info("USERDATA %s [%s/%s] %s: %s", obj['Media'], obj['FileId'], obj['KodiId'], obj['Id'], obj['Title']) + LOG.debug("USERDATA %s [%s/%s] %s: %s", obj['Media'], obj['FileId'], obj['KodiId'], obj['Id'], obj['Title']) @stop() @jellyfin_item() @@ -577,13 +577,13 @@ class TVShows(KodiDb): self.artwork.delete(kodi_id, "season") self.delete_season(kodi_id) - LOG.info("DELETE season [%s] %s", kodi_id, item_id) + LOG.debug("DELETE season [%s] %s", kodi_id, item_id) def remove_episode(self, kodi_id, file_id, item_id): self.artwork.delete(kodi_id, "episode") self.delete_episode(kodi_id, file_id) - LOG.info("DELETE episode [%s/%s] %s", file_id, kodi_id, item_id) + LOG.debug("DELETE episode [%s/%s] %s", file_id, kodi_id, item_id) @jellyfin_item() def get_child(self, item_id, e_item):