Avatar of Paul Cresswell
Paul Cresswell
 asked on

Help with a small script i am trying to write

Hi, I am trying to write a python script that will tweet the name and artist of a song when it plays. I have achieved this but the problem I have is when the player stops or I pause or forward the song the script crashes.
My code so far is

lastSong = None
while True:
   currentSong = client.currentsong()
   if currentSong != lastSong:
        api.update_status(status= currentSong['artist'] + " - " + currentSong['title'] + "\n" + "#NowPlaying" + " #" +  currentSong['artist'].translate(None, whitespace))
        lastSong = currentSong
time.sleep(59) #change this to however often you wanna poll.

Any help would be great. Thanks.
Python

Avatar of undefined
Last Comment
Flabio Gates

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Flabio Gates

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Flabio Gates

OP is inactive
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23