Merge pull request #30 from ilkergzlkkr/main
Never search for spotify track that searched before
This commit is contained in:
commit
e04aa9ba30
|
|
@ -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",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue