add POPM on ID3 and RATING on Flac
This commit is contained in:
parent
44d018a810
commit
4c119447f5
|
@ -1,7 +1,7 @@
|
|||
from mutagen.flac import FLAC, Picture
|
||||
from mutagen.id3 import ID3, ID3NoHeaderError, \
|
||||
TXXX, TIT2, TPE1, TALB, TPE2, TRCK, TPOS, TCON, TYER, TDAT, TLEN, TBPM, \
|
||||
TPUB, TSRC, USLT, SYLT, APIC, IPLS, TCOM, TCOP, TCMP, Encoding, PictureType
|
||||
TPUB, TSRC, USLT, SYLT, APIC, IPLS, TCOM, TCOP, TCMP, Encoding, PictureType, POPM
|
||||
|
||||
# Adds tags to a MP3 file
|
||||
def tagID3(path, track, save):
|
||||
|
@ -12,6 +12,14 @@ 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))
|
||||
|
||||
|
@ -123,6 +131,9 @@ 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
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ class Track:
|
|||
self.id = str(trackAPI_gw['SNG_ID'])
|
||||
self.duration = trackAPI_gw['DURATION']
|
||||
self.trackToken = trackAPI_gw['TRACK_TOKEN']
|
||||
self.rank = trackAPI_gw['RANK_SNG']
|
||||
self.MD5 = trackAPI_gw.get('MD5_ORIGIN')
|
||||
if not self.MD5:
|
||||
if trackAPI and trackAPI.get('md5_origin'):
|
||||
|
|
Loading…
Reference in New Issue