1
0
Fork 0
mirror of synced 2024-09-30 09:06:54 +13:00
bulk-downloader-for-reddit/src/downloaders/Direct.py

18 lines
551 B
Python
Raw Normal View History

import os
2021-02-07 01:29:13 +13:00
import pathlib
from src.downloaders.downloaderUtils import getExtension, getFile
from src.utils import GLOBAL
class Direct:
2021-02-07 01:29:13 +13:00
def __init__(self, directory: pathlib.Path, post: dict):
post['EXTENSION'] = getExtension(post['CONTENTURL'])
if not os.path.exists(directory):
os.makedirs(directory)
filename = GLOBAL.config['filename'].format(**post) + post["EXTENSION"]
short_filename = post['POSTID'] + post['EXTENSION']
getFile(filename, short_filename, directory, post['CONTENTURL'])