Update FileStream/bot/plugins/FileHandlers/callback.py
Browse files
FileStream/bot/plugins/FileHandlers/callback.py
CHANGED
|
@@ -114,31 +114,31 @@ async def cb_data(bot: Client, update: CallbackQuery):
|
|
| 114 |
)
|
| 115 |
|
| 116 |
elif usr_cmd[0] == "pubup":
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
"privacy_type": "PUBLIC",
|
| 143 |
"user_id": user_id,
|
| 144 |
"user_type": "TELEGRAM",
|
|
@@ -150,39 +150,44 @@ async def cb_data(bot: Client, update: CallbackQuery):
|
|
| 150 |
"description":res.get("description", "None"),
|
| 151 |
"keywords":res["keywords"].split(",") if res.get("keywords") else [],
|
| 152 |
"genre": res.get("genre", []) ,
|
| 153 |
-
|
| 154 |
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
text=stream_text,
|
| 164 |
parse_mode=ParseMode.HTML,
|
| 165 |
disable_web_page_preview=True,
|
| 166 |
reply_markup=reply_markup,
|
| 167 |
)
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
chat_id=Telegram.ULOG_GROUP,
|
| 173 |
-
text=
|
| 174 |
-
f"Gᴏᴛ FʟᴏᴏᴅWᴀɪᴛ ᴏғ {str(e.value)}s ғʀᴏᴍ [{message.from_user.first_name}](tg://user?id={message.from_user.id})\n\n**ᴜsᴇʀ ɪᴅ :** `{str(message.from_user.id)}`",
|
| 175 |
disable_web_page_preview=True,
|
| 176 |
parse_mode=ParseMode.MARKDOWN)
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
chat_id=Telegram.ULOG_GROUP,
|
| 184 |
text=f"An error occurred: {str(e)}"
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
elif usr_cmd[0] == "tempup":
|
| 188 |
try:
|
|
|
|
| 114 |
)
|
| 115 |
|
| 116 |
elif usr_cmd[0] == "pubup":
|
| 117 |
+
if int(usr_cmd[1]) in Telegram.OWNER_ID :
|
| 118 |
+
try:
|
| 119 |
+
print("Public Upload :",usr_cmd)
|
| 120 |
+
user_id = str(usr_cmd[1])
|
| 121 |
+
message_id = int(usr_cmd[2])
|
| 122 |
+
message = await FileStream.get_messages(user_id, message_id)
|
| 123 |
+
#response = await FileStream.get_messages(user_id, response_id)
|
| 124 |
+
#print(f"Message:{message}")
|
| 125 |
+
name = getattr(message, "caption", f"{get_name(message)}" ) or "None/Unknown"
|
| 126 |
+
#file_name = get_name(message)
|
| 127 |
+
#name = file_caption if (file_caption) != "None/Unknown" else file_name
|
| 128 |
+
from FileStream.Tools.cleanup import Get_Title_Year
|
| 129 |
+
title, year = Get_Title_Year(name)
|
| 130 |
+
print(f"** ANY SEARCH :{name} \nFinal :{title} YEAR :{year}")
|
| 131 |
+
get_imdb_id = json.loads(imdb.search(title, year=int(year)))
|
| 132 |
+
#print(f"ANY SEARCH :{title} YEAR :{year} IMDB Response :{res}")
|
| 133 |
+
#print("TMDB",search_tmdb_any(title, year))
|
| 134 |
+
#print(f"IMDB ID :{get_imdb_id['results'][0]['id']}")
|
| 135 |
+
print(f"\n** GET_ID {get_imdb_id}")
|
| 136 |
+
#pprint(get_imdb_id)
|
| 137 |
+
#res=json.loads(imdb.get_by_id(get_imdb_id['results'][0]['id']))
|
| 138 |
+
res=json.loads(imdb.get_by_id(get_imdb_id['results'][0]['id']))
|
| 139 |
+
print(f"\n** IMDB Response :{res}")
|
| 140 |
+
#pprint(res)
|
| 141 |
+
instruction = {
|
| 142 |
"privacy_type": "PUBLIC",
|
| 143 |
"user_id": user_id,
|
| 144 |
"user_type": "TELEGRAM",
|
|
|
|
| 150 |
"description":res.get("description", "None"),
|
| 151 |
"keywords":res["keywords"].split(",") if res.get("keywords") else [],
|
| 152 |
"genre": res.get("genre", []) ,
|
| 153 |
+
}
|
| 154 |
|
| 155 |
+
file_info = get_file_info(message, instruction)
|
| 156 |
+
# Here we are Adding the File Into the database First
|
| 157 |
+
inserted_id = await db.add_file(file_info=file_info, db_type="PUBLIC")
|
| 158 |
+
await get_file_ids(False, inserted_id, message)
|
| 159 |
+
#All the Time Get_file_ids should be called before update privacy or else tagged_users will be {}
|
| 160 |
+
await db.update_privacy(file_info)
|
| 161 |
+
reply_markup, stream_text = await gen_link(_id=inserted_id)
|
| 162 |
+
await update.message.edit_text(
|
| 163 |
text=stream_text,
|
| 164 |
parse_mode=ParseMode.HTML,
|
| 165 |
disable_web_page_preview=True,
|
| 166 |
reply_markup=reply_markup,
|
| 167 |
)
|
| 168 |
+
except FloodWait as e:
|
| 169 |
+
print(f"Sleeping for {str(e.value)}s")
|
| 170 |
+
await asyncio.sleep(e.value)
|
| 171 |
+
await FileStream.send_message(
|
| 172 |
chat_id=Telegram.ULOG_GROUP,
|
| 173 |
+
text= f"Gᴏᴛ FʟᴏᴏᴅWᴀɪᴛ ᴏғ {str(e.value)}s ғʀᴏᴍ [{message.from_user.first_name}](tg://user?id={message.from_user.id})\n\n**ᴜsᴇʀ ɪᴅ :** `{str(message.from_user.id)}`",
|
|
|
|
| 174 |
disable_web_page_preview=True,
|
| 175 |
parse_mode=ParseMode.MARKDOWN)
|
| 176 |
+
except Exception as e:
|
| 177 |
+
exc_type, exc_obj, exc_tb = sys.exc_info()
|
| 178 |
+
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
| 179 |
+
print("Error Encountered",exc_type, fname, exc_tb.tb_lineno)
|
| 180 |
+
print(f"An error occurred: a{str(e)}")
|
| 181 |
+
await FileStream.send_message(
|
| 182 |
chat_id=Telegram.ULOG_GROUP,
|
| 183 |
text=f"An error occurred: {str(e)}"
|
| 184 |
+
)
|
| 185 |
+
else:
|
| 186 |
+
await update.message.edit_text(
|
| 187 |
+
text="You are Not An Admin ,Please Get Admin Access",
|
| 188 |
+
parse_mode=ParseMode.HTML,
|
| 189 |
+
disable_web_page_preview=True
|
| 190 |
+
)
|
| 191 |
|
| 192 |
elif usr_cmd[0] == "tempup":
|
| 193 |
try:
|