Skip to content

Commit

Permalink
Fixed bug with invalide image links for files containing " symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
OlehOnyshchak committed May 3, 2020
1 parent de9d89b commit 0fa7cd5
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,10 @@ def _get_description(img):
return parser.get_description().replace("\n", "")

def _get_img_path(img, img_dir):
img_name = img.title(as_filename=True, with_ns=False).replace("\"", "")
img_name = unquote(img.title(with_ns=False, as_url=True))
img_name_valid = hashlib.md5(img_name.encode('utf-8')).hexdigest()
img_path = img_dir / (img_name_valid + ".jpg")

img_path_orig = Path(str(img_path) + "_" + Path(img_name).suffix + ".ORIGINAL")
# img_path_orig = Path(str(img_path) + "_" + img_name + ".ORIGINAL")
# if len(str(img_path_orig).encode('utf-8')) >= 260:
# # pathlib doesn't support Win long path =(
# img_path_orig = Path(str(img_path) + "_" + Path(img_name).suffix + ".ORIGINAL")
img_path_orig = Path(str(img_path) + "_" + Path(img_name).suffix + ".ORIGINAL")

return img_name, img_path, img_path_orig

Expand Down

0 comments on commit 0fa7cd5

Please sign in to comment.