Skip to content

Commit 53666d1

Browse files
committed
refactor
1 parent dce87e3 commit 53666d1

File tree

14 files changed

+1070
-907
lines changed

14 files changed

+1070
-907
lines changed

.env.example

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# Telegram bot token (format: numbers:letters-and-numbers)
2-
TELEGRAM_TOKEN=123456789:ABCdefGHIjklMNOpqrsTUVwxyz1234567
3-
4-
# Authentication password for users (any string)
5-
PASSWORD=your_secure_password
6-
7-
# Comma-separated list of admin Telegram user IDs (numbers only)
8-
ADMINS=123456789,987654321
9-
10-
# Jackett configuration
11-
JACKETT_API_KEY=your_jackett_api_key
12-
JACKETT_URL=http://your.jackett.url:port
13-
JACKETT_URL_SEARCH=/api/v2.0/indexers/all/results
14-
15-
# ruTorrent configuration
16-
RU_TORRENT_URL=https://your.rutorrent.url/rutorrent/php/addtorrent.php
1+
# Telegram bot token (format: numbers:letters-and-numbers)
2+
TELEGRAM_TOKEN=123456789:ABCdefGHIjklMNOpqrsTUVwxyz1234567
3+
4+
# Authentication password for users (any string)
5+
PASSWORD=your_secure_password
6+
7+
# Comma-separated list of admin Telegram user IDs (numbers only)
8+
ADMINS=123456789,987654321
9+
10+
# Jackett configuration
11+
JACKETT_API_KEY=your_jackett_api_key
12+
JACKETT_URL=http://your.jackett.url:port
13+
JACKETT_URL_SEARCH=/api/v2.0/indexers/all/results
14+
15+
# ruTorrent configuration
16+
RU_TORRENT_URL=https://your.rutorrent.url/rutorrent/php/addtorrent.php
1717
RU_TORRENT_TOKEN=base64_encoded_credentials

.github/workflows/python-tests.yml

Lines changed: 51 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,51 @@
1-
name: Python Tests
2-
3-
on:
4-
pull_request:
5-
push:
6-
branches:
7-
- main
8-
workflow_dispatch:
9-
10-
jobs:
11-
test:
12-
runs-on: ubuntu-latest
13-
14-
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v3
17-
18-
- name: Set up Python
19-
uses: actions/setup-python@v4
20-
with:
21-
python-version: 3.9
22-
23-
- name: Install dependencies
24-
run: |
25-
python -m venv venv
26-
source venv/bin/activate
27-
python -m pip install --upgrade pip
28-
pip install -r requirements.txt
29-
30-
- name: Prepare environment
31-
run: |
32-
cp .env.example .env
33-
34-
- name: Run tests
35-
run: |
36-
source venv/bin/activate
37-
pytest
38-
1+
name: Python Tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.12'
22+
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v4
25+
with:
26+
version: "latest"
27+
28+
- name: Install dependencies
29+
run: |
30+
uv sync --dev
31+
32+
- name: Prepare environment
33+
run: |
34+
cp .env.example .env
35+
36+
- name: Run tests
37+
run: |
38+
uv run pytest
39+
40+
- name: Run linting
41+
run: |
42+
uv run ruff check .
43+
44+
- name: Run formatting check
45+
run: |
46+
uv run ruff format --check .
47+
48+
- name: Run type checking
49+
run: |
50+
uv run mypy .
51+

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
.env
2-
.venv
3-
users.json
1+
.env
2+
.venv
3+
users.json

.pre-commit-config.yaml

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,21 @@
1-
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
4-
hooks:
5-
- id: trailing-whitespace
6-
- id: end-of-file-fixer
7-
- id: check-yaml
8-
- id: debug-statements
9-
- id: double-quote-string-fixer
10-
- id: name-tests-test
11-
- repo: https://github.com/asottile/reorder_python_imports
12-
rev: v3.9.0
13-
hooks:
14-
- id: reorder-python-imports
15-
args: [--py37-plus, --add-import, "from __future__ import annotations"]
16-
- repo: https://github.com/asottile/add-trailing-comma
17-
rev: v2.4.0
18-
hooks:
19-
- id: add-trailing-comma
20-
args: [--py36-plus]
21-
- repo: https://github.com/asottile/pyupgrade
22-
rev: v3.3.2
23-
hooks:
24-
- id: pyupgrade
25-
args: [--py37-plus]
26-
- repo: https://github.com/pre-commit/mirrors-autopep8
27-
rev: v2.0.2
28-
hooks:
29-
- id: autopep8
30-
- repo: https://github.com/PyCQA/flake8
31-
rev: 6.0.0
32-
hooks:
33-
- id: flake8
34-
args:
35-
- --max-line-length=120
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: debug-statements
9+
- id: name-tests-test
10+
- repo: https://github.com/astral-sh/ruff-pre-commit
11+
rev: v0.7.4
12+
hooks:
13+
- id: ruff
14+
args: [--fix]
15+
- id: ruff-format
16+
- repo: https://github.com/pre-commit/mirrors-mypy
17+
rev: v1.13.0
18+
hooks:
19+
- id: mypy
20+
additional_dependencies: [types-requests]
21+
args: [--ignore-missing-imports]

README.md

Lines changed: 69 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,70 @@
1-
# Plex Search Search Bot Simple [![Tests](https://github.com/thomasasfk/PlexSearchBotSimple/actions/workflows/python-tests.yml/badge.svg)](https://github.com/thomasasfk/PlexSearchBotSimple/actions/workflows/python-tests.yml)
2-
3-
A Telegram bot that searches Jackett indexers and uploads to rTorrent. Despite the repository name, this has no Plex integration.
4-
5-
## Commands
6-
7-
| Command | Description | Example | Access Level |
8-
|---------|-------------|---------|--------------|
9-
| `/auth [password]` | Authenticate with the bot | `/auth mypassword` | Anyone |
10-
| `/search [term]` | Search for content | `/search arcane` | Authenticated Users |
11-
| `/get[id]` | Download from a search result | `/get14492` | Authenticated Users |
12-
| `/download [magnet]` | Download using magnet link | `/download magnet:?xt=...` | Authenticated Users |
13-
| `/space` | Check home directory size | `/space` | Authenticated Users |
14-
| `/spaceforce` | Force refresh space calculation | `/spaceforce` | Authenticated Users |
15-
| `/sh [command]` | Execute shell commands | `/sh ls -la` | Admins |
16-
17-
## Setup
18-
19-
1. **Install Python 3.9.2** (pyenv recommended)
20-
21-
2. **Configure Environment**
22-
```bash
23-
cp .env.example .env
24-
# Edit .env with your settings
25-
```
26-
27-
3. **Install Requirements**
28-
```bash
29-
python -m venv .venv
30-
. .venv/bin/activate
31-
python -m pip install -r requirements.txt
32-
```
33-
34-
4. **Run**
35-
```bash
36-
python main.py
37-
```
38-
39-
## Environment Configuration
40-
41-
Create a `.env` file with the following variables:
42-
43-
```bash
44-
# Bot configuration
45-
PASSWORD=your_password_here
46-
TELEGRAM_TOKEN=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz123456
47-
ADMINS=123456789
48-
49-
# Jackett configuration
50-
JACKETT_API_KEY=abcdef1234567890abcdef1234567890
51-
JACKETT_URL=http://your.jackett.host:port
52-
JACKETT_URL_SEARCH=/your/jackett/api/v2.0/indexers/all/results
53-
54-
# ruTorrent configuration
55-
RU_TORRENT_URL=https://your.rutorrent.host/user/rutorrent/php/addtorrent.php
56-
RU_TORRENT_TOKEN=base64_encoded_credentials
57-
```
58-
59-
| Variable | Description |
60-
|----------|-------------|
61-
| `PASSWORD` | Bot authentication password |
62-
| `TELEGRAM_TOKEN` | Get from [@BotFather](https://t.me/botfather) |
63-
| `ADMINS` | Your Telegram user ID for admin access |
64-
| `JACKETT_API_KEY` | Found in Jackett dashboard |
65-
| `JACKETT_URL` | Your Jackett instance URL with port |
66-
| `JACKETT_URL_SEARCH` | Jackett API endpoint path |
67-
| `RU_TORRENT_URL` | Full path to ruTorrent addtorrent.php |
1+
mnvm, its `/# Plex Search Search Bot Simple [![Tests](https://github.com/thomasasfk/PlexSearchBotSimple/actions/workflows/python-tests.yml/badge.svg)](https://github.com/thomasasfk/PlexSearchBotSimple/actions/workflows/python-tests.yml)
2+
3+
A Telegram bot that searches Jackett indexers and uploads to rTorrent. Despite the repository name, this has no Plex integration.
4+
5+
## Commands
6+
7+
| Command | Description | Example | Access Level |
8+
|---------|-------------|---------|--------------|
9+
| `/auth [password]` | Authenticate with the bot | `/auth mypassword` | Anyone |
10+
| `/search [term]` | Search for content | `/search arcane` | Authenticated Users |
11+
| `/get[id]` | Download from a search result | `/get14492` | Authenticated Users |
12+
| `/download [magnet]` | Download using magnet link | `/download magnet:?xt=...` | Authenticated Users |
13+
| `/space` | Check home directory size | `/space` | Authenticated Users |
14+
| `/spaceforce` | Force refresh space calculation | `/spaceforce` | Authenticated Users |
15+
16+
## Setup
17+
18+
1. **Install Python 3.12+** and uv package manager
19+
```bash
20+
# Install uv
21+
curl -LsSf https://astral.sh/uv/install.sh | sh
22+
```
23+
24+
2. **Configure Environment**
25+
```bash
26+
cp .env.example .env
27+
# Edit .env with your settings
28+
```
29+
30+
3. **Install Requirements**
31+
```bash
32+
# Install dependencies (creates virtual environment automatically)
33+
uv sync --dev
34+
```
35+
36+
4. **Run**
37+
```bash
38+
uv run python main.py
39+
```
40+
41+
## Environment Configuration
42+
43+
Create a `.env` file with the following variables:
44+
45+
```bash
46+
# Bot configuration
47+
PASSWORD=your_password_here
48+
TELEGRAM_TOKEN=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz123456
49+
ADMINS=123456789
50+
51+
# Jackett configuration
52+
JACKETT_API_KEY=abcdef1234567890abcdef1234567890
53+
JACKETT_URL=http://your.jackett.host:port
54+
JACKETT_URL_SEARCH=/your/jackett/api/v2.0/indexers/all/results
55+
56+
# ruTorrent configuration
57+
RU_TORRENT_URL=https://your.rutorrent.host/user/rutorrent/php/addtorrent.php
58+
RU_TORRENT_TOKEN=base64_encoded_credentials
59+
```
60+
61+
| Variable | Description |
62+
|----------|-------------|
63+
| `PASSWORD` | Bot authentication password |
64+
| `TELEGRAM_TOKEN` | Get from [@BotFather](https://t.me/botfather) |
65+
| `ADMINS` | Your Telegram user ID for admin access |
66+
| `JACKETT_API_KEY` | Found in Jackett dashboard |
67+
| `JACKETT_URL` | Your Jackett instance URL with port |
68+
| `JACKETT_URL_SEARCH` | Jackett API endpoint path |
69+
| `RU_TORRENT_URL` | Full path to ruTorrent addtorrent.php |
6870
| `RU_TORRENT_TOKEN` | Base64 encoded username:password |` | `user:password_base64` | Base64 encoded auth |

feral_services/instance.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)