diff --git a/misskaty/helper/html_view.py b/misskaty/helper/html_view.py
index 7a6c668e..88693f61 100644
--- a/misskaty/helper/html_view.py
+++ b/misskaty/helper/html_view.py
@@ -139,7 +139,7 @@ async def postToWeb(file, name):
data = {"message":"Added new HTML File","committer":{"name":"Yasir Aris M","email":"mail@yasir.eu.org"},"content": f"{fpath.decode('ascii')}"}
- response = await http.put(f"https://api.github.com/repos/yasirarism/HTMLPaste/contents/{name}", headers=headers, data=json.dumps(data))
+ response = await http.put(f"https://api.github.com/repos/yasirarism/HTMLPaste/contents/{name}.html", headers=headers, data=json.dumps(data))
return f"https://yasirarism.github.io/HTMLPaste/{name}"
async def getMediaWeb(title, text):
@@ -153,6 +153,9 @@ async def getMediaWeb(title, text):
f"
{text}
"
with open(f"{fname}.html", 'w', encoding='utf-8') as f:
f.write(hmtl_content.replace('{fileName}', f"{fname}.html").replace('{msg}', mssg))
- res = await postToWeb(f"{fname}.html", fname)
- os.remove(f"{fname}.html")
- return res
+ try:
+ res = await postToWeb(f"{fname}.html", fname)
+ os.remove(f"{fname}.html")
+ return res
+ except:
+ return None
diff --git a/misskaty/plugins/mediainfo.py b/misskaty/plugins/mediainfo.py
index 83762a58..1be47f74 100644
--- a/misskaty/plugins/mediainfo.py
+++ b/misskaty/plugins/mediainfo.py
@@ -55,6 +55,12 @@ async def mediainfo(client, message):
text_ = file_info.message_type
if CUSTOM_VIEW and GH_TOKEN is not None:
link = await getMediaWeb(title, body_text)
+ if not link:
+ try:
+ osremove(file_path)
+ except:
+ pass
+ return await message.reply("Failed to post mediainfo result.")
else:
link = post_to_telegraph(title, body_text)
markup = InlineKeyboardMarkup([[InlineKeyboardButton(text=text_, url=link)]])
@@ -83,6 +89,8 @@ async def mediainfo(client, message):
"""
if CUSTOM_VIEW and GH_TOKEN is not None:
link = await getMediaWeb(title, body_text)
+ if not link:
+ return await message.reply("Failed to post mediainfo result.")
else:
link = post_to_telegraph(title, body_text)
# siteurl = "https://spaceb.in/api/v1/documents/"