Skip to content

Commit

Permalink
chore: video codec
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Oct 12, 2023
1 parent c4766fc commit 04980e1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
6 changes: 3 additions & 3 deletions bot/commands/play_song.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async def _(client: Client, message: Message):
if message.reply_to_message.audio
else round((message.reply_to_message.voice.duration / 60), 2)
)
mention = (
file = (
f"https://t.me/c/{message.chat.id}/{message.reply_to_message.id}".replace(
"/c/-100", "/c/"
)
Expand All @@ -136,7 +136,7 @@ async def _(client: Client, message: Message):
position=position,
)
return await _message.edit(
f"__Added to queue at {position} \n\n Title: [{type_of}]({mention})\nDuration: {duration} Minutes\n Requested by:__ [{data['first_name']}]({data['mention']})",
f"__Added to queue at {position} \n\n Title: [{type_of}]({file})\nDuration: {duration} Minutes\n Requested by:__ [{data['first_name']}]({data['mention']})",
reply_markup=InlineKeyboardMarkup(
[[InlineKeyboardButton("cʟᴏꜱᴇ", callback_data="close")]]
),
Expand Down Expand Up @@ -167,7 +167,7 @@ async def _(client: Client, message: Message):
await _message.delete()
await kreacher.send_photo(
message.chat.id,
caption=f"**__Started Streaming__**\n\n **Title:** [{type_of}]({mention})\n **Requested by:** [{data['first_name']}]({data['mention']})",
caption=f"**__Started Streaming__**\n\n **Title:** [{type_of}]({file})\n **Requested by:** [{data['first_name']}]({data['mention']})",
photo=fotoplay,
reply_markup=InlineKeyboardMarkup(
[
Expand Down
34 changes: 24 additions & 10 deletions bot/commands/play_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,32 @@ async def _(client: Client, message: Message):
)
return await _message.pin()
if message.reply_to_message.video or message.reply_to_message.file:
await _message.edit("🔄 **__Downloading...__**")
media = await assistant.download_media(
message.reply_to_message.video,
file_name=file_name,
progress=progress,
progress_args=(client, message.chat.id, _message.id),
file_name = (
f"/tmp/{str(uuid.uuid4())}.{message.reply_to_message.video.mime_type.split('/', 1)[1]}"
if message.reply_to_message.video
else f"/tmp/{str(uuid.uuid4())}.mp4"
)
type_of = "Video File"
duration = (
round((message.reply_to_message.video.duration / 60), 2)
if message.reply_to_message.video
else round((message.reply_to_message.file.duration / 60), 2)
)
file = f"https://t.me/c/{message.chat.id}/{message.reply_to_message.id}".replace(
"/c/-100", "/c/"
)
if str(message.chat.id) in get_queues():
position = get_last_position_in_queue(str(message.chat.id)) + 1
add_or_create_queue(
str(message.chat.id),
from_user=str(message.from_user.id),
date=str(datetime.now()),
file=media,
file=file_name,
type_of="video_media",
position=position,
)
return await _message.edit(
f"__Added to queue at {position} \n\n Title: [{name}]({url})\nDuration: {duration} Minutes\n Requested by:__ [{data['first_name']}]({data['mention']})",
f"__Added to queue at {position}\n\nTitle: [{type_of}]({file})\nDuration: {duration} Minutes\nRequested by:__ [{data['first_name']}]({data['mention']})",
reply_markup=InlineKeyboardMarkup(
[[InlineKeyboardButton("cʟᴏꜱᴇ", callback_data="close")]]
),
Expand All @@ -190,9 +197,16 @@ async def _(client: Client, message: Message):
from_user=str(message.from_user.id),
date=str(datetime.now()),
is_playing=True,
file=media,
file=file_name,
type_of="video_media",
)
await _message.edit("💾 **__Downloading...__**")
media = await assistant.download_media(
message.reply_to_message,
file_name=file_name,
progress=progress,
progress_args=(client, message.chat.id, _message.id),
)
if VOICE_CHATS.get(message.chat.id) is None:
await _message.edit("**__Joining the voice chat...__** \u23F3")
await tgcalls.start(message.chat.id)
Expand All @@ -210,7 +224,7 @@ async def _(client: Client, message: Message):
[
InlineKeyboardButton("⏪", callback_data="back"),
InlineKeyboardButton(
"\u23F8\uFE0F",
"⏸️",
callback_data="pause_or_resume",
),
InlineKeyboardButton("⏭️", callback_data="next"),
Expand Down
1 change: 0 additions & 1 deletion bot/helpers/progress.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
from random import randint


def bytes_to_string(byte_count):
Expand Down

0 comments on commit 04980e1

Please sign in to comment.