ENDLESS A NEVER ENDING PLAYLIST - SPOTIFY PYTHON & SQL PROJECT. OVERVIEW By simply using just 2 playlists, MASTER and QUEUE, plus SQL lite, and a couple of Python scripts, it's possible to create an endless playlist. The MASTER playlist (can be any name you want as the playlist URI is stored in 'secrets.py' The MASTER is used to hold all of your favorite tracks and the QUEUE playlist will contain and maintain up to 50 tracks for listening. (also needs the URI added to 'secrets.py' You can think of ENDLESS as a library of tracks (the MASTER), that you can only see a small part of in (the QUEUE) playlist, that gets updated when the ENDLESS app runs. Every hour (configurable), ENDLESS takes the tracks you listened to (if any), deletes them, and adds more tracks at random to the QUEUE from the MASTER playlist, using Python and SQL. If you listen to other tracks or playlists, from your Spotify library, when you return to the QUEUE playlist, you should be able to simply resume where you left off. If you skip a track that you don't want to listen to from the QUEUE, then it wont get played until the database gets reset after all tracks have been played! METHOD Part One - 'Violet': Only needs to be run if creating a new database, or after adding or deleting tracks from the MASTER Playlist. • Adds / updates track details from your MASTER playlist into a SQL database table. Part Two - 'Cynthia': Can be scheduled to run every hour, by using 'scheduler.py'. (periodicity can be changed in the scheduler). • Fetch the total number of tracks currently in the QUEUE playlist. • Get Details of each track in the QUEUE playlist and add them to a [list]. • (Also, performs a similar operations with the Recently Played tracks). 1. Read the track title up to the hyphen ('-') to see if one exists. 2. Strip the white space from both ends of the string: 'self.track_name'. 3. Apply upper-case capitalisation to all characters. 4. Do the same to both the QUEUE track and the Recently Played track. 5. Compare the 2 and if they are a match, they can then be dealt with accordingly. • Get the 50 Last Played 50 and check to see if any are in the QUEUE playlist. (Retains one most Recently Played track from the QUEUE, just incase it was only partially played). • If any tracks are in the QUEUE playlist AND they have been played then: • Mark the played tracks as 'played' in the database. • Remove played tracks from the QUEUE playlist. • Calculate the number of new tracks required in order to maintain the QUEUE playlist (50 tracks max). • Select at random, from any of the those not yet played tracks from the database, to fulfill any deficit in the QUEUE. • Set the 'played' flag in the database from '0' to '1' for the newly added QUEUE tracks. • Add any new tracks to the Endless QUEUE Playlist. • Interrogate the database to check the number of tracks that are still yet to get played [played=0]. • If there are no tracks left, then 'reset' the database 'played' flag, thus making all of the tracks available again. Viking Utilities - March 2022