Merge branch 'beta-version'

This commit is contained in:
croneter 2018-07-15 19:22:56 +02:00
commit 27c3e2761e
6 changed files with 28 additions and 7 deletions

View file

@ -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) [![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) [![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) [![FAQ](https://img.shields.io/badge/wiki-FAQ-brightgreen.svg?maxAge=60&style=flat)](https://github.com/croneter/PlexKodiConnect/wiki/faq)

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.plexkodiconnect" name="PlexKodiConnect" version="2.2.13" provider-name="croneter"> <addon id="plugin.video.plexkodiconnect" name="PlexKodiConnect" version="2.2.14" provider-name="croneter">
<requires> <requires>
<import addon="xbmc.python" version="2.1.0"/> <import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.requests" version="2.9.1" /> <import addon="script.module.requests" version="2.9.1" />
@ -73,7 +73,10 @@
<summary lang="uk_UA">Нативна інтеграція Plex в Kodi</summary> <summary lang="uk_UA">Нативна інтеграція Plex в Kodi</summary>
<description lang="uk_UA">Підключає Kodi до серверу Plex. Цей плагін передбачає, що ви керуєте всіма своїми відео за допомогою Plex (і ніяк не Kodi). Ви можете втратити дані, які вже зберігаються у відео та музичних БД Kodi (оскільки цей плагін безпосередньо їх змінює). Використовуйте на свій страх і ризик!</description> <description lang="uk_UA">Підключає Kodi до серверу Plex. Цей плагін передбачає, що ви керуєте всіма своїми відео за допомогою Plex (і ніяк не Kodi). Ви можете втратити дані, які вже зберігаються у відео та музичних БД Kodi (оскільки цей плагін безпосередньо їх змінює). Використовуйте на свій страх і ризик!</description>
<disclaimer lang="uk_UA">Використовуйте на свій ризик</disclaimer> <disclaimer lang="uk_UA">Використовуйте на свій ризик</disclaimer>
<news>version 2.2.13 (beta only): <news>version 2.2.14 (beta only):
- Hopefully fix playlist sync loops
version 2.2.13 (beta only):
- Fix library sync crash - Fix library sync crash
- Fix switching to __future__ module - Fix switching to __future__ module
- Fix "Prefer Kodi Artwork" toggle doing the exact opposite - Fix "Prefer Kodi Artwork" toggle doing the exact opposite

View file

@ -1,3 +1,6 @@
version 2.2.14 (beta only):
- Hopefully fix playlist sync loops
version 2.2.13 (beta only): version 2.2.13 (beta only):
- Fix library sync crash - Fix library sync crash
- Fix switching to __future__ module - Fix switching to __future__ module

View file

@ -40,6 +40,8 @@ SUPPORTED_FILETYPES = (
# 'pls', # 'pls',
# 'cue', # 'cue',
) )
# Avoid endless loops
IGNORE_KODI_PLAYLIST_CHANGE = list()
############################################################################### ###############################################################################
@ -70,9 +72,10 @@ def websocket(plex_id, status):
if sync_plex_playlist(playlist=playlist): if sync_plex_playlist(playlist=playlist):
LOG.debug('Plex deletion of playlist detected: %s', playlist) LOG.debug('Plex deletion of playlist detected: %s', playlist)
try: try:
IGNORE_KODI_PLAYLIST_CHANGE.append(plex_id)
kodi_pl.delete(playlist) kodi_pl.delete(playlist)
except PlaylistError: except PlaylistError:
pass IGNORE_KODI_PLAYLIST_CHANGE.remove(plex_id)
return return
xml = pms.metadata(plex_id) xml = pms.metadata(plex_id)
if xml is None: if xml is None:
@ -90,6 +93,7 @@ def websocket(plex_id, status):
else: else:
LOG.debug('Change of Plex playlist detected: %s', LOG.debug('Change of Plex playlist detected: %s',
playlist) playlist)
IGNORE_KODI_PLAYLIST_CHANGE.append(plex_id)
kodi_pl.delete(playlist) kodi_pl.delete(playlist)
create = True create = True
elif not playlist and not status == 9: elif not playlist and not status == 9:
@ -98,9 +102,10 @@ def websocket(plex_id, status):
create = True create = True
# To the actual work # To the actual work
if create: if create:
IGNORE_KODI_PLAYLIST_CHANGE.append(plex_id)
kodi_pl.create(plex_id) kodi_pl.create(plex_id)
except PlaylistError: except PlaylistError:
pass IGNORE_KODI_PLAYLIST_CHANGE.remove(plex_id)
def full_sync(): def full_sync():
@ -140,22 +145,28 @@ def _full_sync():
if not playlist: if not playlist:
LOG.debug('New Plex playlist %s discovered: %s', LOG.debug('New Plex playlist %s discovered: %s',
api.plex_id(), api.title()) api.plex_id(), api.title())
IGNORE_KODI_PLAYLIST_CHANGE.append(api.plex_id())
kodi_pl.create(api.plex_id()) kodi_pl.create(api.plex_id())
elif playlist.plex_updatedat != api.updated_at(): elif playlist.plex_updatedat != api.updated_at():
LOG.debug('Detected changed Plex playlist %s: %s', LOG.debug('Detected changed Plex playlist %s: %s',
api.plex_id(), api.title()) api.plex_id(), api.title())
IGNORE_KODI_PLAYLIST_CHANGE.append(api.plex_id())
kodi_pl.delete(playlist) kodi_pl.delete(playlist)
IGNORE_KODI_PLAYLIST_CHANGE.append(api.plex_id())
kodi_pl.create(api.plex_id()) kodi_pl.create(api.plex_id())
except PlaylistError: except PlaylistError:
LOG.info('Skipping playlist %s: %s', api.plex_id(), api.title()) 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 # Get rid of old Plex playlists that were deleted on the Plex side
for plex_id in old_plex_ids: for plex_id in old_plex_ids:
playlist = db.get_playlist(plex_id=plex_id) playlist = db.get_playlist(plex_id=plex_id)
LOG.debug('Removing outdated Plex playlist: %s', playlist) LOG.debug('Removing outdated Plex playlist: %s', playlist)
try: try:
IGNORE_KODI_PLAYLIST_CHANGE.append(playlist.plex_id)
kodi_pl.delete(playlist) kodi_pl.delete(playlist)
except PlaylistError: except PlaylistError:
LOG.debug('Skipping deletion of playlist: %s', playlist) 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. # Look at all supported Kodi playlists. Check whether they are in the DB.
old_kodi_paths = db.kodi_playlist_paths() old_kodi_paths = db.kodi_playlist_paths()
for root, _, files in path_ops.walk(v.PLAYLIST_PATH): for root, _, files in path_ops.walk(v.PLAYLIST_PATH):
@ -275,6 +286,11 @@ class PlaylistEventhandler(events.FileSystemEventHandler):
else event.src_path else event.src_path
if not sync_kodi_playlist(path): if not sync_kodi_playlist(path):
return 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 = { _method_map = {
events.EVENT_TYPE_MODIFIED: self.on_modified, events.EVENT_TYPE_MODIFIED: self.on_modified,
events.EVENT_TYPE_MOVED: self.on_moved, events.EVENT_TYPE_MOVED: self.on_moved,

View file

@ -65,8 +65,6 @@ class Playlist(object):
self.kodi_hash = None self.kodi_hash = None
def __repr__(self): def __repr__(self):
for attr in self.__dict__:
LOG.debug('attr %s: %s', attr, type(attr))
return ("{{" return ("{{"
"'plex_id': {self.plex_id}, " "'plex_id': {self.plex_id}, "
"'plex_name': '{self.plex_name}', " "'plex_name': '{self.plex_name}', "

View file

@ -77,6 +77,7 @@ def delete(playlist):
if path_ops.exists(playlist.kodi_path): if path_ops.exists(playlist.kodi_path):
try: try:
path_ops.remove(playlist.kodi_path) path_ops.remove(playlist.kodi_path)
LOG.debug('Deleted Kodi playlist: %s', playlist)
except (OSError, IOError) as err: except (OSError, IOError) as err:
LOG.error('Could not delete Kodi playlist file %s. Error:\n%s: %s', LOG.error('Could not delete Kodi playlist file %s. Error:\n%s: %s',
playlist, err.errno, err.strerror) playlist, err.errno, err.strerror)