From fd8124eb1dc763012baa1f55c5efa3d42e118f8d Mon Sep 17 00:00:00 2001 From: Dominic DiTaranto Date: Tue, 30 Jul 2024 22:38:58 -0400 Subject: updating readme, updating to run as bin script, updating logging and data to go in hidden dir in home dir --- README.md | 7 +++++++ chandl.py | 13 ++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) mode change 100644 => 100755 chandl.py diff --git a/README.md b/README.md index 645d61d..4bf89ea 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,13 @@ 2. Create and activate virtual environment 3. install requirements.txt 4. `python3 chandl.py ` +5. ln -s full/path/to/chandl.py /usr/local/bin/chandl +6. chmod +x /usr/local/bin/chandl + 1. NOTE: This will create a log file in your bin folder, and a data directory if you do not specify a specific path! + +### Arch Installation +1. Clone Repository +2. pacman -S python-beautifulsoup4 python-requests ### Explanation of Arguments 1. `board` - the board the thread is on like `gif` , `pol` , `wsg` diff --git a/chandl.py b/chandl.py old mode 100644 new mode 100755 index d963378..76e96dc --- 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: -- cgit v1.2.3-70-g09d2