Skip to content
This repository has been archived by the owner on Feb 6, 2021. It is now read-only.

Commit

Permalink
[Hotfix] Fix crash when a 'post' is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
M-rcus committed Mar 26, 2020
1 parent 67560aa commit acdf33e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
13 changes: 12 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const cli = meow(
flags: {
userAgent: {
type: 'string',
default: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0',
default: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0',
},
output: {
type: 'string',
Expand Down Expand Up @@ -281,6 +281,17 @@ const maxNameLength = 60;
}

const parsedPost = allPosts[postId];

/**
* Hotfix for posts that can't be parsed due to being "undefined".
* For now it's unclear to me why this is the case, but it seems to be rare
* so I'm just skipping these posts for now.
*/
if (!parsedPost) {
signale.warn(`Could not parse post wih ID: ${postId} -- Skipping.`);
continue;
}

const postMedia = parsedPost.querySelector('.card-attachments');
if (postMedia) {
const title = postMedia.querySelector('.card-title');
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yiff-dl",
"version": "1.2.0",
"version": "1.2.1",
"description": "Downloads files from creators on Yiff",
"main": "index.js",
"scripts": {
Expand All @@ -21,7 +21,7 @@
"filenamify": "^4.1.0",
"jsdom": "^15.2.1",
"meow": "^5.0.0",
"node-html-parser": "^1.2.12",
"node-html-parser": "^1.2.13",
"progress": "^2.0.3",
"signale": "^1.4.0"
},
Expand Down

0 comments on commit acdf33e

Please sign in to comment.