changed hash variable name and changed how entries are provided to function for RSS

This commit is contained in:
2026-06-13 15:05:39 +05:30
parent 5ad61c1cd0
commit b62b9df15e

View File

@@ -33,7 +33,7 @@ XML_END = """</channel></rss>"""
load_dotenv() load_dotenv()
copyparty_token = os.getenv('COPYPARTY_TOKEN') copyparty_token = os.getenv('COPYPARTY_TOKEN')
def make_torrent_entry(name, timestamp, hash, category): def make_torrent_entry(name, timestamp, filehash, category):
if category: if category:
category = "DODI_Repack" category = "DODI_Repack"
else: else:
@@ -42,7 +42,7 @@ def make_torrent_entry(name, timestamp, hash, category):
<title><![CDATA[{name}]]></title> <title><![CDATA[{name}]]></title>
<pubDate>{timestamp} +0000</pubDate> <pubDate>{timestamp} +0000</pubDate>
<category>{category}</category> <category>{category}</category>
<guid>{name}</guid> <guid>{filehash}</guid>
<link><![CDATA[https://torfiles.fieryeagle.org/{urlencode(name)}]]></link> <link><![CDATA[https://torfiles.fieryeagle.org/{urlencode(name)}]]></link>
<description><![CDATA[Category: {category}{timestamp} +0000]]></description> <description><![CDATA[Category: {category}{timestamp} +0000]]></description>
</item>""" </item>"""
@@ -56,13 +56,13 @@ def write_file(path, data):
def create_25_recent_feed(df): def create_25_recent_feed(df):
most_recent_25 = df.sort_values("timestamp", ascending=False).head(25) most_recent_25 = df.sort_values("timestamp", ascending=False).head(25)
latest_25_xml = "\n".join([make_torrent_entry(i[0], i[2], i[3], i[4]) for i in most_recent_25.values]) latest_25_xml = "\n".join([make_torrent_entry(i["name"], i["timestamp"], i["filehash"], i["is_repack"]) for i in most_recent_25])
write_file("RSS/recent_25.xml", XML_BEGIN_RECENT+latest_25_xml+XML_END) write_file("RSS/recent_25.xml", XML_BEGIN_RECENT+latest_25_xml+XML_END)
def create_48h_latest(df): def create_48h_latest(df):
last_48_hours = df[df['timestamp'] > datetime.now() - pd.Timedelta(days=2)] last_48_hours = df[df['timestamp'] > datetime.now() - pd.Timedelta(days=2)]
last_48_hours = last_48_hours.sort_values("timestamp", ascending=False) last_48_hours = last_48_hours.sort_values("timestamp", ascending=False)
last_48_xml = "\n".join([make_torrent_entry(i[0], i[2], i[3], i[4]) for i in last_48_hours.values]) last_48_xml = "\n".join([make_torrent_entry(i["name"], i["timestamp"], i["filehash"], i["is_repack"]) for i in last_48_hours])
write_file("RSS/latest_48h.xml", XML_BEGIN_LAST+last_48_xml+XML_END) write_file("RSS/latest_48h.xml", XML_BEGIN_LAST+last_48_xml+XML_END)
def create_df(): def create_df():
@@ -71,7 +71,7 @@ def create_df():
rows = [i.find_all("td") for i in soup.tbody.find_all("tr")] rows = [i.find_all("td") for i in soup.tbody.find_all("tr")]
filtered_rows = [[i[1].text, i[6].text, i[4].text, datetime.strptime(i[9].text, "%Y-%m-%d %H:%M:%S")] for i in rows] filtered_rows = [[i[1].text, i[6].text, i[4].text, datetime.strptime(i[9].text, "%Y-%m-%d %H:%M:%S")] for i in rows]
df = pd.DataFrame( df = pd.DataFrame(
data=filtered_rows, columns=["name", "upload_ip", "hash", "timestamp"] data=filtered_rows, columns=["name", "upload_ip", "filehash", "timestamp"]
) )
df['is_repack'] = df['name'].str.contains('DODI', case=False) df['is_repack'] = df['name'].str.contains('DODI', case=False)