Skip to content

Commit

Permalink
fix all exceptions hopefully
Browse files Browse the repository at this point in the history
  • Loading branch information
xAmarnath committed May 5, 2024
1 parent 3f7d000 commit fdfe678
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion modules/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ def generate_thumbnail(in_filename, out_filename):


def get_video_metadata(file):
data = ffmpeg.probe(file)
try:
data = ffmpeg.probe(file)
return (
int(data.get("format", {}).get("duration", "0").split(".")[0]),
data.get("streams", [])[0].get("width", 1),
Expand Down
4 changes: 2 additions & 2 deletions modules/custdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ async def episode_x(e):
import time

def generate_ffmpeg_command(mp4_file_path, subs):
ffmpeg_command = ['ffmpeg', '-y', '-i', mp4_file_path]
ffmpeg_command = ['ffmpeg', '-y', '-i', '"{}"'.format(mp4_file_path)]

for sub in subs:
ffmpeg_command.extend(['-i', sub["file"]])
Expand All @@ -227,7 +227,7 @@ def generate_ffmpeg_command(mp4_file_path, subs):
ffmpeg_command.extend(['-map', f'{i + 1}:s:0'])
ffmpeg_command.extend(['-metadata:s:s:%d' % i, 'language=' + subs[i]["label"]])

ffmpeg_command.extend(['-c', 'copy', output_file_path])
ffmpeg_command.extend(['-c', 'copy', '"{}"'.format(output_file_path)])

return ffmpeg_command

Expand Down
18 changes: 10 additions & 8 deletions modules/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
@new_cmd(pattern="ping")
async def _ping_cmd(e):
uptime = time.time() - StartTime

ping_start = time.time()
msg = await e.reply("Pong!")

end_ping = time.time() - ping_start
await msg.edit(f"**Pong!** `{end_ping * 1000:.3f}ms`\n**Uptime:** `{uptime:.2f}`")



@newIn(pattern="s (.*)")
Expand Down Expand Up @@ -446,11 +445,14 @@ async def upload_decorator(e, files, chat, caption: str, directory: str):
caption = filename
filename = filename.split("/")[-1] if filename == l else filename
if l.endswith(("mp4", "mkv", "3gp", "webm")):
thumb = (
generate_thumbnail(l, l + "_thumb.jpg")
if len(thumbs) == 0
else thumbs[0]
)
try:
thumb = (
generate_thumbnail(l, l + "_thumb.jpg")
if len(thumbs) == 0
else thumbs[0]
)
except:
thumb = None if len(thumbs) == 0 else thumbs[0]
d, w, h = get_video_metadata(l)
attributes = [
types.DocumentAttributeVideo(
Expand Down

0 comments on commit fdfe678

Please sign in to comment.