Fixed bug when searching for existing songs whose name contains a period

This commit is contained in:
Erik 2024-04-14 11:38:48 +03:00
parent 494862c93f
commit d6c131fe2e

View File

@ -188,8 +188,11 @@ class SpotifyDownloader extends Downloader
#parseFilename (fileName: string) #parseFilename (fileName: string)
{ {
const [ name, ext ] = fileName.split('.'); const match = fileName.match(/(?<artist>.+)\W---\W(?<song>.+)\W---\W(?<album>.+)(?<ext>\.\w+)$/u);
const [ artist, song, album ] = name.split('---').map(str => str.trim()); if (!match || !match.groups)
throw new Error('Unknown file name format');
const { artist, song, album, ext } = match.groups;
return { return {
fileName, fileName,
artist, artist,