From e57c6f2fb5e471a60008051a05464979a0046930 Mon Sep 17 00:00:00 2001 From: Seven Petals Date: Thu, 2 Jan 2025 19:28:07 +0000 Subject: [PATCH] Update rss.py Updated rss.py to use python's fstrings instead of the string formatting used. --- rss.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/rss.py b/rss.py index bf3af77036..a1e44be501 100644 --- a/rss.py +++ b/rss.py @@ -2,7 +2,7 @@ # # Copyright (C) 2016 James Elliott -# Copyright (C) 2016-2018 Plailect +# Copyright (C) 2016-2018 Plailect # Copyright (C) 2022-2023 Nintendo Homebrew # # SPDX-License-Identifier: MIT @@ -35,7 +35,7 @@ with open(rss, "w") as xml: xml.write("\n") xml.write("\t\n") xml.write("\t\tPlailect Guide Feed\n") - xml.write("\t\t{0}\n".format(datetime.datetime.utcnow().strftime("%a, %d %b %Y %X +0000"))) + xml.write(f"\t\t{datetime.datetime.utcnow().strftime("%a, %d %b %Y %X +0000")}\n") xml.write("\t\thttps://github.com/hacks-guide/Guide_3DS/\n") for filename in os.listdir(dir): @@ -47,7 +47,7 @@ with open(rss, "w") as xml: tor = bencodepy.decode(raw) trackers = [] infohash = hashlib.sha1(bencodepy.encode(tor[b"info"])).hexdigest().upper() - magp = {"xt": "urn:btih:{0}".format(infohash), "dn": tor[b"info"][b"name"], "xl": tor[b"info"][b"length"]} + magp = {"xt": f"urn:btih:{infohash}", "dn": tor[b"info"][b"name"], "xl": tor[b"info"][b"length"]} magstr = urllib.parse.urlencode(magp) if b'announce-list' in tor: for anncl in tor[b'announce-list']: @@ -66,16 +66,16 @@ with open(rss, "w") as xml: for i in items: pubdate = datetime.datetime.utcfromtimestamp(int(i["ts"])) xml.write("\t\t\n") - xml.write("\t\t\t{0}\n".format(i["name"])) - xml.write("\t\t\t{0}\n".format(i["name"])) - xml.write("\t\t\t{0}\n".format(i["infohash"])) - xml.write("\t\t\tmagnet:?xt=urn:btih:{0}\n".format(i["infohash"])) - xml.write("\t\t\t{0}\n".format(pubdate.strftime("%a, %d %b %Y %X +0000"))) - xml.write("\t\t\t{0}\n".format(i["length"])) - xml.write("\t\t\t{0}\n".format(i["infohash"])) - xml.write("\t\t\tmagnet:?xt=urn:btih:{0}\n".format(i["infohash"])) + xml.write(f"\t\t\t{i['name']}\n") + xml.write(f"\t\t\t{i['name']}\n".format(i["name"])) + xml.write(f"\t\t\t{i['infohash']}\n") + xml.write(f"\t\t\tmagnet:?xt=urn:btih:{i['infohash']}\n") + xml.write(f"\t\t\t{pubdate.strftime("%a, %d %b %Y %X +0000")}\n") + xml.write(f"\t\t\t{i['length']}\n") + xml.write(f"\t\t\t{i['infohash']}\n") + xml.write(f"\t\t\tmagnet:?xt=urn:btih:{i['infohash']}\n") #xml.write("\t\t\t{0}\n".format(name)) - xml.write("\t\t\t\n".format(i["infohash"])) + xml.write(f"\t\t\t\n") if i["trackers"]: xml.write("\t\t\t\n") @@ -83,7 +83,7 @@ with open(rss, "w") as xml: for tracker in i["trackers"]: xml.write("\t\t\t\t\t\n") - xml.write("\t\t\t\t\t\t{0}\n".format(tracker)) + xml.write(f"\t\t\t\t\t\t{tracker}\n") xml.write("\t\t\t\t\t\n") xml.write("\t\t\t\t\n")