Link to home
Start Free TrialLog in
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.
ASKER CERTIFIED SOLUTION
Avatar of Flabio Gates
Flabio Gates

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Flabio Gates
Flabio Gates

OP is inactive