fix extension check

This commit is contained in:
Luna 2023-06-10 01:30:40 -03:00
parent 919bd4017e
commit f3ec3ab6d3

View file

@ -1,3 +1,4 @@
import os
import json
import aiohttp
import pprint
@ -187,6 +188,7 @@ async def download_images(ctx):
log.info("processing post %r", md5)
existing_post = await fetch_post(ctx, md5)
if existing_post:
log.info("already exists %r", md5)
continue
# download the post
@ -194,10 +196,10 @@ async def download_images(ctx):
post_url_path = Path(urlparse(post_file_url).path)
good_extension = False
for extension in ALLOWED_EXTENSIONS:
if extension in post_url_path.stem:
if extension in post_url_path.suffix:
good_extension = True
if not good_extension:
log.info("ignoring %r, invalid extension (%r)", md5, post_url_path.stem)
log.info("ignoring %r, invalid extension (%r)", md5, post_url_path.suffix)
continue
post_filename = post_url_path.name
post_filepath = DOWNLOADS / post_filename