如何自动将指定艺人新曲目添加至Spotify「My Favorites」播放列表?
Absolutely! You can totally automate adding your favorite artist’s new Spotify tracks to your "My Favorites" playlist the second they drop. Here are a few solid options depending on how technical you want to get:
Automated Workflow to Add New Artist Tracks to Spotify Playlist
Option 1: No-Code Tools (Quick & Easy)
If you don’t want to mess with code, tools like Zapier or IFTTT make this super straightforward:
Zapier Setup
- Connect your Spotify account to Zapier.
- Create a new Zap with the trigger:
Spotify > New Track by Artist. Search for your target artist and confirm their profile (watch out for name duplicates!). - Add an action step:
Spotify > Add Track to Playlist. Select your "My Favorites" playlist from the dropdown. - Test the Zap and turn it on—from now on, any new track the artist releases will automatically get added to your playlist.
IFTTT Setup
- Sign up/in to IFTTT and connect your Spotify account.
- Create a new Applet. For the trigger, choose
Spotify > New release from artistand select your artist. - For the action, choose
Spotify > Add track to playlistand pick "My Favorites". - Save the Applet, and you’re done!
Option 2: Custom Python Script (More Control)
If you’re comfortable with a little code, a Python script gives you full control over how you filter and add tracks. Here’s how to set it up:
Prerequisites
- Sign up for a Spotify Developer Account, create a new App, and grab your Client ID, Client Secret, then set a redirect URI like
http://localhost:8888/callback. - Install the
spotipylibrary via pip:
pip install spotipy
Sample Script
Replace the placeholder values with your own details:
import spotipy from spotipy.oauth2 import SpotifyOAuth from datetime import datetime, timedelta # Your Spotify API credentials CLIENT_ID = "your_client_id_here" CLIENT_SECRET = "your_client_secret_here" REDIRECT_URI = "http://localhost:8888/callback" # Target artist and playlist IDs (find these in Spotify's web URL) ARTIST_ID = "target_artist_spotify_id" PLAYLIST_ID = "my_favorites_playlist_id" # Initialize Spotify client with required scopes sp = spotipy.Spotify(auth_manager=SpotifyOAuth( client_id=CLIENT_ID, client_secret=CLIENT_SECRET, redirect_uri=REDIRECT_URI, scope="playlist-modify-public playlist-read-private" )) def get_recent_artist_tracks(days=30): """Fetch tracks the artist released in the last X days""" recent_tracks = [] # Get latest albums and singles albums = sp.artist_albums(ARTIST_ID, album_type="album,single", limit=10)["items"] for album in albums: release_date = datetime.strptime(album["release_date"], "%Y-%m-%d") if release_date >= datetime.now() - timedelta(days=days): # Get all tracks from the album/single tracks = sp.album_tracks(album["id"])["items"] recent_tracks.extend([track["id"] for track in tracks]) return list(set(recent_tracks)) # Avoid duplicates def get_existing_playlist_tracks(): """Fetch all tracks already in your playlist""" existing_tracks = [] results = sp.playlist_tracks(PLAYLIST_ID) while results: existing_tracks.extend([item["track"]["id"] for item in results["items"]]) results = sp.next(results) return existing_tracks def add_new_tracks_to_playlist(): """Compare recent tracks with existing ones and add new ones""" recent_tracks = get_recent_artist_tracks() existing_tracks = get_existing_playlist_tracks() tracks_to_add = [track for track in recent_tracks if track not in existing_tracks] if tracks_to_add: sp.playlist_add_items(PLAYLIST_ID, tracks_to_add) print(f"Successfully added {len(tracks_to_add)} new track(s) to 'My Favorites'!") else: print("No new tracks to add right now.") if __name__ == "__main__": add_new_tracks_to_playlist()
Schedule the Script
To make this run automatically:
- On Linux/macOS: Use
cronto schedule the script to run daily (e.g., once every 24 hours). - On Windows: Use Task Scheduler to set up a recurring task that runs the script.
Tips & Notes
- To find an artist/playlist ID: Go to their page on Spotify’s web app, look at the URL— the long string of characters at the end is the ID.
- For the script, adjust the
daysparameter inget_recent_artist_tracks()to check for releases over a different time frame. - If your playlist is private, make sure the
scopein the script includesplaylist-modify-privateinstead ofplaylist-modify-public.
内容的提问来源于stack exchange,提问作者Behzod A
相关产品推荐
相关产品推荐

