|
|
|
@ -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){ |
|
|
|
@ -212,6 +220,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) |
|
|
|
@ -276,6 +289,12 @@ function tagID3v1(path, track, save){ |
|
|
|
tagBuffer.writeUInt8(255, 127) |
|
|
|
} |
|
|
|
|
|
|
|
// Write as comment
|
|
|
|
if (save.rating) { |
|
|
|
let rank = Math.round(track.rank / 10000); |
|
|
|
tagBuffer.write(`Rating: ${rank}%`, 97); |
|
|
|
} |
|
|
|
|
|
|
|
// Save tags
|
|
|
|
const songBuffer = fs.readFileSync(path) |
|
|
|
const buffer = new ArrayBuffer(songBuffer.byteLength + 128) |
|
|
|
|