This repository contains scripts for transforming Spotify data to Prolog knowledge base for the CMPE260 course project (Principles of Programming Languages).
crawl_artists.py: For all genres (provided from Spotify), discover playlists. Save artists from discovered playlists toartists.pkl. After this step, there will be plenty of artists from different genres.crawl_albums.py: For each saved artist inartists.pkl, save their album information toalbums.pkl.crawl_tracks.py: For each saved album inalbums.pkl, save its tracks' information (and features) totracks.pkl.generate_artist_predicates.pyConverts the information inartists.pklto Prolog facts.generate_album_predicates.pyConverts the information inalbums.pklto Prolog facts.generate_track_predicates.pyConverts the information intracks.pklto Prolog facts.utils.py: Wrapper functions for HTTPS calls.clean_albums.pyandclean_artists.pyRemove duplicate albums (they contain different IDs but basically the same thing for our purpose) and their IDs from their respective artists.
Other scripts are used to filter out some problematic facts. If you want to reproduce the data, run the following:
python crawl_artists.pypython crawl_albums.pypython crawl_tracsk.pypython generate_artist_predicates.pypython generate_album_predicates.pypython generate_track_predicates.pypython clean_albums.pypython clean_artists.py
In order to make calls to Spotify API, you will need a token that can be obtained by registering an application to Spotify API. Look for the details https://developer.spotify.com/documentation/web-api/
You can truncate albums and tracks using truncate.py if you want your knowledge base to be small.