diff options
Diffstat (limited to 'chandl.py')
-rwxr-xr-x[-rw-r--r--] | chandl.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/chandl.py b/chandl.py index d963378..76e96dc 100644..100755 --- a/chandl.py +++ b/chandl.py @@ -1,3 +1,5 @@ +#!/usr/bin/python + import argparse import os from pathlib import Path @@ -14,14 +16,14 @@ class Chandl: self.board = board self.thread_id = thread_id - self.output_path = output_path if output_path else f'data/{self.thread_id}/' + self.output_path = output_path if output_path else f'{str(Path.home())}/.chandl/data/{self.thread_id}/' self.output_path_exists = os.path.exists(self.output_path) self.quiet = quiet if self.quiet: sys.stdout = open(os.devnull, 'w') - self.log_path = f'logs/{thread_id}.pickle' + self.log_path = f'{str(Path.home())}/.chandl/logs/' self.delete_log = delete_log if self.delete_log: @@ -42,8 +44,9 @@ class Chandl: def serialize_log_file(self): print('Saving log file...') - with open(self.log_path, 'wb') as f: - self.downloaded_files = pickle.dump(self.downloaded_files, f) + Path(self.log_path).mkdir(parents=True) + with open(f'{self.log_path}{self.thread_id}.pickle', 'wb') as f: + pickle.dump(self.downloaded_files, f) def main(self): print(f'Logs currently contain {len(self.downloaded_files)} files...') @@ -82,7 +85,7 @@ class Chandl: resp = requests.get(file_path, stream=True) - full_file_path = f"{self.output_path}/{file_name}" + full_file_path = f"{self.output_path}{file_name}" print(f'Saving {file_name} to {full_file_path}...') with open(full_file_path, 'wb') as f: |