dl/commands/nyaa-404.py
Michel Roux cf68462ae2
Some checks failed
dl / lint (push) Successful in 2m7s
dl / docker (push) Failing after 6m33s
refactor: add transmissionrpc_cf and 2hdp script
2024-11-30 01:50:46 +01:00

38 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python3
from argparse import ArgumentParser
from logging import INFO, StreamHandler
from os import path
from sys import stdout
from time import sleep
from requests import head
from transmissionrpc_cf import LOGGER, Client # type: ignore
parser = ArgumentParser()
parser.add_argument("-u", "--username", required=True)
parser.add_argument("-p", "--password", required=True)
args = parser.parse_args()
LOGGER.setLevel(INFO)
LOGGER.addHandler(StreamHandler(stdout))
client = Client(
"https://torrent.crystalyx.net/transmission/rpc",
port=443,
user=args.username,
password=args.password,
)
for torrent in client.get_torrents():
if "nyaa" in torrent.comment:
try:
response = head(torrent.comment)
if response.status_code != 200:
print(f"{response.status_code} - {path.join(torrent.downloadDir, torrent.name)}")
except Exception:
print(
f"{response.status_code} - {torrent.comment} - {path.join(torrent.downloadDir, torrent.name)}" # noqa
)
sleep(1)