Spaces:
Running
Running
Update FileStream/bot/plugins/FileHandlers/callback.py
Browse files
FileStream/bot/plugins/FileHandlers/callback.py
CHANGED
@@ -125,72 +125,72 @@ async def cb_data(bot: Client, update: CallbackQuery):
|
|
125 |
#file_name = get_name(message)
|
126 |
#name = file_caption if (file_caption) != "None/Unknown" else file_name
|
127 |
|
128 |
-
if user_id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
await update.message.edit_text(
|
130 |
text="You are Not An Admin ,Please Get Admin Access",
|
131 |
parse_mode=ParseMode.HTML,
|
132 |
disable_web_page_preview=True
|
133 |
-
|
134 |
-
|
135 |
-
try:
|
136 |
-
title, year = Get_Title_Year(name)
|
137 |
-
print(f"** ANY SEARCH :{name} \nFinal :{title} YEAR :{year}")
|
138 |
-
get_imdb_id = json.loads(imdb.search(title, year=int(year)))
|
139 |
-
#print(f"ANY SEARCH :{title} YEAR :{year} IMDB Response :{res}")
|
140 |
-
#print("TMDB",search_tmdb_any(title, year))
|
141 |
-
#print(f"IMDB ID :{get_imdb_id['results'][0]['id']}")
|
142 |
-
print(f"\n** GET_ID {get_imdb_id}")
|
143 |
-
#pprint(get_imdb_id)
|
144 |
-
#res=json.loads(imdb.get_by_id(get_imdb_id['results'][0]['id']))
|
145 |
-
res=json.loads(imdb.get_by_id(get_imdb_id['results'][0]['id']))
|
146 |
-
print(f"\n** IMDB Response :{res}")
|
147 |
-
#pprint(res)
|
148 |
-
instruction = {
|
149 |
-
"privacy_type": "PUBLIC",
|
150 |
-
"user_id": user_id,
|
151 |
-
"user_type": "TELEGRAM",
|
152 |
-
"IMDB_id": get_imdb_id['results'][0]['id'],
|
153 |
-
"poster": res.get("poster", "None"),
|
154 |
-
"title": res['name'],
|
155 |
-
"release_date": res["datePublished"],
|
156 |
-
"type": res['type'],
|
157 |
-
"description":res.get("description", "None"),
|
158 |
-
"keywords":res["keywords"].split(",") if res.get("keywords") else [],
|
159 |
-
"genre": res.get("genre", []) ,
|
160 |
-
}
|
161 |
-
|
162 |
-
file_info = get_file_info(message, instruction)
|
163 |
-
# Here we are Adding the File Into the database First
|
164 |
-
inserted_id = await db.add_file(file_info=file_info, db_type="PUBLIC")
|
165 |
-
await get_file_ids(False, inserted_id, message)
|
166 |
-
#All the Time Get_file_ids should be called before update privacy or else tagged_users will be {}
|
167 |
-
await db.update_privacy(file_info)
|
168 |
-
reply_markup, stream_text = await gen_link(_id=inserted_id)
|
169 |
-
await update.message.edit_text(
|
170 |
-
text=stream_text,
|
171 |
-
parse_mode=ParseMode.HTML,
|
172 |
-
disable_web_page_preview=True,
|
173 |
-
reply_markup=reply_markup,
|
174 |
-
)
|
175 |
-
except FloodWait as e:
|
176 |
-
print(f"Sleeping for {str(e.value)}s")
|
177 |
-
await asyncio.sleep(e.value)
|
178 |
-
await FileStream.send_message(
|
179 |
-
chat_id=Telegram.ULOG_GROUP,
|
180 |
-
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)}`",
|
181 |
-
disable_web_page_preview=True,
|
182 |
-
parse_mode=ParseMode.MARKDOWN)
|
183 |
-
except Exception as e:
|
184 |
-
exc_type, exc_obj, exc_tb = sys.exc_info()
|
185 |
-
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
186 |
-
print("Error Encountered",exc_type, fname, exc_tb.tb_lineno)
|
187 |
-
print(f"An error occurred: a{str(e)}")
|
188 |
-
await FileStream.send_message(
|
189 |
-
chat_id=Telegram.ULOG_GROUP,
|
190 |
-
text=f"An error occurred: {str(e)}"
|
191 |
-
)
|
192 |
-
|
193 |
-
|
194 |
elif usr_cmd[0] == "tempup":
|
195 |
try:
|
196 |
print("Public Upload :",usr_cmd)
|
|
|
125 |
#file_name = get_name(message)
|
126 |
#name = file_caption if (file_caption) != "None/Unknown" else file_name
|
127 |
|
128 |
+
if str(user_id) == str(Telegram.OWNER_ID):
|
129 |
+
try:
|
130 |
+
title, year = Get_Title_Year(name)
|
131 |
+
print(f"** ANY SEARCH :{name} \nFinal :{title} YEAR :{year}")
|
132 |
+
get_imdb_id = json.loads(imdb.search(title, year=int(year)))
|
133 |
+
#print(f"ANY SEARCH :{title} YEAR :{year} IMDB Response :{res}")
|
134 |
+
#print("TMDB",search_tmdb_any(title, year))
|
135 |
+
#print(f"IMDB ID :{get_imdb_id['results'][0]['id']}")
|
136 |
+
print(f"\n** GET_ID {get_imdb_id}")
|
137 |
+
#pprint(get_imdb_id)
|
138 |
+
#res=json.loads(imdb.get_by_id(get_imdb_id['results'][0]['id']))
|
139 |
+
res=json.loads(imdb.get_by_id(get_imdb_id['results'][0]['id']))
|
140 |
+
print(f"\n** IMDB Response :{res}")
|
141 |
+
#pprint(res)
|
142 |
+
instruction = {
|
143 |
+
"privacy_type": "PUBLIC",
|
144 |
+
"user_id": user_id,
|
145 |
+
"user_type": "TELEGRAM",
|
146 |
+
"IMDB_id": get_imdb_id['results'][0]['id'],
|
147 |
+
"poster": res.get("poster", "None"),
|
148 |
+
"title": res['name'],
|
149 |
+
"release_date": res["datePublished"],
|
150 |
+
"type": res['type'],
|
151 |
+
"description":res.get("description", "None"),
|
152 |
+
"keywords":res["keywords"].split(",") if res.get("keywords") else [],
|
153 |
+
"genre": res.get("genre", []) ,
|
154 |
+
}
|
155 |
+
|
156 |
+
file_info = get_file_info(message, instruction)
|
157 |
+
# Here we are Adding the File Into the database First
|
158 |
+
inserted_id = await db.add_file(file_info=file_info, db_type="PUBLIC")
|
159 |
+
await get_file_ids(False, inserted_id, message)
|
160 |
+
#All the Time Get_file_ids should be called before update privacy or else tagged_users will be {}
|
161 |
+
await db.update_privacy(file_info)
|
162 |
+
reply_markup, stream_text = await gen_link(_id=inserted_id)
|
163 |
+
await update.message.edit_text(
|
164 |
+
text=stream_text,
|
165 |
+
parse_mode=ParseMode.HTML,
|
166 |
+
disable_web_page_preview=True,
|
167 |
+
reply_markup=reply_markup,
|
168 |
+
)
|
169 |
+
except FloodWait as e:
|
170 |
+
print(f"Sleeping for {str(e.value)}s")
|
171 |
+
await asyncio.sleep(e.value)
|
172 |
+
await FileStream.send_message(
|
173 |
+
chat_id=Telegram.ULOG_GROUP,
|
174 |
+
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)}`",
|
175 |
+
disable_web_page_preview=True,
|
176 |
+
parse_mode=ParseMode.MARKDOWN)
|
177 |
+
except Exception as e:
|
178 |
+
exc_type, exc_obj, exc_tb = sys.exc_info()
|
179 |
+
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
180 |
+
print("Error Encountered",exc_type, fname, exc_tb.tb_lineno)
|
181 |
+
print(f"An error occurred: a{str(e)}")
|
182 |
+
await FileStream.send_message(
|
183 |
+
chat_id=Telegram.ULOG_GROUP,
|
184 |
+
text=f"An error occurred: {str(e)}"
|
185 |
+
)
|
186 |
+
|
187 |
+
else:
|
188 |
await update.message.edit_text(
|
189 |
text="You are Not An Admin ,Please Get Admin Access",
|
190 |
parse_mode=ParseMode.HTML,
|
191 |
disable_web_page_preview=True
|
192 |
+
)
|
193 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
elif usr_cmd[0] == "tempup":
|
195 |
try:
|
196 |
print("Public Upload :",usr_cmd)
|