Merge pull request #717 from croneter/fix-playlists

Fix rare case where thousands of identical playlists could be generated
This commit is contained in:
croneter 2019-02-08 15:19:37 +01:00 committed by GitHub
commit da1cb6e3d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,7 +17,7 @@ LOG = getLogger('PLEX.playlists.kodi_pl')
############################################################################### ###############################################################################
REGEX_FILE_NUMBERING = re.compile(r'''_(\d+)\.\w+$''') REGEX_FILE_NUMBERING = re.compile(r'''_(\d\d)\.\w+$''')
def create(plex_id): def create(plex_id):
@ -53,6 +53,10 @@ def create(plex_id):
'%s_01.m3u' % name[:min(len(name), 248)]) '%s_01.m3u' % name[:min(len(name), 248)])
else: else:
number = int(occurance.group(1)) + 1 number = int(occurance.group(1)) + 1
if number > 3:
LOG.error('Detected spanning tree issue, abort sync for %s',
playlist)
raise PlaylistError('Spanning tree warning')
basename = re.sub(REGEX_FILE_NUMBERING, '', path) basename = re.sub(REGEX_FILE_NUMBERING, '', path)
path = '%s_%02d.m3u' % (basename, number) path = '%s_%02d.m3u' % (basename, number)
LOG.debug('Kodi playlist path: %s', path) LOG.debug('Kodi playlist path: %s', path)