allow processing to resume when rejecting

This commit is contained in:
Erik 2024-03-28 10:12:13 +02:00
parent 6efdbd88ea
commit a79d14bf3f

View File

@ -119,7 +119,10 @@ class SpotifyDownloader extends Downloader
childProcess.exec(`"${this.#executable}" --root-path "${this.downloadDir}" ${this.#options.join(' ')} ${url}`, (error, stdout, stderr) =>
{
if (error)
{
this.#processing = false;
return reject(error);
}
if (stderr && !stderr.includes('###'))
this.logger.debug('stderr', stderr);
@ -132,13 +135,19 @@ class SpotifyDownloader extends Downloader
this.logger.debug('Got ID mismatch, attempting to parse stdout to find filename');
const match = stdout.match(reg);
if (!match)
{
this.#processing = false;
return reject(new Error('Got bad output from zotify (could not find file name) and could not find by ID from cache file'));
}
const { file, name } = match.groups!;
fs.appendFileSync(path.join(this.downloadDir!, '.song_ids'), `${id}\t${(new Date()).toLocaleString('sv')}\t${name}\t${file}`);
data = this.#parseFilename(file);
}
if (!data)
{
this.#processing = false;
return reject(new Error('Failed to find file reference'));
}
const { fileName, artist, song, album, ext } = data;
const filePath = path.join(this.downloadDir!, fileName);