How zona05/spotify-dynamic-list works
Main Components
• Spotify API Integration & Authentication: The script (SpotifyDynamic.py) handles OAuth-based authentication to securely connect with Spotify.
• Data Management: Two JSON files (canciones_favoritas.json and generos_filtrados.json) serve as local storage for the user’s favorite songs and for filtered genres (those with at least 10 songs).
• Playlist Management Logic: Within SpotifyDynamic.py, this logic selects a random valid genre, checks whether a “Dynamic Playlist” exists, and creates or updates it accordingly.
• Scheduled Automation: The GitHub Actions workflow (.github/workflows/main.yml) is responsible for triggering the script daily at midnight (UTC).
• Dependencies and Environment Setup: The requirements.txt file specifies the necessary packages, ensuring the environment is set up correctly to run the script.
Out the Relationships and Interactions
• The “User / Client” provides necessary Spotify credentials (configured on the Spotify Developer Dashboard) which are used by the OAuth authentication flow.
• The “SpotifyDynamic.py” script:
• Initiates with OAuth authentication.
• Reads the local JSON files to gather data about favorite songs and genre counts.
• Calls the Spotify API to fetch/update the playlist based on the selected random genre.
• Data flows:
• From the JSON files to the script’s processing logic.
• From the script to Spotify via API calls for playlist creation/updating.
• The GitHub Actions workflow triggers the script automatically, simulating a “scheduler” that executes the logic on a daily basis.
Architectural Pattern and Design Principles
• Even though the project is a relatively straightforward script, it demonstrates a separation of concerns by isolating API authentication, data management, and playlist handling.
• It also follows practices for automation, ensuring regular updates via CI/CD (GitHub Actions).
• The design essentially resembles a microservice or scheduled task with clearly defined input (data in JSON, API credentials) and output (playlist creation/updating via the Spotify API).
Elements
• Clear Labels: Name each component (e.g., "OAuth Authentication", "Data Management", "Playlist Manager", "GitHub Actions Scheduler", "Spotify API").