fix extension check
This commit is contained in:
parent
919bd4017e
commit
f3ec3ab6d3
6
main.py
6
main.py
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
import json
|
import json
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import pprint
|
import pprint
|
||||||
|
@ -187,6 +188,7 @@ async def download_images(ctx):
|
||||||
log.info("processing post %r", md5)
|
log.info("processing post %r", md5)
|
||||||
existing_post = await fetch_post(ctx, md5)
|
existing_post = await fetch_post(ctx, md5)
|
||||||
if existing_post:
|
if existing_post:
|
||||||
|
log.info("already exists %r", md5)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# download the post
|
# download the post
|
||||||
|
@ -194,10 +196,10 @@ async def download_images(ctx):
|
||||||
post_url_path = Path(urlparse(post_file_url).path)
|
post_url_path = Path(urlparse(post_file_url).path)
|
||||||
good_extension = False
|
good_extension = False
|
||||||
for extension in ALLOWED_EXTENSIONS:
|
for extension in ALLOWED_EXTENSIONS:
|
||||||
if extension in post_url_path.stem:
|
if extension in post_url_path.suffix:
|
||||||
good_extension = True
|
good_extension = True
|
||||||
if not good_extension:
|
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
|
continue
|
||||||
post_filename = post_url_path.name
|
post_filename = post_url_path.name
|
||||||
post_filepath = DOWNLOADS / post_filename
|
post_filepath = DOWNLOADS / post_filename
|
||||||
|
|
Loading…
Reference in New Issue