radi8 — 4/30/2023, 11:41:49 PM

look at the end of my bio (real)

♥ 10 ↩ 0 💬 9 comments

comments

grippins:

innovative

5/1/2023, 12:49:01 AM
radi8:

ye

5/1/2023, 12:50:49 AM
stareye:

wow

5/1/2023, 12:17:17 AM
radi8:

yes

5/1/2023, 12:17:28 AM
radi8:

it updates whenever I listen to music

5/1/2023, 12:17:53 AM
stareye:

that is awesome (how do you do that)

5/1/2023, 2:36:51 AM
radi8:
import spotipy
import spotipy.util as util
import requests
import json
import time

client_id = 'redacted'
client_secret = 'redacted'
redirect_uri = 'http://localhost:8090/callback'
username = 'redacted'
scope = 'user-read-currently-playing'

token = util.prompt_for_user_token(username, scope, client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri)

if token:
    sp = spotipy.Spotify(auth=token)
    while True:
        # Get the user's currently playing track
        track = sp.current_user_playing_track()
        if track:
            title = track['item']['name']
            author = track['item']['artists'][0]['name']
        else:
            title = 'Not listening'
            author = ''

        data = {'title': title, 'author': author}
        print(data)
        currentbio = requests.get("https://api.wasteof.money/users/username/bio").json()["bio"]
        currentbio = currentbio.split("​")[0]
        if title == "Not listening":
            newbio = currentbio + "​ | Not listening to anything on Spotify"
        else:
            if author == "":
                newbio = currentbio + f"​ | Listening to {title} on Spotify"
            else:
                newbio = currentbio + f"​ | Listening to {title} by {author} on Spotify"
        setbio = requests.put("https://api.wasteof.money/users/username/bio", json = {"bio": newbio}, headers = {"Authorization": "redacted"})
        print(setbio.json())
        time.sleep(15)
else:
    print("Can't get token for", username)
5/1/2023, 12:12:36 PM
stareye:

cool

5/1/2023, 2:17:21 PM
radi8:

ye

5/1/2023, 3:08:15 PM