diff options
-rwxr-xr-x | grab-queue | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -27,6 +27,7 @@ import argparse import sys, os, subprocess, json import yaml from urllib.parse import urlencode +from urllib.parse import urlparse from hashlib import sha256 from tqdm import tqdm @@ -64,13 +65,18 @@ class DownloadMultiple: if self.debug: print('Downloading ' + url + '...') + domain = urlparse(url).netloc + # Heuristics to check if dest is a folder if local_filename[-1] == '/': folder = local_filename - log_sep = '/' + log_sep = '../logs/' else: folder = os.path.dirname(local_filename) - log_sep = '.' + log_sep = '' + + with open(log_sep + 'grab-queue.log', "a") as log: + log.write('Downloading ' + url + '...') self.ensuredir(local_filename) @@ -89,7 +95,7 @@ class DownloadMultiple: stdout, stderr = await proc.communicate() if stdout: - output = open(local_filename + log_sep + 'stdout', 'w') + output = open(local_filename + log_sep + domain + '.stdout', 'w') output.write(stdout.decode()) output.close() @@ -97,18 +103,18 @@ class DownloadMultiple: print(f'[stdout] {url} {stdout.decode()}') if stderr: - output = open(local_filename + log_sep + 'stderr', 'w') + output = open(local_filename + log_sep + domain + '.stderr', 'w') output.write(stderr.decode()) output.close() if self.debug: print(f'[stderr] {url} {stderr.decode()}') - output = open(local_filename + log_sep + 'returncode', 'w') + output = open(local_filename + log_sep + domain + '.returncode', 'w') output.write(str(proc.returncode) + '\n') output.close() - output = open(local_filename + log_sep + 'date', 'w') + output = open(local_filename + log_sep + domain + '.date', 'w') output.write(str(datetime.datetime.now()) + '\n') output.close() |