Skip to content

Commit

Permalink
fixed issue related to merge audio
Browse files Browse the repository at this point in the history
  • Loading branch information
yashoswalyo committed Aug 22, 2022
1 parent 75b8262 commit 8fd54a1
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
8 changes: 4 additions & 4 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ async def start_handler(c: Client, m: Message):


@mergeApp.on_message((filters.document | filters.video | filters.audio) & filters.private)
async def video_handler(c: Client, m: Message):
async def files_handler(c: Client, m: Message):
user_id = m.from_user.id
if user_id != int(Config.OWNER):
if await database.allowedUser(uid=user_id) is False:
Expand Down Expand Up @@ -256,7 +256,7 @@ async def video_handler(c: Client, m: Message):
MessageText = "Okay,\nNow Send Me Next Video or Press **Merge Now** Button!"

if queueDB.get(user_id, None) is None:
queueDB.update({m.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({user_id: {"videos": [], "subtitles": [], "audios":[]}})
if (
len(queueDB.get(user_id)["videos"]) >= 0
and len(queueDB.get(user_id)["videos"]) < 10
Expand Down Expand Up @@ -303,7 +303,7 @@ async def video_handler(c: Client, m: Message):
)

if queueDB.get(user_id, None) is None:
queueDB.update({user_id: {"videos": [], "audios": []}})
queueDB.update({user_id: {"videos": [], "subtitles": [], "audios":[]}})
if len(queueDB.get(user_id)["videos"]) == 0:
queueDB.get(user_id)["videos"].append(m.id)
# if len(queueDB.get(user_id)["videos"])==1:
Expand Down Expand Up @@ -339,7 +339,7 @@ async def video_handler(c: Client, m: Message):
editable = await m.reply_text("Please Wait ...", quote=True)
MessageText = "Okay,\nNow Send Me Some More <u>Subtitles</u> or Press **Merge Now** Button!"
if queueDB.get(user_id, None) is None:
queueDB.update({user_id: {"videos": [], "subtitles": []}})
queueDB.update({user_id: {"videos": [], "subtitles": [], "audios":[]}})
if len(queueDB.get(user_id)["videos"]) == 0:
queueDB.get(user_id)["videos"].append(m.id)
# if len(queueDB.get(user_id)["videos"])==1:
Expand Down
6 changes: 3 additions & 3 deletions plugins/cb_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def callback_handler(c: Client, cb: CallbackQuery):
if os.path.exists(f"userdata/{cb.from_user.id}/rclone.conf") is False:
await cb.message.delete()
await delete_all(root=f"downloads/{cb.from_user.id}/")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return
UPLOAD_TO_DRIVE.update({f"{cb.from_user.id}": True})
Expand Down Expand Up @@ -170,7 +170,7 @@ async def callback_handler(c: Client, cb: CallbackQuery):

elif cb.data == "cancel":
await delete_all(root=f"downloads/{cb.from_user.id}/")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
await cb.message.edit("Sucessfully Cancelled")
await asyncio.sleep(5)
Expand All @@ -193,7 +193,7 @@ async def callback_handler(c: Client, cb: CallbackQuery):
cache_time=0,
)
await delete_all(root=f"downloads/{cb.from_user.id}/")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return

Expand Down
16 changes: 8 additions & 8 deletions plugins/mergeVideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def mergeNow(c: Client, cb: CallbackQuery, new_file_name: str):
vid_list.append(f"file '{file_dl_path}'")
except:
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
await cb.message.edit("⚠️ Video is corrupted")
return
Expand All @@ -115,7 +115,7 @@ async def mergeNow(c: Client, cb: CallbackQuery, new_file_name: str):
if merged_video_path is None:
await cb.message.edit("❌ Failed to merge video !")
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return
try:
Expand All @@ -134,19 +134,19 @@ async def mergeNow(c: Client, cb: CallbackQuery, new_file_name: str):
if UPLOAD_TO_DRIVE[f"{cb.from_user.id}"]:
await rclone_driver(omess, cb, merged_video_path)
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return
if file_size > 2044723200 and Config.IS_PREMIUM == False:
await cb.message.edit(f"Video is Larger than 2GB Can't Upload,\n\n Tell {Config.OWNER_USERNAME} to add premium account to get 4GB TG uploads")
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return
if Config.IS_PREMIUM and file_size > 4241280205:
await cb.message.edit(f"Video is Larger than 4GB Can't Upload,\n\n Tell {Config.OWNER_USERNAME} to die with premium account")
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return
await cb.message.edit("🎥 Extracting Video Data ...")
Expand All @@ -157,7 +157,7 @@ async def mergeNow(c: Client, cb: CallbackQuery, new_file_name: str):
duration = metadata.get("duration").seconds
except Exception as er:
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
await cb.message.edit("⭕ Merged Video is corrupted")
return
Expand Down Expand Up @@ -185,7 +185,7 @@ async def mergeNow(c: Client, cb: CallbackQuery, new_file_name: str):
Image.open(video_thumbnail).convert("RGB").save(video_thumbnail, "JPEG")
except:
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
await cb.message.edit("⭕ Merged Video is corrupted")
return
Expand All @@ -202,6 +202,6 @@ async def mergeNow(c: Client, cb: CallbackQuery, new_file_name: str):
)
await cb.message.delete(True)
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return
14 changes: 7 additions & 7 deletions plugins/mergeVideoAudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async def mergeAudio(c: Client, cb: CallbackQuery, new_file_name: str):
if muxed_video is None:
await cb.message.edit("❌ Failed to add audio to video !")
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "audios": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return
try:
Expand All @@ -90,20 +90,20 @@ async def mergeAudio(c: Client, cb: CallbackQuery, new_file_name: str):
# uploads to drive using rclone
await rclone_driver(omess, cb, merged_video_path)
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "audios": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return

if file_size > 2044723200 and Config.IS_PREMIUM == False:
await cb.message.edit(f"Video is Larger than 2GB Can't Upload,\n\n Tell {Config.OWNER_USERNAME} to add premium account to get 4GB TG uploads")
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return
if Config.IS_PREMIUM and file_size > 4241280205:
await cb.message.edit(f"Video is Larger than 4GB Can't Upload,\n\n Tell {Config.OWNER_USERNAME} to die with premium account")
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return
await cb.message.edit("🎥 Extracting Video Data ...")
Expand All @@ -115,7 +115,7 @@ async def mergeAudio(c: Client, cb: CallbackQuery, new_file_name: str):
duration = metadata.get("duration").seconds
except Exception as er:
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "audios": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
await cb.message.edit("⭕ Merged Video is corrupted")
return
Expand Down Expand Up @@ -143,7 +143,7 @@ async def mergeAudio(c: Client, cb: CallbackQuery, new_file_name: str):
Image.open(video_thumbnail).convert("RGB").save(video_thumbnail, "JPEG")
except:
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "audios": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
await cb.message.edit(
"⭕ Merged Video is corrupted \n\n<i>Try setting custom thumbnail</i>",
Expand All @@ -162,6 +162,6 @@ async def mergeAudio(c: Client, cb: CallbackQuery, new_file_name: str):
)
await cb.message.delete(True)
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "audios": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return
14 changes: 7 additions & 7 deletions plugins/mergeVideoSub.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def mergeSub(c: Client, cb: CallbackQuery, new_file_name: str):
if subbed_video is None:
await cb.message.edit("❌ Failed to add subs video !")
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return
try:
Expand All @@ -101,19 +101,19 @@ async def mergeSub(c: Client, cb: CallbackQuery, new_file_name: str):
if UPLOAD_TO_DRIVE[f"{cb.from_user.id}"]:
await rclone_driver(omess, cb, merged_video_path)
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return
if file_size > 2044723200 and Config.IS_PREMIUM == False:
await cb.message.edit(f"Video is Larger than 2GB Can't Upload,\n\n Tell {Config.OWNER_USERNAME} to add premium account to get 4GB TG uploads")
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return
if Config.IS_PREMIUM and file_size > 4241280205:
await cb.message.edit(f"Video is Larger than 4GB Can't Upload,\n\n Tell {Config.OWNER_USERNAME} to die with premium account")
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return
await cb.message.edit("🎥 Extracting Video Data ...")
Expand All @@ -125,7 +125,7 @@ async def mergeSub(c: Client, cb: CallbackQuery, new_file_name: str):
duration = metadata.get("duration").seconds
except Exception as er:
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
await cb.message.edit("⭕ Merged Video is corrupted")
return
Expand Down Expand Up @@ -153,7 +153,7 @@ async def mergeSub(c: Client, cb: CallbackQuery, new_file_name: str):
Image.open(video_thumbnail).convert("RGB").save(video_thumbnail, "JPEG")
except:
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
await cb.message.edit(
"⭕ Merged Video is corrupted \n\n<i>Try setting custom thumbnail</i>",
Expand All @@ -172,6 +172,6 @@ async def mergeSub(c: Client, cb: CallbackQuery, new_file_name: str):
)
await cb.message.delete(True)
await delete_all(root=f"./downloads/{str(cb.from_user.id)}")
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": []}})
queueDB.update({cb.from_user.id: {"videos": [], "subtitles": [], "audios":[]}})
formatDB.update({cb.from_user.id: None})
return

0 comments on commit 8fd54a1

Please sign in to comment.