Fixed deduplication issues
This commit is contained in:
parent
0be87c4700
commit
de8c0a0880
@ -197,7 +197,18 @@ class MusicLibrary implements Initialisable
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Expensive call
|
// 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;
|
const { common } = metadata;
|
||||||
// Fall back to file and folder name if artist or title not available
|
// Fall back to file and folder name if artist or title not available
|
||||||
const segmets = fp.replace(this.#path, '').split(path.sep);
|
const segmets = fp.replace(this.#path, '').split(path.sep);
|
||||||
|
@ -71,6 +71,10 @@ class SpotifyDownloader extends Downloader
|
|||||||
if (!this.downloadDir)
|
if (!this.downloadDir)
|
||||||
throw new Error('No download directory defined');
|
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);
|
const match = url.match(/spotify\.com\/track\/(\w+)/u);
|
||||||
if (!match)
|
if (!match)
|
||||||
throw new MusicPlayerError('The bot will only process track URLs');
|
throw new MusicPlayerError('The bot will only process track URLs');
|
||||||
@ -177,7 +181,7 @@ class SpotifyDownloader extends Downloader
|
|||||||
if (!line)
|
if (!line)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
const elements = line.split('\t');
|
const elements = line.split('\t').map(str => str.trim());
|
||||||
const fileName = elements[elements.length - 1];
|
const fileName = elements[elements.length - 1];
|
||||||
return this.#parseFilename(fileName);
|
return this.#parseFilename(fileName);
|
||||||
}
|
}
|
||||||
@ -185,7 +189,7 @@ class SpotifyDownloader extends Downloader
|
|||||||
#parseFilename (fileName: string)
|
#parseFilename (fileName: string)
|
||||||
{
|
{
|
||||||
const [ name, ext ] = fileName.split('.');
|
const [ name, ext ] = fileName.split('.');
|
||||||
const [ artist, song, album ] = name.split('---');
|
const [ artist, song, album ] = name.split('---').map(str => str.trim());
|
||||||
return {
|
return {
|
||||||
fileName,
|
fileName,
|
||||||
artist,
|
artist,
|
||||||
|
Loading…
Reference in New Issue
Block a user