Cleaner downloads

This commit is contained in:
Kasper Plougmann 2025-07-08 21:26:40 +02:00 committed by GitHub
parent 0cfeb056a6
commit bd3c4b1702
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,7 +21,14 @@ logging.basicConfig(
watch_dir = "/watch" watch_dir = "/watch"
def download_torrent(name, url): def download_torrent(name, url):
dest = os.path.join(watch_dir, f"{name}.torrent") dest = os.path.join(watch_dir, f"{name}.torrent")
added = os.path.join(watch_dir, f"{name}.torrent.added")
# Skip if already processed or queued
if dest.exists() or added.exists():
logging.info("Skip %s torrent already present.", dest.name)
return False
try: try:
logging.info(f"Fetching {url} ...") logging.info(f"Fetching {url} ...")
r = requests.get(url, timeout=30) r = requests.get(url, timeout=30)