Add POPM for ID3v2 & FLAC tag

This commit is contained in:
RemixDev 2021-09-21 13:54:02 +02:00
parent 85132da563
commit a18c04acd4
4 changed files with 16 additions and 1 deletions

View file

@ -89,6 +89,7 @@ const DEFAULTS = {
composer: false,
involvedPeople: false,
source: false,
rating: false,
savePlaylistAsCompilation: false,
useNullSeparator: false,
saveID3v1: true,

View file

@ -112,6 +112,14 @@ function tagID3(path, track, save){
})
}
if (save.rating) {
let rank = (track.rank / 10000) * 2.55;
rank = rank > 255 ? 255 : Math.round(rank);
tag.setFrame('POPM', {
rating: rank
})
}
if (save.cover && track.album.embeddedCoverPath){
const coverArrayBuffer = fs.readFileSync(track.album.embeddedCoverPath)
if (coverArrayBuffer.length != 0){
@ -218,6 +226,11 @@ function tagFLAC(path, track, save){
flac.setTag(`SOURCEID=${track.id}`)
}
if (save.rating) {
let rank = Math.round(track.rank / 10000);
flac.setTag(`RATING=${rank}`)
}
if (save.cover && track.album.embeddedCoverPath){
let picture = fs.readFileSync(track.album.embeddedCoverPath)
if (picture.length != 0) flac.importPicture(picture)

View file

@ -223,6 +223,7 @@ class Track {
this.ISRC = trackAPI_gw.ISRC
this.trackNumber = trackAPI_gw.TRACK_NUMBER
this.contributors = trackAPI_gw.SNG_CONTRIBUTORS
this.rank = trackAPI_gw.RANK_SNG
this.lyrics = new Lyrics(trackAPI_gw.LYRICS_ID || "0")

File diff suppressed because one or more lines are too long