From 2d3d6d0699291fdb1b20bf7c1a349b1acbfa72d3 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Wed, 4 Aug 2021 20:39:51 +0200 Subject: [PATCH] Made rating an optional tag --- deemix/settings.py | 1 + deemix/tagger.py | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/deemix/settings.py b/deemix/settings.py index d1c6d5e..60a54b5 100644 --- a/deemix/settings.py +++ b/deemix/settings.py @@ -89,6 +89,7 @@ DEFAULTS = { "composer": False, "involvedPeople": False, "source": False, + "rating": False, "savePlaylistAsCompilation": False, "useNullSeparator": False, "saveID3v1": True, diff --git a/deemix/tagger.py b/deemix/tagger.py index 205e28a..5ea0d32 100644 --- a/deemix/tagger.py +++ b/deemix/tagger.py @@ -12,14 +12,6 @@ def tagID3(path, track, save): except ID3NoHeaderError: tag = ID3() - rank = round((int(track.rank) / 10000) * 2.55) - if rank > 255 : - rank = 255 - else: - rank = round(rank, 0) - - tag.add(POPM(rating=rank)) - if save['title']: tag.add(TIT2(text=track.title)) @@ -106,6 +98,15 @@ def tagID3(path, track, save): tag.add(TXXX(desc="SOURCE", text='Deezer')) tag.add(TXXX(desc="SOURCEID", text=str(track.id))) + if save['rating']: + rank = round((int(track.rank) / 10000) * 2.55) + if rank > 255 : + rank = 255 + else: + rank = round(rank, 0) + + tag.add(POPM(rating=rank)) + if save['cover'] and track.album.embeddedCoverPath: descEncoding = Encoding.LATIN1 @@ -131,9 +132,6 @@ def tagFLAC(path, track, save): tag.delete() tag.clear_pictures() - rank = round((int(track.rank) / 10000)) - tag['RATING'] = str(rank) - if save['title']: tag["TITLE"] = track.title @@ -210,6 +208,10 @@ def tagFLAC(path, track, save): tag["SOURCE"] = 'Deezer' tag["SOURCEID"] = str(track.id) + if save['rating']: + rank = round((int(track.rank) / 10000)) + tag['RATING'] = str(rank) + if save['cover'] and track.album.embeddedCoverPath: image = Picture() image.type = PictureType.COVER_FRONT