Merge pull request #30 from ilkergzlkkr/main

Never search for spotify track that searched before
This commit is contained in:
Clxud 2022-08-29 19:37:01 -04:00 committed by GitHub
commit e04aa9ba30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -291,7 +291,8 @@ class Player(VoiceProtocol):
ignore_if_playing: bool = False ignore_if_playing: bool = False
) -> Track: ) -> Track:
"""Plays a track. If a Spotify track is passed in, it will be handled accordingly.""" """Plays a track. If a Spotify track is passed in, it will be handled accordingly."""
if track.spotify: # Make sure we've never searched the track before
if track.original is None:
# First lets try using the tracks ISRC, every track has one (hopefully) # First lets try using the tracks ISRC, every track has one (hopefully)
try: try:
if not track.isrc: if not track.isrc:
@ -299,7 +300,7 @@ class Player(VoiceProtocol):
raise raise
search: Track = (await self._node.get_tracks( search: Track = (await self._node.get_tracks(
f"{track._search_type}:{track.isrc}", ctx=track.ctx))[0] f"{track._search_type}:{track.isrc}", ctx=track.ctx))[0]
except: except Exception:
# First method didn't work, lets try just searching it up # First method didn't work, lets try just searching it up
try: try:
search: Track = (await self._node.get_tracks( search: Track = (await self._node.get_tracks(
@ -317,6 +318,8 @@ class Player(VoiceProtocol):
"noReplace": ignore_if_playing "noReplace": ignore_if_playing
} }
track.original = search track.original = search
track.track_id = search.track_id
# Set track_id for later lavalink searches
else: else:
data = { data = {
"op": "play", "op": "play",