Fixed an issue where the downloader would crash

This commit is contained in:
Izuco 2021-11-23 19:07:59 +01:00
parent 0d051ac94d
commit 3ae1269ac7
No known key found for this signature in database
GPG key ID: 318460063D70949F
3 changed files with 6 additions and 4 deletions

View file

@ -70,9 +70,11 @@ const downloaded = (kind: {
service: 'crunchy',
type: 's'|'srz'
}, ID: string, episode: string[]) => {
const data = loadData();
if (!Object.prototype.hasOwnProperty.call(data, kind.service))
let data = loadData();
if (!Object.prototype.hasOwnProperty.call(data, kind.service)) {
addToArchive(kind, ID);
data = loadData(); // Load updated version
}
(kind.service == 'crunchy' ? data[kind.service][kind.type] : data[kind.service][kind.type]).find(a => a.id === ID)?.already.push(...episode);
fs.writeFileSync(archiveFile, JSON.stringify(data, null, 4));
};

2
package-lock.json generated
View file

@ -1,6 +1,6 @@
{
"name": "multi-downloader-nx",
"version": "2.0.2",
"version": "2.0.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View file

@ -1,7 +1,7 @@
{
"name": "multi-downloader-nx",
"short_name": "aniDL",
"version": "2.0.2",
"version": "2.0.3",
"description": "Download videos from Funimation or Crunchyroll via cli",
"keywords": [
"download",