Skip to content

Commit

Permalink
[joyreactor] try to prevent JsonDecodeErrors (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Nov 23, 2018
1 parent 503d42a commit bacbc2e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions gallery_dl/extractor/joyreactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,15 @@ def _pagination(self, url):
def _parse_post(post):
post, _, script = post.partition('<script type="application/ld+json">')
images = text.extract_iter(post, '<div class="image">', '</div>')
script = script[:script.index("</")].strip().replace("\\", "\\\\")
data = json.loads(script)
script = script[:script.index("</")].strip()

try:
data = json.loads(script)
except ValueError:
data = json.loads(script
.replace("\\", "\\\\")
.replace("\n", "")
.replace("\r", ""))

num = 0
date = data["datePublished"]
Expand Down

0 comments on commit bacbc2e

Please sign in to comment.