From e5e64bd7c17bd3b7b7f73fc996f14357234bad9f Mon Sep 17 00:00:00 2001 From: Firepup Sixfifty Date: Mon, 6 May 2024 09:36:31 -0500 Subject: [PATCH] Try to have the radio dynamically adjust miss rates, based on success rates. --- threads.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/threads.py b/threads.py index 08075a9..85da3ce 100644 --- a/threads.py +++ b/threads.py @@ -79,22 +79,32 @@ def radio(instance: bare.bot) -> NoReturn: lastTrack = "" complained = False firstMiss = False + misses = 0 + missChunk = 0 + missCap = -5 + perChunk = 10 while 1: try: newTrack = instance.lastfmLink.get_user("Firepup650").get_now_playing() if newTrack: complained = False - firstMiss = False thisTrack = newTrack.__str__() if thisTrack != lastTrack: + misses = 0 + missChunk = 0 lastTrack = thisTrack instance.msg("f.sp " + thisTrack, "#fp-radio") instance.sendraw( f"TOPIC #fp-radio :Firepup radio ({thisTrack}) - https://open.spotify.com/playlist/4ctNy3O0rOwhhXIKyLvUZM" ) + elif misses > missCap: + missChunk +=1 + if missChunk >= perChunk: + misses -= 1 + missChunk = 0 elif not complained: - if not firstMiss: - firstMiss = True + if misses < 0: + misses += 1 continue instance.msg( "Firepup seems to have stopped the music by mistake :/", "#fp-radio"