better path handling

This commit is contained in:
Austin Huang 2022-01-09 14:30:21 -05:00
parent fb8baf35f4
commit f197c47a06
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
2 changed files with 4 additions and 6 deletions

View File

@ -21,8 +21,8 @@ def get_timestamp_of_file(file):
def album(id):
req = IMAGE_CACHE
get("/a/" + id, req)
found_list_file = IMAGE_CACHE + ("/a/" + id).replace('/', '_')
get("a/" + id, req)
found_list_file = IMAGE_CACHE + ("a/" + id).replace('/', '_')
with open(found_list_file, 'r') as f:
imgs = f.read().split(',')

View File

@ -25,15 +25,13 @@ def error(msg):
def get(url: str, write_dir: str, delete=True):
orig_url = url
if not url.startswith('https://imgur.com/'):
url = 'https://imgur.com' + url
found_url = ''
found_urls = []
found_list_file = ''
url = 'https://imgur.com/' + url
album = False
if "gallery" in url:
url = url.replace("gallery", "a")
if "/a/" in url:
if url.startswith("https://imgur.com/a/"):
album = True
if not url.endswith("blog"):
url += "/layout/blog"