{"id":19350662,"url":"https://github.com/slevin48/music","last_synced_at":"2025-04-23T07:30:46.500Z","repository":{"id":56036512,"uuid":"308947157","full_name":"slevin48/music","owner":"slevin48","description":"Music App based on Spotify API and Streamlit framework","archived":false,"fork":false,"pushed_at":"2022-12-12T01:20:27.000Z","size":5524,"stargazers_count":15,"open_issues_count":6,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T09:38:49.024Z","etag":null,"topics":["boto3","python","spotipy","streamlit"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slevin48.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-31T18:27:21.000Z","updated_at":"2025-02-23T15:03:03.000Z","dependencies_parsed_at":"2023-01-27T09:46:02.441Z","dependency_job_id":null,"html_url":"https://github.com/slevin48/music","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slevin48%2Fmusic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slevin48%2Fmusic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slevin48%2Fmusic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slevin48%2Fmusic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slevin48","download_url":"https://codeload.github.com/slevin48/music/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250390939,"owners_count":21422809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boto3","python","spotipy","streamlit"],"created_at":"2024-11-10T04:33:26.832Z","updated_at":"2025-04-23T07:30:45.229Z","avatar_url":"https://github.com/slevin48.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Music 48 🎵[![Open in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://share.streamlit.io/slevin48/music/main/code/streamlit_app.py)\n\n![sergent-pepper](img/25yQPHgC35WNnnOUqFhgVR.jpg)\n\nStarted out as a Spotify music recommendation app\n\n***NEW***: Added features from [music-generator](https://github.com/slevin48/music-generator) 🎹\n\n**Content:**\n1. [Parse Streaming History](#parse)\n2. [Music Taste Analysis](#taste)\n3. [Get Recommendation](#reco)\n4. [Spotify API](#api)\n\n## 1. \u003ca name=\"parse\"\u003e\u003c/a\u003eParse Streaming History\n\nStreaming history can be retrieved from the Spotify profile as JSON, or through the spotipy functions [current_user_recently_played](https://spotipy.readthedocs.io/en/2.16.1/?highlight=current_user_recently_played#spotipy.client.Spotify.current_user_recently_played) or [current_user_saved_tracks](https://spotipy.readthedocs.io/en/2.16.1/?highlight=current_user_saved_tracks#spotipy.client.Spotify.current_user_saved_tracks)\n\n\n```python\nwith open(\"recently_played_20210306.json\",\"r\") as f:\n    results = json.load(f)\n\ntracks = []\nfor idx, item in enumerate(results['items']):\n    track = item['track']\n    tracks.append([idx, track['artists'][0]['name'], track['name']])\n\ntrackDict = {\"id\":[], \"artist\":[],\"name\":[]}\nfor idx, item in enumerate(results['items']):\n    track = item['track']\n    trackDict[\"id\"].append(idx)\n    trackDict[\"artist\"].append(track['artists'][0]['name'])\n    trackDict[\"name\"].append(track['name'])\n    \nimport pandas as pd\ntrackDf = pd.DataFrame.from_dict(trackDict)\n```\n\n## 2. \u003ca name=\"taste\"\u003e\u003c/a\u003eMusic Taste Analysis\n\nAnalysis of features to produce a polar plot\n\n![feature-plot](spotifyData/features.svg)\n```python\nimport spotifyAPI\nfrom secret import clientId,clientSecret\ntoken  = spotifyAPI.get_token(clientId,clientSecret)\nlucy_id = spotifyAPI.get_track_id2('Lucy in the Sky', token, artist = 'The Beatles')\n\nurl = \"https://open.spotify.com/track/\"+lucy_id\nimport webbrowser\nwebbrowser.open(url)\n\nimport pandas as pd\n\nlucy_features = spotifyAPI.get_features(lucy_id,token)\ndf = pd.DataFrame(lucy_features, index=[0])\ndf_features = df.loc[: ,['acousticness', 'danceability', 'energy', 'instrumentalness', 'liveness', 'speechiness', 'valence']]\n\nspotifyAPI.feature_plot(df_features)\n```\n\n\n## 3. \u003ca name=\"reco\"\u003e\u003c/a\u003eGet Recommendation\n```python\njson_response = spotifyAPI.get_track_reco(lucy_id,token)\nuris =[]\nfor i in json_response['tracks']:\n            uris.append(i)\n            print(f\"\\\"{i['name']}\\\" by {i['artists'][0]['name']}\")\n```\n\n\n## 4. \u003ca name=\"api\"\u003e\u003c/a\u003eSpotify API\n\nThis notebook leverages the Spotipy module to access the Spotify API:\n\nhttps://spotipy.readthedocs.io/\n\n* [Basic auth](code/basicMusic.ipynb)\n  * Search \u0026 Get track\n  * Get features\n  * Get recommendations\n* Spotipy auth\n  * Artist albums\n  * Artist top tracks\n  * Advanced Search ([help](https://spotipy.readthedocs.io/en/2.16.1/#spotipy.client.Spotify.search))\n  * Current user\n* Access Scopes (detailed later)\n  * Saved Tracks\n  * Saved Albums ([doc](https://developer.spotify.com/console/get-current-user-saved-albums))\n  * Playlist ([doc](https://developer.spotify.com/console/get-current-user-playlists/))\n  * Recently played ([doc](https://developer.spotify.com/console/get-recently-played/))\n  )\n  * Advanced recommendations based on seeds ([doc](https://developer.spotify.com/console/get-recommendations/))\n\n![spotifyNoneUserData](img/spotifyNonUserData.png)\n\n### Scopes\n\n* Images\n  * [ugc-image-upload](https://developer.spotify.com/documentation/general/guides/scopes/#ugc-image-upload)\n* Spotify Connect\n  * [user-read-playback-state](https://developer.spotify.com/documentation/general/guides/scopes/#user-read-playback-state)\n  * [user-modify-playback-state](https://developer.spotify.com/documentation/general/guides/scopes/#user-modify-playback-state)\n  * [user-read-currently-playing](https://developer.spotify.com/documentation/general/guides/scopes/#user-read-currently-playing)\n* Playback\n  * [streaming](https://developer.spotify.com/documentation/general/guides/scopes/#streaming)\n  * [app-remote-control](https://developer.spotify.com/documentation/general/guides/scopes/#app-remote-control)\n* Users\n  * [user-read-email](https://developer.spotify.com/documentation/general/guides/scopes/#user-read-email)\n  * [user-read-private](https://developer.spotify.com/documentation/general/guides/scopes/#user-read-private)\n* Playlists\n  * [playlist-read-collaborative](https://developer.spotify.com/documentation/general/guides/scopes/#playlist-read-collaborative)\n  * [playlist-modify-public](https://developer.spotify.com/documentation/general/guides/scopes/#playlist-modify-public)\n  * [playlist-read-private](https://developer.spotify.com/documentation/general/guides/scopes/#playlist-read-private)\n  * [playlist-modify-private](https://developer.spotify.com/documentation/general/guides/scopes/#playlist-modify-private)\n* Library\n  * [user-library-modify](https://developer.spotify.com/documentation/general/guides/scopes/#user-library-modify)\n  * [user-library-read](https://developer.spotify.com/documentation/general/guides/scopes/#user-library-read)\n* Listening History\n  * [user-top-read](https://developer.spotify.com/documentation/general/guides/scopes/#user-top-read)\n  * [user-read-playback-position](https://developer.spotify.com/documentation/general/guides/scopes/#user-read-playback-position)\n  * [user-read-recently-played](https://developer.spotify.com/documentation/general/guides/scopes/#user-read-recently-played)\n* Follow\n  * [user-follow-read](https://developer.spotify.com/documentation/general/guides/scopes/#user-follow-read)\n  * [user-follow-modify](https://developer.spotify.com/documentation/general/guides/scopes/#user-follow-modify)\n\n\n## Resources\n* https://dev.to/mxdws/using-python-with-the-spotify-api-1d02\n* https://medium.com/python-in-plain-english/music-recommendation-system-for-djs-d253d472677e\n* https://github.com/tgel0/spotify-data\n* https://towardsdatascience.com/a-visual-look-at-my-taste-in-music-a8c197a728be\n* https://medium.com/@maxtingle/getting-started-with-spotifys-api-spotipy-197c3dc6353b\n* https://towardsdatascience.com/a-music-taste-analysis-using-spotify-api-and-python-e52d186db5fc\n* https://github.com/jmcabreira/A-Music-Taste-Analysis-Using-Spotify-API-and-Python.\n* https://medium.com/analytics-vidhya/build-your-own-playlist-generator-with-spotifys-api-in-python-ceb883938ce4\n* https://towardsdatascience.com/get-your-spotify-streaming-history-with-python-d5a208bbcbd3\n* https://towardsdatascience.com/how-to-utilize-spotifys-api-and-create-a-user-interface-in-streamlit-5d8820db95d5\n* https://developer.spotify.com/community/showcase/spotify-audio-analysis/\n* https://medium.com/deep-learning-turkey/build-your-own-spotify-playlist-of-best-playlist-recommendations-fc9ebe92826a\n* https://www.theverge.com/platform/amp/tldr/2018/2/5/16974194/spotify-recommendation-algorithm-playlist-hack-nelson\n* http://sortyourmusic.playlistmachinery.com/\n* https://towardsdatascience.com/k-means-clustering-and-pca-to-categorize-music-by-similar-audio-features-df09c93e8b64\n* https://towardsdatascience.com/interactive-machine-learning-and-data-visualization-with-streamlit-7108c5032144\n* http://druckhaus-hofmann.de/gallery/36-wj-june-2020.pdf\n* https://medium.com/swlh/music-genre-classification-using-transfer-learning-pytorch-ea1c23e36eb8\n* https://towardsdatascience.com/music-genre-classification-with-tensorflow-3de38f0d4dbb\n* https://towardsdatascience.com/machine-learning-and-recommender-systems-using-your-own-spotify-data-4918d80632e3\n* https://github.com/anthonyli358/spotify-recommender-systems/blob/main/recommender_playlists.ipynb","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslevin48%2Fmusic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslevin48%2Fmusic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslevin48%2Fmusic/lists"}