1
0
Fork 0
mirror of synced 2024-10-01 01:30:52 +13:00
bulk-downloader-for-reddit/bulkredditdownloader/downloaders/direct.py
2021-04-18 16:42:49 +03:00

17 lines
586 B
Python

import os
import pathlib
from bulkredditdownloader.downloaders.downloader_utils import getExtension, getFile
from bulkredditdownloader.utils import GLOBAL
class Direct:
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'])