Clean up code

This commit is contained in:
Croneter 2018-05-02 17:55:27 +02:00
parent 799f9ba25a
commit c3b649c1b1

View file

@ -126,7 +126,8 @@ def create_kodi_playlist(plex_id=None, updated_at=None):
playlist.kodi_path = path playlist.kodi_path = path
# Derive filename close to Plex playlist name # Derive filename close to Plex playlist name
_write_playlist_to_file(playlist, xml) _write_playlist_to_file(playlist, xml)
update_plex_table(playlist, update_kodi_hash=True) playlist.kodi_hash = utils.generate_file_md5(path)
update_plex_table(playlist)
LOG.info('Created Kodi playlist based on Plex playlist: %s', playlist) LOG.info('Created Kodi playlist based on Plex playlist: %s', playlist)
@ -147,8 +148,7 @@ def delete_kodi_playlist(playlist):
update_plex_table(playlist, delete=True) update_plex_table(playlist, delete=True)
def update_plex_table(playlist, delete=False, new_path=None, def update_plex_table(playlist, delete=False):
update_kodi_hash=False):
""" """
Assumes that all sync operations are over. Takes playlist [Playlist_Object] Assumes that all sync operations are over. Takes playlist [Playlist_Object]
and creates/updates the corresponding Plex playlists table entry and creates/updates the corresponding Plex playlists table entry
@ -159,8 +159,6 @@ def update_plex_table(playlist, delete=False, new_path=None,
with plexdb.Get_Plex_DB() as plex_db: with plexdb.Get_Plex_DB() as plex_db:
plex_db.delete_playlist_entry(playlist) plex_db.delete_playlist_entry(playlist)
return return
if update_kodi_hash:
playlist.kodi_hash = utils.generate_file_md5(playlist.kodi_path)
with plexdb.Get_Plex_DB() as plex_db: with plexdb.Get_Plex_DB() as plex_db:
plex_db.insert_playlist_entry(playlist) plex_db.insert_playlist_entry(playlist)