perf: finish 2hdp
Some checks failed
dl / docker (push) Blocked by required conditions
dl / lint (push) Has been cancelled

This commit is contained in:
Michel Roux 2024-11-30 12:39:43 +01:00
parent 7f99179b40
commit 1047fa6386
2 changed files with 33 additions and 10 deletions

View File

@ -1,20 +1,16 @@
from argparse import ArgumentParser
from csv import DictWriter
from logging import INFO, StreamHandler
from sys import stdout
from xml.etree import ElementTree
from requests import get
from transmissionrpc import LOGGER, Client, DefaultHTTPHandler # type: ignore
from transmissionrpc import Client, DefaultHTTPHandler # 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))
class CustomHTTPHandler(DefaultHTTPHandler):
def request(self, url, query, headers, timeout):
@ -30,9 +26,10 @@ client = Client(
port=443,
user=args.username,
password=args.password,
http_handler=CustomHTTPHandler,
http_handler=CustomHTTPHandler(),
)
movies = []
torrents = client.get_torrents()
writer = DictWriter(stdout, fieldnames=["season", "title", "hash", "url"])
@ -42,19 +39,45 @@ for item in tree.findall(".//item"):
title = item.find("title")
season = item.find("itunes:season", {"itunes": "http://www.itunes.com/dtds/podcast-1.0.dtd"})
if season is None or title is None:
if season is None or title is None or title.text is None:
continue
row = {
"title": title.text,
"season": season.text,
"season": f"Saison {season.text}",
"hash": "",
"url": f"https://www.ygg.re/engine/search?name={title.text}&description=&file=&uploader=&category=2145&sub_category=2183&option_langue:multiple[0]=4&do=search&order=asc&sort=publish_date",
}
for torrent in torrents:
if title.text is not None and title.text.lower() in torrent.name.lower():
if title.text.lower() in torrent.name.lower():
row["hash"] = torrent.hashString
break
movies.append(title.text.lower())
writer.writerow(row)
tree = ElementTree.fromstring(
get("https://www.calvinballconsortium.fr/podcasts/leretourdujeudi/feed.xml").text
)
for item in tree.findall(".//item"):
title = item.find("title")
if title is None or title.text is None or title.text.lower() in movies:
continue
row = {
"title": title.text,
"season": "Jeudi",
"hash": "",
"url": f"https://www.ygg.re/engine/search?name={title.text}&description=&file=&uploader=&category=2145&sub_category=2183&option_langue:multiple[0]=4&do=search&order=asc&sort=publish_date",
}
for torrent in torrents:
if title.text.lower() in torrent.name.lower():
row["hash"] = torrent.hashString
break
movies.append(title.text.lower())
writer.writerow(row)

View File

@ -31,7 +31,7 @@ client = Client(
port=443,
user=args.username,
password=args.password,
http_handler=CustomHTTPHandler,
http_handler=CustomHTTPHandler(),
)
for torrent in client.get_torrents():