Connects Spotify + Google Apps Script + Twitter. Has functionality like converting a Spotify playlist to a Google Sheet and Tweeting every entry in it. Can set to run on a trigger if you want an update every hour or so.
- Output list of Spotify playlist(s) to a Google Sheet
- Output all Spotify playlists to their Google Sheets
- Tweet every entry in a playlist so when you add a song to a playlist, it shares on Twitter (NOTE [May 2024] - this functionality is no longer being tested after Twitter started circling the drain so this can be considered deprecated)
- Add all songs from a rotating playlist (e.g. Discover Weekly & Release Radar) to a static playlist on a weekly basis so you don't miss the recommended songs when they refresh
- Add all songs/features from an artist to their own playlist
- Remove songs from a playlist if they've already been detected in another playlist
- Remove songs from a playlist if it's greyed out (unplayable)
- You can either import the scripts from this repo manually or use the plugin Google Apps Script GitHub Assistant to import: https://chrome.google.com/webstore/detail/google-apps-script-github/lfjcgcmkmjjlieihflfhjopckgpelofo
- Go to https://developer.spotify.com/dashboard/applications and sign in with your Spotify account.
- Create an app. Call it something simple like "Google Sheets Spotify Connector".
- Save your Client ID and Client Secret. Insert them above the
getSpotifyService_()
function in `spotify_oauth/getSpotifyService.gs. - Save the Redirect URI for your script. It is https://script.google.com/macros/d/<>/usercallback where <> is the script ID in the URL or in your script Project Settings. I saved it in
spotify_oauth/getSpotifyData.gs
for ease. - At https://developer.spotify.com/dashboard/applications, click on your app and Edit Settings. Add the Redirect URI created above. Save.
- Run one of the Spotify functions mentioned below or in
_primary/spotifyToGoogleSheets
. - On the first run through you'll see a URL generated in the Console Log: "Open the following URL and re-run the script: <>". Open the URL in a new tab.
- Agree to the Spotify app authorization request to authorize your script using OAuth.
- When you see "Success! You can close this tab.", go back to the script and re-run the function
spotifyToGoogleSheets()
in_primary/spotifyToGoogleSheets.gs
.
NOTE [May 2024] - this functionality is no longer being tested after Twitter started circling the drain so this can be considered deprecated
- Create a Twitter Developer account and create a new app: https://developer.twitter.com/en/portal/dashboard
- Save the keys and tokens from your new Twitter app in the
sendTweet()
function inhelpers/twitterFunctions.gs
. - If not already added, add the OAuth2 Library by the Script ID:
1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF
. Use the latest version. - If not already added, add the Twitter Library by the Script ID:
11dB74uW9VLpgvy1Ax3eBZ8J7as0ZrGtx4BPw7RKK-JQXyAJHBx98pY-7
. Use the latest version and name itTwitter
. - Enter the playlist IDs in
_primary/addSongsToPlaylistFromAnotherPlaylist
. - Change
var sheetName
in functionspotifyToGoogleSheets()
to whatever you want to be the name of the sheet. - Run
Tweet New Entries in a Playlist
from the Google Sheet orspotifyToGoogleSheets()
from Google Apps Script in_primary/spotifyToGoogleSheets
. Every entry in this playlist will be tweeted. The next time you run this function, it will compare the playlist with the entries in the sheet. If there are new entries (i.e. you added new songs to the playlist and it grabbed them), it will tweet them too. If you want to do this periodically and automatically, create a trigger to run this function about once an hour. Any more often and you might be rate limited by the API.
- Run
Print Playlists to a Google Sheet
from the Google Sheet orgetPlaylists()
from Google Apps Script inspotify_oauth/getPlaylists
. This will print your playlists to the "Playlists" sheet.
- Run
Get Content of All Playlists
from the Google Sheet orprintAllPlaylists()
from Google Apps Script in_primary/printAllPlaylists
. This will print all your playlist contents to the spreadsheet with each sheet being a different sheet. If you want to activate and move certain sheets to the front when the spreadsheet is open, updatevar faveSheets
for the functiononOpen()
in_primary/onOpen.gs
with the names of these sheets.
- Run
addSongsToPlaylistFromAnotherPlaylist()
from Google Apps Script. This will get the specified Spotify playlists, grab the songs, and add to a Google Sheet and another playlist. Helpful for adding tracks from weekly changing playlists (e.g. Discover Weekly, Release Radar) to a static one. - If you want to specify different playlists, update the variables in
_primary/addSongsToPlaylistFromAnotherPlaylist()
.
- Run
Add songs from an artist to a new playlist
from the Google Sheet. This will get the specified Spotify artist, grab the songs, add to a Google Sheet and then add to a new playlist. Helpful for checking out an artist's album songs, singles, and features. - Run
Add songs from an artist to My Current Playlist
from the Google Sheet. This will get the specified Spotify artist, grab the songs, add to a Google Sheet and then add to a specified playlist instead of a new one. - If you want to specify a different playlist, update the variables in
_primary/addToArtistPlaylist
.
- Go to
spotifyDeDuper.gs
and underRunnerForDeDuper()
, there are a couple functions to run. Uncomment the one you'd like to run and comment the other ones. Would only recommend running one at a time to not surpass the 5 minute limit. These are limited to ~25 tracks per batch so if you have more in your playlist, create a trigger to rerun theRunnerForDeDuper()
function every 10 minutes or so until it is no longer returning entries.
spotifyDeduper(playlist1ID, playlist2ID)
: Compares tracks between two Spotify playlists and removes songs from the second playlist if they are also found in the first.spotifySingleDeduper(playlistID)
: Finds duplicate tracks within a Spotify playlist and prints them to a Google Sheet.
removeUnavailableTracks(playlistID)
: Removes tracks from a Spotify playlist that are unavailable in any markets and have no preview URL.