Initial commit: StashHandler

Bridge between qBittorrent and Stash that polls for completed torrents,
deduplicates via SHA256 hashing and SQLite, and imports new media files.
Supports daemon mode (continuous polling) and scan mode (bulk operations).
Configuration via environment variables for Docker Swarm compatibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-16 11:25:05 -05:00
commit f09d94e34b
10 changed files with 617 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import hashlib
def hash_file(path, algorithm="sha256"):
"""Hash a file by streaming in 64KB chunks. Returns hex digest."""
if algorithm == "blake3":
try:
import blake3
h = blake3.blake3()
except ImportError:
raise ImportError("blake3 requested but not installed; pip install blake3")
else:
h = hashlib.new(algorithm)
with open(path, "rb") as f:
while chunk := f.read(65536):
h.update(chunk)
return h.hexdigest()