Last active
July 12, 2023 11:51
-
-
Save yusufusta/02ef3199fa7d421f0382f8cbb3d55788 to your computer and use it in GitHub Desktop.
find Spotify UnFollowers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import spotify_token as st | |
| from requests import get, delete | |
| SETTINGS = { | |
| "UNFOLLOW": True, | |
| "ARTIST_UNFOLLOW": True | |
| } | |
| account_id = 'ar5xr05io7p2lrvlzz8cgpz7f' | |
| data = st.start_session("sp_dc","sp_key") # Login spotify with Chrome then open Cookie manager and find 'sp_dc' and 'sp_key' | |
| following = [[profile['uri'], profile['name']] for profile in get(f"https://spclient.wg.spotify.com/user-profile-view/v3/profile/{account_id}/following?market=from_token", | |
| headers={'Authorization': 'Bearer ' + data[0]}).json()['profiles']] | |
| followers = [[profile['uri'], profile['name']] for profile in get(f"https://spclient.wg.spotify.com/user-profile-view/v3/profile/{account_id}/followers?market=from_token", | |
| headers={'Authorization': 'Bearer ' + data[0]}).json()['profiles']] | |
| i = 0 | |
| for user in following: | |
| if not user in followers: | |
| if SETTINGS["UNFOLLOW"]: | |
| user_id = user[0].split(':')[-1] | |
| if user[0].split(':')[-2] == "artist" and SETTINGS["ARTIST_UNFOLLOW"]: | |
| delete( | |
| f"https://api.spotify.com/v1/me/following?type=artist&ids={user_id}", headers={'Authorization': 'Bearer ' + data[0]}) | |
| print(f"Artist Unfollowed: {user[1]} ({user_id})") | |
| i += 1 | |
| continue | |
| delete( | |
| f"https://api.spotify.com/v1/me/following?type=user&ids={user_id}", headers={'Authorization': 'Bearer ' + data[0]}) | |
| print(f"User Unfollowed: {user[1]} ({user_id})") | |
| i += 1 | |
| else: | |
| print( | |
| f"{ 'Artist' if (user[0].split(':')[-2] == 'artist') else 'User'} not following you: {user[1]} ({user_id})") | |
| print( | |
| f"{ 'Successfully unfollowed' if SETTINGS['UNFOLLOW'] else 'Found' } {i} user/artist") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how do i use this?