From 59a64d227d59011792446480f83c4590fa7a681b Mon Sep 17 00:00:00 2001 From: croneter Date: Fri, 13 Jul 2018 07:31:21 +0200 Subject: [PATCH 1/3] Less logging --- resources/lib/playlists/common.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/resources/lib/playlists/common.py b/resources/lib/playlists/common.py index 2421978c..66444b11 100644 --- a/resources/lib/playlists/common.py +++ b/resources/lib/playlists/common.py @@ -65,8 +65,6 @@ class Playlist(object): self.kodi_hash = None def __repr__(self): - for attr in self.__dict__: - LOG.debug('attr %s: %s', attr, type(attr)) return ("{{" "'plex_id': {self.plex_id}, " "'plex_name': '{self.plex_name}', " From 06bfb95623df4820e5885cbde743ab9689b0cdc2 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 15 Jul 2018 19:20:51 +0200 Subject: [PATCH 2/3] Hopefully fix playlist sync loops --- resources/lib/playlists/__init__.py | 20 ++++++++++++++++++-- resources/lib/playlists/kodi_pl.py | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/resources/lib/playlists/__init__.py b/resources/lib/playlists/__init__.py index 1f89a8ae..da5df27d 100644 --- a/resources/lib/playlists/__init__.py +++ b/resources/lib/playlists/__init__.py @@ -40,6 +40,8 @@ SUPPORTED_FILETYPES = ( # 'pls', # 'cue', ) +# Avoid endless loops +IGNORE_KODI_PLAYLIST_CHANGE = list() ############################################################################### @@ -70,9 +72,10 @@ def websocket(plex_id, status): if sync_plex_playlist(playlist=playlist): LOG.debug('Plex deletion of playlist detected: %s', playlist) try: + IGNORE_KODI_PLAYLIST_CHANGE.append(plex_id) kodi_pl.delete(playlist) except PlaylistError: - pass + IGNORE_KODI_PLAYLIST_CHANGE.remove(plex_id) return xml = pms.metadata(plex_id) if xml is None: @@ -90,6 +93,7 @@ def websocket(plex_id, status): else: LOG.debug('Change of Plex playlist detected: %s', playlist) + IGNORE_KODI_PLAYLIST_CHANGE.append(plex_id) kodi_pl.delete(playlist) create = True elif not playlist and not status == 9: @@ -98,9 +102,10 @@ def websocket(plex_id, status): create = True # To the actual work if create: + IGNORE_KODI_PLAYLIST_CHANGE.append(plex_id) kodi_pl.create(plex_id) except PlaylistError: - pass + IGNORE_KODI_PLAYLIST_CHANGE.remove(plex_id) def full_sync(): @@ -140,22 +145,28 @@ def _full_sync(): if not playlist: LOG.debug('New Plex playlist %s discovered: %s', api.plex_id(), api.title()) + IGNORE_KODI_PLAYLIST_CHANGE.append(api.plex_id()) kodi_pl.create(api.plex_id()) elif playlist.plex_updatedat != api.updated_at(): LOG.debug('Detected changed Plex playlist %s: %s', api.plex_id(), api.title()) + IGNORE_KODI_PLAYLIST_CHANGE.append(api.plex_id()) kodi_pl.delete(playlist) + IGNORE_KODI_PLAYLIST_CHANGE.append(api.plex_id()) kodi_pl.create(api.plex_id()) except PlaylistError: LOG.info('Skipping playlist %s: %s', api.plex_id(), api.title()) + IGNORE_KODI_PLAYLIST_CHANGE.remove(api.plex_id()) # Get rid of old Plex playlists that were deleted on the Plex side for plex_id in old_plex_ids: playlist = db.get_playlist(plex_id=plex_id) LOG.debug('Removing outdated Plex playlist: %s', playlist) try: + IGNORE_KODI_PLAYLIST_CHANGE.append(playlist.plex_id) kodi_pl.delete(playlist) except PlaylistError: LOG.debug('Skipping deletion of playlist: %s', playlist) + IGNORE_KODI_PLAYLIST_CHANGE.remove(playlist.plex_id) # Look at all supported Kodi playlists. Check whether they are in the DB. old_kodi_paths = db.kodi_playlist_paths() for root, _, files in path_ops.walk(v.PLAYLIST_PATH): @@ -275,6 +286,11 @@ class PlaylistEventhandler(events.FileSystemEventHandler): else event.src_path if not sync_kodi_playlist(path): return + playlist = db.get_playlist(path=path) + if playlist and playlist.plex_id in IGNORE_KODI_PLAYLIST_CHANGE: + LOG.debug('Ignoring event %s for playlist %s', event, playlist) + IGNORE_KODI_PLAYLIST_CHANGE.remove(playlist.plex_id) + return _method_map = { events.EVENT_TYPE_MODIFIED: self.on_modified, events.EVENT_TYPE_MOVED: self.on_moved, diff --git a/resources/lib/playlists/kodi_pl.py b/resources/lib/playlists/kodi_pl.py index 9b90bf83..41a0c146 100644 --- a/resources/lib/playlists/kodi_pl.py +++ b/resources/lib/playlists/kodi_pl.py @@ -77,6 +77,7 @@ def delete(playlist): if path_ops.exists(playlist.kodi_path): try: path_ops.remove(playlist.kodi_path) + LOG.debug('Deleted Kodi playlist: %s', playlist) except (OSError, IOError) as err: LOG.error('Could not delete Kodi playlist file %s. Error:\n%s: %s', playlist, err.errno, err.strerror) From 976cb506b95b6baf2979f5f89e6f7f23ed0a29ed Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 15 Jul 2018 19:22:30 +0200 Subject: [PATCH 3/3] Beta version bump 2.2.14 --- README.md | 2 +- addon.xml | 7 +++++-- changelog.txt | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 13b908d0..300ece0d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![stable version](https://img.shields.io/badge/stable_version-2.1.6-blue.svg?maxAge=60&style=flat) ](https://github.com/croneter/binary_repo/raw/master/stable/repository.plexkodiconnect/repository.plexkodiconnect-1.0.2.zip) -[![beta version](https://img.shields.io/badge/beta_version-2.2.13-red.svg?maxAge=60&style=flat) ](https://github.com/croneter/binary_repo/raw/master/beta/repository.plexkodiconnectbeta/repository.plexkodiconnectbeta-1.0.2.zip) +[![beta version](https://img.shields.io/badge/beta_version-2.2.14-red.svg?maxAge=60&style=flat) ](https://github.com/croneter/binary_repo/raw/master/beta/repository.plexkodiconnectbeta/repository.plexkodiconnectbeta-1.0.2.zip) [![Installation](https://img.shields.io/badge/wiki-installation-brightgreen.svg?maxAge=60&style=flat)](https://github.com/croneter/PlexKodiConnect/wiki/Installation) [![FAQ](https://img.shields.io/badge/wiki-FAQ-brightgreen.svg?maxAge=60&style=flat)](https://github.com/croneter/PlexKodiConnect/wiki/faq) diff --git a/addon.xml b/addon.xml index 5bde2c3e..8645e489 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + @@ -73,7 +73,10 @@ Нативна інтеграція Plex в Kodi Підключає Kodi до серверу Plex. Цей плагін передбачає, що ви керуєте всіма своїми відео за допомогою Plex (і ніяк не Kodi). Ви можете втратити дані, які вже зберігаються у відео та музичних БД Kodi (оскільки цей плагін безпосередньо їх змінює). Використовуйте на свій страх і ризик! Використовуйте на свій ризик - version 2.2.13 (beta only): + version 2.2.14 (beta only): +- Hopefully fix playlist sync loops + +version 2.2.13 (beta only): - Fix library sync crash - Fix switching to __future__ module - Fix "Prefer Kodi Artwork" toggle doing the exact opposite diff --git a/changelog.txt b/changelog.txt index 85eec9de..af752ab7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +version 2.2.14 (beta only): +- Hopefully fix playlist sync loops + version 2.2.13 (beta only): - Fix library sync crash - Fix switching to __future__ module