Skip to content

Commit e57c6f2

Browse files
7petalslifehackerhansol
authored andcommitted
Update rss.py
Updated rss.py to use python's fstrings instead of the string formatting used.
1 parent 7ebcabb commit e57c6f2

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

rss.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#
44
# Copyright (C) 2016 James Elliott
5-
# Copyright (C) 2016-2018 Plailect
5+
# Copyright (C) 2016-2018 Plailect
66
# Copyright (C) 2022-2023 Nintendo Homebrew
77
#
88
# SPDX-License-Identifier: MIT
@@ -35,7 +35,7 @@
3535
xml.write("<rss version=\"2.0\">\n")
3636
xml.write("\t<channel>\n")
3737
xml.write("\t\t<title>Plailect Guide Feed</title>\n")
38-
xml.write("\t\t<lastBuildDate>{0}</lastBuildDate>\n".format(datetime.datetime.utcnow().strftime("%a, %d %b %Y %X +0000")))
38+
xml.write(f"\t\t<lastBuildDate>{datetime.datetime.utcnow().strftime("%a, %d %b %Y %X +0000")}</lastBuildDate>\n")
3939
xml.write("\t\t<link>https://github.com/hacks-guide/Guide_3DS/</link>\n")
4040

4141
for filename in os.listdir(dir):
@@ -47,7 +47,7 @@
4747
tor = bencodepy.decode(raw)
4848
trackers = []
4949
infohash = hashlib.sha1(bencodepy.encode(tor[b"info"])).hexdigest().upper()
50-
magp = {"xt": "urn:btih:{0}".format(infohash), "dn": tor[b"info"][b"name"], "xl": tor[b"info"][b"length"]}
50+
magp = {"xt": f"urn:btih:{infohash}", "dn": tor[b"info"][b"name"], "xl": tor[b"info"][b"length"]}
5151
magstr = urllib.parse.urlencode(magp)
5252
if b'announce-list' in tor:
5353
for anncl in tor[b'announce-list']:
@@ -66,24 +66,24 @@
6666
for i in items:
6767
pubdate = datetime.datetime.utcfromtimestamp(int(i["ts"]))
6868
xml.write("\t\t<item>\n")
69-
xml.write("\t\t\t<title>{0}</title>\n".format(i["name"]))
70-
xml.write("\t\t\t<description>{0}</description>\n".format(i["name"]))
71-
xml.write("\t\t\t<guid>{0}</guid>\n".format(i["infohash"]))
72-
xml.write("\t\t\t<link>magnet:?xt=urn:btih:{0}</link>\n".format(i["infohash"]))
73-
xml.write("\t\t\t<pubDate>{0}</pubDate>\n".format(pubdate.strftime("%a, %d %b %Y %X +0000")))
74-
xml.write("\t\t\t<contentLength>{0}</contentLength>\n".format(i["length"]))
75-
xml.write("\t\t\t<infoHash>{0}</infoHash>\n".format(i["infohash"]))
76-
xml.write("\t\t\t<magnetURI>magnet:?xt=urn:btih:{0}</magnetURI>\n".format(i["infohash"]))
69+
xml.write(f"\t\t\t<title>{i['name']}</title>\n")
70+
xml.write(f"\t\t\t<description>{i['name']}</description>\n".format(i["name"]))
71+
xml.write(f"\t\t\t<guid>{i['infohash']}</guid>\n")
72+
xml.write(f"\t\t\t<link>magnet:?xt=urn:btih:{i['infohash']}</link>\n")
73+
xml.write(f"\t\t\t<pubDate>{pubdate.strftime("%a, %d %b %Y %X +0000")}</pubDate>\n")
74+
xml.write(f"\t\t\t<contentLength>{i['length']}</contentLength>\n")
75+
xml.write(f"\t\t\t<infoHash>{i['infohash']}</infoHash>\n")
76+
xml.write(f"\t\t\t<magnetURI>magnet:?xt=urn:btih:{i['infohash']}</magnetURI>\n")
7777
#xml.write("\t\t\t<fileName>{0}</fileName><fileName>\n".format(name))
78-
xml.write("\t\t\t<enclosure url=\"magnet:?xt=urn:btih:{0}\" type=\"application/x-bittorrent\" />\n".format(i["infohash"]))
78+
xml.write(f"\t\t\t<enclosure url=\"magnet:?xt=urn:btih:{i['infohash']}\" type=\"application/x-bittorrent\" />\n")
7979

8080
if i["trackers"]:
8181
xml.write("\t\t\t<trackers>\n")
8282
xml.write("\t\t\t\t<group order=\"random\">\n")
8383

8484
for tracker in i["trackers"]:
8585
xml.write("\t\t\t\t\t<tracker>\n")
86-
xml.write("\t\t\t\t\t\t{0}\n".format(tracker))
86+
xml.write(f"\t\t\t\t\t\t{tracker}\n")
8787
xml.write("\t\t\t\t\t</tracker>\n")
8888

8989
xml.write("\t\t\t\t</group>\n")

0 commit comments

Comments
 (0)