️ create tmp folder if it does not exist

This commit is contained in:
Marc Koch 2021-09-02 16:17:07 +02:00
parent 12446bb04f
commit 1297e0376b
1 changed files with 7 additions and 0 deletions

View File

@ -41,6 +41,13 @@ class TazDownloader:
Downloads a newspaper from dl.taz.de and stores it in /tmp
"""
# Check if folder exists
try:
if not os.path.isdir(dir_path):
os.mkdirs(dir_path)
except Exception as e:
raise TazDownloadError(f"Could find or create \"{dir_path}\":\n{e}")
# download taz
try:
with requests.get(