Skip to content

Commit

Permalink
fixed downloading song before checking duration UsergeTeam#325 (Userg…
Browse files Browse the repository at this point in the history
…eTeam#327)

* fixed downloading song before checking duration UsergeTeam#325

* now 'okay'

* done
  • Loading branch information
Krishna-Singhal authored May 10, 2021
1 parent 3c8545e commit be1dcd0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions userge/plugins/utils/voice_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ async def play_music(msg: Message):
async def force_play_music(msg: Message):
""" Force play music in voice call """

if not QUEUE:
if not PLAYING:
return await play_music(msg)

if msg.input_str:
Expand All @@ -297,6 +297,7 @@ async def force_play_music(msg: Message):
QUEUE.insert(0, msg)
else:
await mesg.edit("No results found.")
return
elif msg.reply_to_message and msg.reply_to_message.audio:
replied = msg.reply_to_message
QUEUE.insert(0, replied)
Expand Down Expand Up @@ -611,9 +612,12 @@ def mp3_down(url: str):
}

with ytdl.YoutubeDL(ydl_opts) as ydl:
info = ydl.extract_info(url)
if info.get("duration") > Config.MAX_DURATION:
return False
info = ydl.extract_info(url, download=False)

if info.get("duration") > Config.MAX_DURATION:
return False

ydl.download([url])

return info.get("title"), time_formatter(info.get("duration"))

Expand Down

0 comments on commit be1dcd0

Please sign in to comment.