commit 3f4fa3c10d5431964b64442a669b0e62dc1aa6ba Author: Kris Lamoureux Date: Mon Sep 2 22:33:56 2024 -0400 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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..579f19b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +config.ini +venv diff --git a/main.py b/main.py new file mode 100644 index 0000000..0d61449 --- /dev/null +++ b/main.py @@ -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) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1ab3894 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +python-qbittorrent==0.4.3 diff --git a/tarch b/tarch new file mode 100755 index 0000000..423035b --- /dev/null +++ b/tarch @@ -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