Skip to content

Commit

Permalink
fix: adjust parse_image_danbooru
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkaroid committed Dec 6, 2022
1 parent 2b7b37e commit 2ea04d1
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions booru/utils/parser.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import json
import re
from random import sample
from booru import __version__
from xmltodict import parse
from requests import get


class Api:
Expand Down Expand Up @@ -200,3 +197,31 @@ def resolve(b_object: dict) -> dict:
raw json object
"""
return json.loads(b_object)

def parse_image_danbooru(raw_object: dict) -> list:
"""Smh, it's danbooru though
Parameters
----------
raw_object : dict
The object to be parsed.
Returns
-------
list
The list of image urls.
"""

image = []

try:
for i in raw_object:
image.append(i["file_url"])
return image
except KeyError:
for i in raw_object:
try:
image.append(i["file_url"])
except KeyError:
pass
return image

0 comments on commit 2ea04d1

Please sign in to comment.