mirror of
https://github.com/markuryy/shark.git
synced 2025-12-15 04:41:01 +00:00
feat(dl): add metadata, lyrics, and cover art tagging
Introduce metadata handling for online downloads: - Embed cover art and lyrics (synced/unsynced) into MP3 files - Save cover art to album folders and .lrc lyric files as sidecars - Fetch and parse album/track metadata and lyrics from Deezer API - Add user settings for artwork and lyrics embedding, LRC export, and cover quality - Refactor queue manager to run continuously in background
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
import { deezerAPI } from '$lib/services/deezer';
|
||||
import { addToQueue } from '$lib/stores/downloadQueue';
|
||||
import { parseLyricsToLRC, parseLyricsToSYLT, parseLyricsText } from './tagger';
|
||||
|
||||
/**
|
||||
* Fetch track metadata and add to download queue
|
||||
@@ -19,7 +20,33 @@ export async function addDeezerTrackToQueue(trackId: string): Promise<void> {
|
||||
throw new Error('Track not found or invalid track ID');
|
||||
}
|
||||
|
||||
// Build track object
|
||||
// Fetch album data for cover art URLs
|
||||
let albumData = null;
|
||||
try {
|
||||
albumData = await deezerAPI.getAlbumData(trackInfo.ALB_ID.toString());
|
||||
} catch (error) {
|
||||
console.warn('[AddToQueue] Could not fetch album data:', error);
|
||||
}
|
||||
|
||||
// Fetch lyrics
|
||||
let lyricsData = null;
|
||||
try {
|
||||
lyricsData = await deezerAPI.getLyrics(trackInfo.SNG_ID.toString());
|
||||
} catch (error) {
|
||||
console.warn('[AddToQueue] Could not fetch lyrics:', error);
|
||||
}
|
||||
|
||||
// Parse lyrics if available
|
||||
let lyrics = undefined;
|
||||
if (lyricsData) {
|
||||
lyrics = {
|
||||
sync: parseLyricsToLRC(lyricsData),
|
||||
unsync: parseLyricsText(lyricsData),
|
||||
syncID3: parseLyricsToSYLT(lyricsData)
|
||||
};
|
||||
}
|
||||
|
||||
// Build track object with enhanced metadata
|
||||
const track = {
|
||||
id: trackInfo.SNG_ID,
|
||||
title: trackInfo.SNG_TITLE,
|
||||
@@ -36,10 +63,19 @@ export async function addDeezerTrackToQueue(trackId: string): Promise<void> {
|
||||
explicit: trackInfo.EXPLICIT_LYRICS === 1,
|
||||
md5Origin: trackInfo.MD5_ORIGIN,
|
||||
mediaVersion: trackInfo.MEDIA_VERSION,
|
||||
trackToken: trackInfo.TRACK_TOKEN
|
||||
trackToken: trackInfo.TRACK_TOKEN,
|
||||
// Enhanced metadata
|
||||
lyrics,
|
||||
albumCoverUrl: albumData?.ALB_PICTURE ? `https://e-cdns-images.dzcdn.net/images/cover/${albumData.ALB_PICTURE}/500x500-000000-80-0-0.jpg` : undefined,
|
||||
albumCoverXlUrl: albumData?.ALB_PICTURE ? `https://e-cdns-images.dzcdn.net/images/cover/${albumData.ALB_PICTURE}/1000x1000-000000-80-0-0.jpg` : undefined,
|
||||
label: albumData?.LABEL_NAME,
|
||||
barcode: albumData?.UPC,
|
||||
releaseDate: trackInfo.PHYSICAL_RELEASE_DATE,
|
||||
genre: trackInfo.GENRE ? [trackInfo.GENRE] : undefined,
|
||||
copyright: trackInfo.COPYRIGHT
|
||||
};
|
||||
|
||||
// Add to queue
|
||||
// Add to queue (queue manager runs continuously in background)
|
||||
await addToQueue({
|
||||
source: 'deezer',
|
||||
type: 'track',
|
||||
|
||||
Reference in New Issue
Block a user