Open difrost opened 4 months ago
As a quick check I've done a cast to int and that "fixes" the issue:
if random_song:
if uri.find("album") > 0:
results = client.album_tracks(uri, market=country_code)
position = random.randint(0, int(results["total"]) - 1)
elif uri.find("playlist") > 0:
results = client.playlist_tracks(uri)
position = random.randint(0, int(results["total"]) - 1)
elif uri.find("collection") > 0:
results = client.current_user_saved_tracks()
position = random.randint(0, int(results["total"]) - 1)
_LOGGER.debug(
"Start playback at random position: %s", position)
I'm not sure if that's correct tho can't find a reason why direct cast might cause some future errors. I can make a PR for review.
NOTE: I'm not a Python dev :smile:
Thanks for the info. If you submit a pr can you just add a comment saying
# TODO: review random position algo
I want to revisit it later, but at least we could fix the dependency issue quick.
Bug Ticket
Describe the bug
Due to the
randrange()
changes introduced in Python 3.12 Spotcast raise an TypeError:See following note:
Troubleshooting
Make sure to validate all the elements before submitting the ticket (Exception to the steps marked as optional)
sp_dc
andsp_key
values and restarted Home Assistant (see README)Environment