Skip to content

Commit

Permalink
Fix error thrown when non-yt link is used. (#2374)
Browse files Browse the repository at this point in the history
* Fix error thrown when non-yt link is used.

* run black
  • Loading branch information
itsTheFae committed Dec 18, 2023
1 parent e11464f commit 7cde7ad
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions musicbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,17 +719,21 @@ async def on_player_play(self, player, entry):
url,
)

content = self._gen_embed()
if match:
# TODO: come up with a good way to extract thumbnails from ytdl data.
videoID = match.group(1)
content.set_image(
url=f"https://i1.ytimg.com/vi/{videoID}/hqdefault.jpg"
)
else:
log.error("Unknown link or unable to get video ID.")
content = self._gen_embed()

if self.config.now_playing_mentions:
content.title = None
content.add_field(name="\n", value=newmsg, inline=True)
else:
content.title = newmsg
content.set_image(url=f"https://i1.ytimg.com/vi/{videoID}/hqdefault.jpg")

# send it in specified channel
self.server_specific_data[guild]["last_np_msg"] = await self.safe_send_message(
Expand Down Expand Up @@ -3287,8 +3291,11 @@ async def cmd_np(self, player, channel, guild, message):
url,
)

thumb_url = None
if match:
# TODO: come up with a good way to extract thumbnails from the ytdl data.
videoID = match.group(1)
thumb_url = f"https://i1.ytimg.com/vi/{videoID}/hqdefault.jpg"
else:
log.error("Unknown link or unable to get video ID.")

Expand All @@ -3302,9 +3309,8 @@ async def cmd_np(self, player, channel, guild, message):
content.add_field(
name=f"Currently {action_text}", value=np_text, inline=True
)
content.set_image(
url=f"https://i1.ytimg.com/vi/{videoID}/hqdefault.jpg"
)
if thumb_url:
content.set_image(url=thumb_url)

self.server_specific_data[guild][
"last_np_msg"
Expand Down

0 comments on commit 7cde7ad

Please sign in to comment.