forked from miraclx/freyr-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix miraclx#334: Replace AtomicParsley with lofty-rs.
- Loading branch information
Showing
4 changed files
with
183 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import {program as commander} from 'commander'; | |
import {decode as entityDecode} from 'html-entities'; | ||
import {createFFmpeg, fetchFile} from '@ffmpeg/ffmpeg'; | ||
import ProgressBar, {getPersistentStdout} from 'xprogress'; | ||
import meta_writer from '@orsetto/meta-writer'; | ||
|
||
import _merge from 'lodash.merge'; | ||
import _mergeWith from 'lodash.mergewith'; | ||
|
@@ -1096,56 +1097,58 @@ async function init(packageJson, queries, options) { | |
Config.concurrency.embedder, | ||
async ({track, meta, files, audioSource}) => { | ||
try { | ||
await Promise.promisify(atomicParsley)(meta.outFile.path, { | ||
await meta_writer({ | ||
overWrite: '', // overwrite the file | ||
|
||
title: track.name, // ©nam | ||
artist: track.artists[0], // ©ART | ||
composer: track.composers, // ©wrt | ||
album: track.album, // ©alb | ||
genre: (genre => (genre ? genre.concat(' ') : ''))((track.genres || [])[0]), // ©gen | gnre | ||
tracknum: `${track.track_number}/${track.total_tracks}`, // trkn | ||
disk: `${track.disc_number}/${track.disc_number}`, // disk | ||
year: new Date(track.release_date).toISOString().split('T')[0], // ©day | ||
compilation: track.compilation, // ©cpil | ||
gapless: options.gapless, // pgap | ||
rDNSatom: [ | ||
TrackTitle: track.name, // ©nam | ||
TrackArtist: track.artists[0], // ©ART | ||
Composer: track.composers, // ©wrt | ||
AlbumTitle: track.album, // ©alb | ||
Genre: (genre => (genre ? genre.concat(' ') : ''))((track.genres || [''])[0]), // ©gen | gnre | ||
TrackNumber: `${track.track_number}`, // trkn | ||
TrackTotal: `${track.total_tracks}`, | ||
DiscNumber: `${track.disc_number}`, // disk | ||
DiscTotal: `${track.disc_number}`, | ||
RecordingDate: new Date(track.release_date).toISOString().split('T')[0], // ©day | ||
|
||
AlbumArtist: track.album_artist, // aART | ||
CopyrightMessage: track.copyrights.sort(({type}) => (type === 'P' ? -1 : 1))[0]?.text, // cprt | ||
EncoderSoftware: `freyr-js cli v${packageJson.version}`, // ©too | ||
EncodedBy: 'd3vc0dr', // ©enc | ||
FrontCover: files.image.file.path, // covr | ||
|
||
// Ilst tags | ||
'cpil': track.compilation, // ©cpil | ||
stik: 'Normal', // stik | ||
pgap: options.gapless, // pgap | ||
rDNS: [ | ||
// ---- | ||
['Digital Media', 'name=MEDIA', 'domain=com.apple.iTunes'], | ||
[track.isrc, 'name=ISRC', 'domain=com.apple.iTunes'], | ||
[track.artists[0], 'name=ARTISTS', 'domain=com.apple.iTunes'], | ||
[track.label, 'name=LABEL', 'domain=com.apple.iTunes'], | ||
[`${meta.service[symbols.meta].DESC}: ${track.uri}`, 'name=SOURCE', 'domain=com.apple.iTunes'], | ||
[ | ||
`${audioSource.service[symbols.meta].DESC}: ${audioSource.source.videoId}`, | ||
'name=PROVIDER', | ||
'domain=com.apple.iTunes', | ||
], | ||
{mean: 'com.apple.iTunes', name: 'MEDIA', data: 'Digital Media' }, | ||
{mean: 'com.apple.iTunes', name: 'ISRC', data: track.isrc }, | ||
{mean: 'com.apple.iTunes', name: 'ARTISTS', data: track.artists[0] }, | ||
{mean: 'com.apple.iTunes', name: 'LABEL', data: track.label }, | ||
{mean: 'com.apple.iTunes', name: 'SOURCE', data: `${meta.service[symbols.meta].DESC}: ${track.uri}` }, | ||
{mean: 'com.apple.iTunes', name: 'PROVIDER', data: `${audioSource.service[symbols.meta].DESC}: ${audioSource.source.videoId}` } | ||
], | ||
advisory: ['explicit', 'clean'].includes(track.contentRating) // rtng | ||
ParentalAdvisory: ['explicit', 'clean'].includes(track.contentRating) // rtng | ||
? track.contentRating | ||
: track.contentRating === true | ||
? 'explicit' | ||
: 'Inoffensive', | ||
stik: 'Normal', // stik | ||
// geID: 0, // geID: genreID. See `AtomicParsley --genre-list` | ||
// sfID: 0, // ~~~~: store front ID | ||
// cnID: 0, // cnID: catalog ID | ||
albumArtist: track.album_artist, // aART | ||
// ownr? <owner> | ||
purchaseDate: 'timestamp', // purd | ||
purd: 'timestamp', // purd | ||
apID: '[email protected]', // apID | ||
copyright: track.copyrights.sort(({type}) => (type === 'P' ? -1 : 1))[0]?.text, // cprt | ||
encodingTool: `freyr-js cli v${packageJson.version}`, // ©too | ||
encodedBy: 'd3vc0dr', // ©enc | ||
artwork: files.image.file.path, // covr | ||
// sortOrder: [ | ||
// ['name', 'NAME'], // sonm | ||
// ['album', 'NAME'], // soal | ||
// ['artist', 'NAME'], // soar | ||
// ['albumartist', 'NAME'], // soaa | ||
// ], | ||
}); | ||
}, | ||
meta.outFile.path); | ||
} catch (err) { | ||
throw {err, [symbols.errorCode]: 8}; | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.