Set up the initial project structure

- Create a bash script to set up a virtual environment
- Implement config.ini loading with debug option
- Create a basic torrent listing and slow print functionality
This commit is contained in:
Kris Lamoureux 2024-09-02 22:33:56 -04:00
commit 3f4fa3c10d
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
4 changed files with 43 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
config.ini
venv

22
main.py Normal file
View File

@ -0,0 +1,22 @@
import configparser
import qbittorrent
import time
# Load config
config = configparser.ConfigParser()
config.read("config.ini")
qbittorrent_client = config["DEFAULT"]["QBITTORRENT_CLIENT"]
debug = config["DEFAULT"].getboolean("DEBUG")
# Connect to qbittorrent
qb = qbittorrent.Client(qbittorrent_client)
torrents = qb.torrents()
# Debug info
if debug:
print(f"[DEBUG]: There are {len(torrents)} torrents")
# List torrents
for torrent in torrents:
print(torrent["name"])
time.sleep(2)

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
python-qbittorrent==0.4.3

18
tarch Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
# Create a virtual environment if it does not exist
if [ ! -d "venv" ]; then
python3 -m venv venv && \
source venv/bin/activate && \
pip install -r requirements.txt && \
deactivate
fi
# Activate the virtual environment
source venv/bin/activate
# Run the Python script
python main.py "$@"
# Deactivate the virtual environment
deactivate