Compare commits

...

9 Commits

Author SHA1 Message Date
9866977392 fixed pandas df issue 2026-06-13 15:08:30 +05:30
b62b9df15e changed hash variable name and changed how entries are provided to function for RSS 2026-06-13 15:05:39 +05:30
5ad61c1cd0 added hash as guid for rss 2026-06-10 23:36:18 +05:30
60645b1c68 removed file upload due to incompatibility with discord 2026-06-03 19:50:39 +05:30
5dfb498908 fixed error 2026-06-03 19:45:08 +05:30
51fb22b2c3 test 2026-06-03 19:43:44 +05:30
19878a39a7 changed filename type 2026-06-03 19:35:41 +05:30
70146e7931 added more logging 2026-06-03 19:31:44 +05:30
bc05b054e5 added logger entries for manual upload 2026-06-03 19:28:22 +05:30
2 changed files with 9 additions and 16 deletions

View File

@@ -118,18 +118,10 @@ async def update_rss(ctx):
await ctx.respond("Sucessfully updated RSS feed")
@bot.slash_command()
async def upload(ctx,file: discord.Attachment | None = None):
async def upload(ctx):
messagechannel = bot.get_channel(torrent_link_channel_id)
if file is None:
logger.info("No link attached")
else:
filename = str(file.filename)
if ".torrent" in filename:
await file.save(filename)
await ctx.respond(f"{filename} recieved, uploading")
if ctx.user.id == fiery_eagle_id or ctx.user.id == dodi_id:
files = files_to_upload(".")
try:
@@ -138,10 +130,11 @@ async def upload(ctx,file: discord.Attachment | None = None):
await ctx.respond("Tried to upload 0 files")
else:
for i in files:
logger.info(f"Uploading filename: {i}")
uploadfile(i)
await messagechannel.send(f"{os.path.splitext(i)[0]}\nhttps://torfiles.fieryeagle.org/{urlencode(i)}")
os.remove(i)
await ctx.respond(f"Sucessfully uploaded {files}")
await ctx.followup.send(f"Sucessfully uploaded {files}")
@bot.slash_command()
async def manual_upload(ctx, file_url: str):

View File

@@ -33,7 +33,7 @@ XML_END = """</channel></rss>"""
load_dotenv()
copyparty_token = os.getenv('COPYPARTY_TOKEN')
def make_torrent_entry(name, timestamp, category):
def make_torrent_entry(name, timestamp, filehash, category):
if category:
category = "DODI_Repack"
else:
@@ -42,7 +42,7 @@ def make_torrent_entry(name, timestamp, category):
<title><![CDATA[{name}]]></title>
<pubDate>{timestamp} +0000</pubDate>
<category>{category}</category>
<guid>{name}</guid>
<guid>{filehash}</guid>
<link><![CDATA[https://torfiles.fieryeagle.org/{urlencode(name)}]]></link>
<description><![CDATA[Category: {category}{timestamp} +0000]]></description>
</item>"""
@@ -56,22 +56,22 @@ def write_file(path, data):
def create_25_recent_feed(df):
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]) for i in most_recent_25.values])
latest_25_xml = "\n".join(make_torrent_entry(row.name, row.timestamp, row.filehash, row.is_repack) for row in most_recent_25.itertuples())
write_file("RSS/recent_25.xml", XML_BEGIN_RECENT+latest_25_xml+XML_END)
def create_48h_latest(df):
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_xml = "\n".join([make_torrent_entry(i[0], i[2], i[3]) for i in last_48_hours.values])
last_48_xml = "\n".join(make_torrent_entry(row.name, row.timestamp, row.filehash, row.is_repack) for row in last_48_hours.itertuples())
write_file("RSS/latest_48h.xml", XML_BEGIN_LAST+last_48_xml+XML_END)
def create_df():
torfiles_scrape = requests.get("https://upload.fieryeagle.org/torfiles", auth=("torbot",copyparty_token))
soup = BeautifulSoup(torfiles_scrape.content, "html.parser")
rows = [i.find_all("td") for i in soup.tbody.find_all("tr")]
filtered_rows = [[i[1].text, i[6].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(
data=filtered_rows, columns=["name", "upload_ip", "timestamp"]
data=filtered_rows, columns=["name", "upload_ip", "filehash", "timestamp"]
)
df['is_repack'] = df['name'].str.contains('DODI', case=False)