summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rwxr-xr-x[-rw-r--r--]chandl.py13
2 files changed, 15 insertions, 5 deletions
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 <board> <thread_id>`
+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
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: