mirror of
https://github.com/d-fi/d-fi-core.git
synced 2025-07-25 06:35:44 +02:00
improve album matching
This commit is contained in:
parent
15a126cbdb
commit
8ca5b08ac7
@ -2,9 +2,18 @@ import {downloadAlbumCover} from './abumCover';
|
|||||||
import {getTrackLyrics} from './getTrackLyrics';
|
import {getTrackLyrics} from './getTrackLyrics';
|
||||||
import {writeMetadataMp3} from './id3';
|
import {writeMetadataMp3} from './id3';
|
||||||
import {writeMetadataFlac} from './flacmetata';
|
import {writeMetadataFlac} from './flacmetata';
|
||||||
import {getAlbumInfoPublicApi} from '../api';
|
import {getAlbumInfoPublicApi, getTrackInfoPublicApi} from '../api';
|
||||||
import type {trackType} from '../types';
|
import type {trackType} from '../types';
|
||||||
|
|
||||||
|
const albumInfo = async (track: trackType) => {
|
||||||
|
try {
|
||||||
|
return getAlbumInfoPublicApi(track.ALB_ID);
|
||||||
|
} catch (err) {
|
||||||
|
const {album} = await getTrackInfoPublicApi(track.SNG_ID);
|
||||||
|
return getAlbumInfoPublicApi(album.id.toString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add metdata to the mp3
|
* Add metdata to the mp3
|
||||||
* @param {Buffer} trackBuffer decrypted track buffer
|
* @param {Buffer} trackBuffer decrypted track buffer
|
||||||
@ -15,7 +24,7 @@ export const addTrackTags = async (trackBuffer: Buffer, track: trackType, albumC
|
|||||||
const [cover, lyrics, album] = await Promise.all([
|
const [cover, lyrics, album] = await Promise.all([
|
||||||
downloadAlbumCover(track, albumCoverSize),
|
downloadAlbumCover(track, albumCoverSize),
|
||||||
getTrackLyrics(track),
|
getTrackLyrics(track),
|
||||||
getAlbumInfoPublicApi(track.ALB_ID),
|
albumInfo(track),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (lyrics) {
|
if (lyrics) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user