Fixed deduplication issues

This commit is contained in:
Erik 2024-03-28 11:17:59 +02:00
parent 0be87c4700
commit de8c0a0880
2 changed files with 18 additions and 3 deletions

View File

@ -197,7 +197,18 @@ class MusicLibrary implements Initialisable
}
// Expensive call
const metadata = await parseFile(fp, { skipCovers: true });
let metadata = null;
try
{
metadata = await parseFile(fp, { skipCovers: true });
}
catch (err)
{
const error = err as Error;
if (!error.message.includes('MIME-type'))
this.#logger.error(error);
return;
}
const { common } = metadata;
// Fall back to file and folder name if artist or title not available
const segmets = fp.replace(this.#path, '').split(path.sep);

View File

@ -71,6 +71,10 @@ class SpotifyDownloader extends Downloader
if (!this.downloadDir)
throw new Error('No download directory defined');
const songIds = path.join(this.downloadDir!, '.song_ids');
if (!fs.existsSync(songIds))
fs.writeFileSync(songIds, '');
const match = url.match(/spotify\.com\/track\/(\w+)/u);
if (!match)
throw new MusicPlayerError('The bot will only process track URLs');
@ -177,7 +181,7 @@ class SpotifyDownloader extends Downloader
if (!line)
return null;
const elements = line.split('\t');
const elements = line.split('\t').map(str => str.trim());
const fileName = elements[elements.length - 1];
return this.#parseFilename(fileName);
}
@ -185,7 +189,7 @@ class SpotifyDownloader extends Downloader
#parseFilename (fileName: string)
{
const [ name, ext ] = fileName.split('.');
const [ artist, song, album ] = name.split('---');
const [ artist, song, album ] = name.split('---').map(str => str.trim());
return {
fileName,
artist,