Skip to content

Commit d551f77

Browse files
committed
Fix miraclx#334: Replace AtomicParsley with lofty-rs.
1 parent 3861d07 commit d551f77

File tree

6 files changed

+1498
-4518
lines changed

6 files changed

+1498
-4518
lines changed

Dockerfile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ RUN apk add --no-cache git g++ make cmake linux-headers
1212
COPY --from=installer /freyr/node_modules /freyr/node_modules
1313
RUN go install github.com/tj/node-prune@1159d4c \
1414
&& node-prune --include '*.map' /freyr/node_modules \
15-
&& node-prune /freyr/node_modules \
16-
# todo! revert to upstream when https://github.com/wez/atomicparsley/pull/63 is merged and a release is cut
17-
&& git clone --branch 20230114.175602.21bde60 --depth 1 https://github.com/miraclx/atomicparsley /atomicparsley \
18-
&& cmake -S /atomicparsley -B /atomicparsley \
19-
&& cmake --build /atomicparsley --config Release
15+
&& node-prune /freyr/node_modules
2016

2117
FROM alpine:3.18.3 as base
2218

@@ -25,7 +21,6 @@ RUN apk add --no-cache bash nodejs python3 \
2521
&& find /usr/lib/python3* \
2622
\( -type d -name __pycache__ -o -type f -name '*.whl' \) \
2723
-exec rm -r {} \+
28-
COPY --from=prep /atomicparsley/AtomicParsley /bin/AtomicParsley
2924

3025
COPY . /freyr
3126
COPY --from=prep /freyr/node_modules /freyr/node_modules

README.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -129,27 +129,6 @@ Here's a list of the metadata that freyr can extract from each streaming service
129129

130130
</details>
131131

132-
<details>
133-
<summary>AtomicParsley >= 20230114</summary>
134-
135-
First, download the latest release for your individual platforms here <https://github.com/miraclx/atomicparsley/releases/latest>
136-
137-
Then;
138-
139-
- Windows:
140-
- unzip and place the `AtomicParsley.exe` in your `PATH`.
141-
- or the `bins/windows` folder of this project directory. Create the folder(s) if they don't exist.
142-
- Linux + macOS:
143-
- unzip and place the `AtomicParsley` in your `PATH`.
144-
- or the `bins/posix` folder of this project directory. Create the folder(s) if they don't exist.
145-
- Alternatively:
146-
- Debian: `sudo apt-get install atomicparsley`
147-
- Arch Linux: `sudo pacman -S atomicparsley`
148-
- Android (Termux): `apt install atomicparsley`
149-
- Build from source: See [wez/AtomicParsley](https://github.com/miraclx/atomicparsley)
150-
151-
</details>
152-
153132
> _Please note that [YouTube Music](https://music.youtube.com/) must be available in your region for freyr to successfully work, this is because freyr sources raw audio from [YouTube Music](https://music.youtube.com/)._
154133
155134
---
@@ -305,7 +284,6 @@ Options:
305284

306285
Environment Variables:
307286
SHOW_DEBUG_STACK show extended debug information
308-
ATOMIC_PARSLEY_PATH custom AtomicParsley path, alternatively use `--atomic-parsley`
309287

310288
Info:
311289
When downloading playlists, the tracks are downloaded individually into

cli.js

Lines changed: 34 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {program as commander} from 'commander';
2828
import {decode as entityDecode} from 'html-entities';
2929
import {createFFmpeg, fetchFile} from '@ffmpeg/ffmpeg';
3030
import ProgressBar, {getPersistentStdout} from 'xprogress';
31+
import meta_writer from '@orsetto/meta-writer';
3132

3233
import _merge from 'lodash.merge';
3334
import _mergeWith from 'lodash.mergewith';
@@ -758,22 +759,6 @@ async function init(packageJson, queries, options) {
758759
),
759760
);
760761

761-
let atomicParsley;
762-
763-
try {
764-
let atomicParsleyPath = options.atomicParsley || process.env.ATOMIC_PARSLEY_PATH;
765-
if (atomicParsleyPath) {
766-
if (!(await maybeStat(atomicParsleyPath)))
767-
throw new Error(`\x1b[31mAtomicParsley\x1b[0m: Binary not found [${options.atomicParsley}]`);
768-
if (!(await isBinaryFile(atomicParsleyPath)))
769-
stackLogger.warn('\x1b[33mAtomicParsley\x1b[0m: Detected non-binary file, trying anyways...');
770-
}
771-
atomicParsley = wrapCliInterface(['AtomicParsley', 'atomicparsley'], atomicParsleyPath);
772-
} catch (err) {
773-
stackLogger.error(err.message);
774-
process.exit(7);
775-
}
776-
777762
async function createPlaylist(header, stats, logger, filename, playlistTitle, shouldAppend) {
778763
if (options.playlist !== false) {
779764
const validStats = stats.filter(stat => (stat[symbols.errorCode] === 0 ? stat.complete : !stat[symbols.errorCode]));
@@ -1096,56 +1081,58 @@ async function init(packageJson, queries, options) {
10961081
Config.concurrency.embedder,
10971082
async ({track, meta, files, audioSource}) => {
10981083
try {
1099-
await Promise.promisify(atomicParsley)(meta.outFile.path, {
1084+
await meta_writer({
11001085
overWrite: '', // overwrite the file
11011086

1102-
title: track.name, // ©nam
1103-
artist: track.artists[0], // ©ART
1104-
composer: track.composers, // ©wrt
1105-
album: track.album, // ©alb
1106-
genre: (genre => (genre ? genre.concat(' ') : ''))((track.genres || [])[0]), // ©gen | gnre
1107-
tracknum: `${track.track_number}/${track.total_tracks}`, // trkn
1108-
disk: `${track.disc_number}/${track.disc_number}`, // disk
1109-
year: new Date(track.release_date).toISOString().split('T')[0], // ©day
1110-
compilation: track.compilation, // ©cpil
1111-
gapless: options.gapless, // pgap
1112-
rDNSatom: [
1087+
TrackTitle: track.name, // ©nam
1088+
TrackArtist: track.artists[0], // ©ART
1089+
Composer: track.composers, // ©wrt
1090+
AlbumTitle: track.album, // ©alb
1091+
Genre: (genre => (genre ? genre.concat(' ') : ''))((track.genres || [''])[0]), // ©gen | gnre
1092+
TrackNumber: `${track.track_number}`, // trkn
1093+
TrackTotal: `${track.total_tracks}`,
1094+
DiscNumber: `${track.disc_number}`, // disk
1095+
DiscTotal: `${track.disc_number}`,
1096+
RecordingDate: new Date(track.release_date).toISOString().split('T')[0], // ©day
1097+
1098+
AlbumArtist: track.album_artist, // aART
1099+
CopyrightMessage: track.copyrights.sort(({type}) => (type === 'P' ? -1 : 1))[0]?.text, // cprt
1100+
EncoderSoftware: `freyr-js cli v${packageJson.version}`, // ©too
1101+
EncodedBy: 'd3vc0dr', // ©enc
1102+
FrontCover: files.image.file.path, // covr
1103+
1104+
// Ilst tags
1105+
'cpil': track.compilation, // cpil
1106+
stik: 'Normal', // stik
1107+
pgap: options.gapless, // pgap
1108+
rDNS: [
11131109
// ----
1114-
['Digital Media', 'name=MEDIA', 'domain=com.apple.iTunes'],
1115-
[track.isrc, 'name=ISRC', 'domain=com.apple.iTunes'],
1116-
[track.artists[0], 'name=ARTISTS', 'domain=com.apple.iTunes'],
1117-
[track.label, 'name=LABEL', 'domain=com.apple.iTunes'],
1118-
[`${meta.service[symbols.meta].DESC}: ${track.uri}`, 'name=SOURCE', 'domain=com.apple.iTunes'],
1119-
[
1120-
`${audioSource.service[symbols.meta].DESC}: ${audioSource.source.videoId}`,
1121-
'name=PROVIDER',
1122-
'domain=com.apple.iTunes',
1123-
],
1110+
{mean: 'com.apple.iTunes', name: 'MEDIA', data: 'Digital Media' },
1111+
{mean: 'com.apple.iTunes', name: 'ISRC', data: track.isrc },
1112+
{mean: 'com.apple.iTunes', name: 'ARTISTS', data: track.artists[0] },
1113+
{mean: 'com.apple.iTunes', name: 'LABEL', data: track.label },
1114+
{mean: 'com.apple.iTunes', name: 'SOURCE', data: `${meta.service[symbols.meta].DESC}: ${track.uri}` },
1115+
{mean: 'com.apple.iTunes', name: 'PROVIDER', data: `${audioSource.service[symbols.meta].DESC}: ${audioSource.source.videoId}` }
11241116
],
1125-
advisory: ['explicit', 'clean'].includes(track.contentRating) // rtng
1117+
ParentalAdvisory: ['explicit', 'clean'].includes(track.contentRating) // rtng
11261118
? track.contentRating
11271119
: track.contentRating === true
11281120
? 'explicit'
11291121
: 'Inoffensive',
1130-
stik: 'Normal', // stik
11311122
// geID: 0, // geID: genreID. See `AtomicParsley --genre-list`
11321123
// sfID: 0, // ~~~~: store front ID
11331124
// cnID: 0, // cnID: catalog ID
1134-
albumArtist: track.album_artist, // aART
11351125
// ownr? <owner>
1136-
purchaseDate: 'timestamp', // purd
1126+
purd: 'timestamp', // purd
11371127
apID: 'cli@freyr.git', // apID
1138-
copyright: track.copyrights.sort(({type}) => (type === 'P' ? -1 : 1))[0]?.text, // cprt
1139-
encodingTool: `freyr-js cli v${packageJson.version}`, // ©too
1140-
encodedBy: 'd3vc0dr', // ©enc
1141-
artwork: files.image.file.path, // covr
11421128
// sortOrder: [
11431129
// ['name', 'NAME'], // sonm
11441130
// ['album', 'NAME'], // soal
11451131
// ['artist', 'NAME'], // soar
11461132
// ['albumartist', 'NAME'], // soaa
11471133
// ],
1148-
});
1134+
},
1135+
meta.outFile.path);
11491136
} catch (err) {
11501137
throw {err, [symbols.errorCode]: 8};
11511138
}
@@ -1886,7 +1873,6 @@ function prepCli(packageJson) {
18861873
console.log('');
18871874
console.log('Environment Variables:');
18881875
console.log(' SHOW_DEBUG_STACK show extended debug information');
1889-
console.log(' ATOMIC_PARSLEY_PATH custom AtomicParsley path, alternatively use `--atomic-parsley`');
18901876
console.log('');
18911877
console.log('Info:');
18921878
console.log(' When downloading playlists, the tracks are downloaded individually into');

0 commit comments

Comments
 (0)