Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jpxwb/php-mysql-extended-spotify-streaming-history

PHP / MySQL Extended Spotify Streaming History
https://github.com/jpxwb/php-mysql-extended-spotify-streaming-history

mysql php spotify xampp

Last synced: 19 days ago
JSON representation

PHP / MySQL Extended Spotify Streaming History

Awesome Lists containing this project

README

        

# Analyse Spotify Extended Streaming History using MySQL and PHP

- [Analyse Spotify Extended Streaming History using MySQL and PHP](#analyse-spotify-extended-streaming-history-using-mysql-and-php)
* [Installation](#installation)
* [Screenshots](#screenshots)
+ [Homepage](#homepage)
- [Summary by Year](#summary-by-year)
- [Tracks Summary](#tracks-summary)
- [Artists Summary](#artists-summary)
- [Summary by Hours of Day and Days of Week](#summary-by-hours-of-day-and-days-of-week)
+ [Artist Page](#artist-page)
- [Artist Chart Page](#artist-chart-page)
+ [Album Page](#album-page)
+ [Tracks Page](#tracks-page)
+ [All Data Page](#all-data-page)
+ [Silly Stats Page](#silly-stats-page)
- [One Track Artists](#one-track-artists)
- [Artists Unique to a Year](#artists-unique-to-a-year)
+ [Data Grid Options](#data-grid-options)
- [Action Buttons](#action-buttons)
- [Show and Hide Columns](#show-and-hide-columns)
- [Filter Data](#filter-data)
- [Sort Data](#sort-data)
- [Pagination](#pagination)
- [Reorder Columns](#reorder-columns)
- [Artists Links](#artists-links)
+ [Podcasts](#podcasts)
+ [Disclaimer](#disclaimer)
* [Issues](#issues)

___

If you spend a lot of time listening to Spotify, you are probably familiar with Spotify Unwrapped, which provides a summary for the year of things like top artists, tracks, time spent listening to music etc.

If you want a more detailed view of your listening activity on Spotify, you can ask to get your extended streaming history emailed to you.

There are various websites which will analyse your stats for you.

There are two versions which you have to pay for:

- [Stats.fm](https://stats.fm/)
- [Volt.fm](https://volt.fm/)

There are also some free options, such as:

- [Curio](https://everynoise.com/curio.html?page=listening_history)
- [Explorify](https://explorify.link/)

I wanted to make a website which allowed me to search through my listening history, export the data to Excel, do charts etc.

This is my attempt at that.

It's not as slick as Curio and Explorify since those store the data in the browser and nothing is stored in a database or server.

If you are comfortable with installing things on your computer I have written instructions showing how you can set things up so you can import your listening data into a database and run a website on a local server on your computer.

I have loaded in data for me and some people in my family and put it on a public website and it seems to work well enough, but you can also run the site on your local computer, so you don't have to pay for web hosting or buy a domain name.

## Installation

Instructions are covered in the docs - here are the pages:

- [01 - Screenshots](https://github.com/jpxwb/php-mysql-extended-spotify-streaming-history/blob/main/docs/01-screenshots.md)
- [02 - Request Spotify Data](https://github.com/jpxwb/php-mysql-extended-spotify-streaming-history/blob/main/docs/02-request-your-data-from-spotify.md)
- [03 - Install Xampp](https://github.com/jpxwb/php-mysql-extended-spotify-streaming-history/blob/main/docs/03-install-xampp.md)
- [04 - Set up Spotify History Database](https://github.com/jpxwb/php-mysql-extended-spotify-streaming-history/blob/main/docs/04-set-up-spotify-history-database.md)
- [05 - Set up Spotify History Website](https://github.com/jpxwb/php-mysql-extended-spotify-streaming-history/blob/main/docs/05-set-up-spotify-history-website.md)
- [06 - Load data from JSON files into database](https://github.com/jpxwb/php-mysql-extended-spotify-streaming-history/blob/main/docs/06-load-history-data-into-database.md)
- [07 - Useful SQL](https://github.com/jpxwb/php-mysql-extended-spotify-streaming-history/blob/main/docs/07-useful-sql.md)

## Screenshots

### Homepage

#### Summary by Year

Homepage provides a summary at the top of the page across all years, showing:

- Year
- Total:
- Minutes
- Hours
- Distinct Artist Count
- Distinct Track Count
- Sum of plays

![Homepage](https://jpxwb.github.io/img/Screenshot%202025-01-05%20191005.png)

Slightly further down the page, listening activity is displayed in a bar chart:

![Summary by Year](https://jpxwb.github.io/img/Screenshot%202025-01-05%20191026.png)

#### Tracks Summary

See a summary of tracks - for all time, or using the links at the top of the page, narrow down by year.

![Track Summary - All Time](https://jpxwb.github.io/img/Screenshot%202025-01-05%20191228.png)

Example of narrowing down by year:

![Track Summary - All Time](https://jpxwb.github.io/img/Screenshot%202025-01-05%20191406.png)

#### Artists Summary

See a summary of artists - for all time:

![Track Summary - All Time](https://jpxwb.github.io/img/Screenshot%202025-01-05%20191258.png)

You can use year the links at the top of the page to focus on a specific year:

![Year Links](https://jpxwb.github.io/img/Screenshot%202025-01-05%20191336.png)

![Artists Summary - All Time](https://jpxwb.github.io/img/Screenshot%202025-01-05%20191258.png)

The icons / links in the `Artist #` column are:

1. Chart - see bar graph charting listening activity for artist over the years
2. Calendar - track summary for artist - showing which tracks you have listened to for that artist (showing first listened to, last listened to, listening time and play count)
3. Clock - detailed track listening history for artist
4. Search icon - album summary for artist - showing which albums you have listened to for that artist (showing first listened to, last listened to, number of tracks listened to, listening time and play count).

Use the Year links at the top of the page to focus on a specific year.

#### Summary by Hours of Day and Days of Week

At the bottom of the page a summary shows listening minutes per hour of the day and per day of the week. Use the Year links at the top of the page to focus on a specific year.

![Summary by Hour / Day of Week - All Time](https://jpxwb.github.io/img/Screenshot%202025-01-07%20073332.png)

### Artist Page
Search for / see data for artists.

Click on the link in the `Albums` column to see the album summary listing for that artist.

![Artists Search Form](https://jpxwb.github.io/img/Screenshot%202025-01-05%20191451.png)

#### Artist Chart Page
See charts showing listening history across all years and months for an artist, the further down the page, see a summary per year.

![Artist Minutes Chart 1 Form](https://jpxwb.github.io/img/Screenshot%202025-01-05%20191518.png)
![Artist Minutes Chart 2 Form](https://jpxwb.github.io/img/Screenshot%202025-01-05%20191550.png)

### Album Page
Search for / see data for albums.

Click on the link in the `Albums` column to see the album summary listing for that artist.

![Artists Search Form](https://jpxwb.github.io/img/Screenshot%202025-01-05%20191451.png)

### Tracks Page
Search for / see data for tracks.
![Tracks Search Form](https://jpxwb.github.io/img/Screenshot%202025-01-05%20191635.png)

### All Data Page
Listening activity per day for all days.

![All Data](https://jpxwb.github.io/img/Screenshot%202025-01-08%20114957.png)

### Silly Stats Page
There are two sections on this page.

#### One Track Artists
Section listing artists where only one track has been listened to, ordered by most time listened to, in descending order.

![One Track Artists](https://jpxwb.github.io/img/Screenshot%202025-01-08%20112601.png)

#### Artists Unique to a Year
Lists artists which have only been listened to that year, and not during any of the other years of your listening history.

![Artists unique to each year](https://jpxwb.github.io/img/Screenshot%202025-01-08%20114007.png)

### Data Grid Options

#### Action Buttons

Data can be copied to clipboard, or exported to CSV or Excel:

![Action Buttons](https://jpxwb.github.io/img/Screenshot%202025-01-07%20085026.png)

#### Show and Hide Columns

Use the `Column visiblity` button to show / hide columns:

![Show / Hide Columns](https://jpxwb.github.io/img/Screenshot%202025-01-05%20192437.png)

#### Filter Data

The search form on any data grid can be used to quickly filter results:

![Filter Data](https://jpxwb.github.io/img/Screenshot%202025-01-07%20084723.png)

#### Sort Data

Column headings can be clicked to sort data:

![Sort Data](https://jpxwb.github.io/img/Screenshot%202025-01-07%20084956.png)

#### Pagination

Where relevant, there are next / previous links at the bottom of the data grids:

![Pagination Buttons](https://jpxwb.github.io/img/Screenshot%202025-01-07%20085416.png)

#### Reorder Columns

You can click and drag column headings and change the order of the columns.

#### Artists Links
The icons / links in the `Artist #` column are:

1. Chart - see bar graph charting listening activity for artist over the years
2. Calendar - track summary for artist - showing which tracks you have listened to for that artist (showing first listened to, last listened to, listening time and play count)
3. Clock - detailed track listening history for artist
4. Search icon - album summary for artist - showing which albums you have listened to for that artist (showing first listened to, last listened to, number of tracks listened to, listening time and play count).

Click on the link in the `Track` column to view a detailed listening history for that track.

### Podcasts
This page provides a summary of shows listened to. Click the show link to see a detail list of episodes that were listened to for that show.

![Shows Page](https://jpxwb.github.io/img/Screenshot%202025-01-05%20191834.png)

This shows an example of data provided when drilling down to view episodes for a show:

![Episodes Page](https://jpxwb.github.io/img/Screenshot%202025-01-05%20192410.png)

### Disclaimer

- The way I have written the PHP code in this project is pretty basic I think if you are a real programmer.
- If a real programmer were to look at the code they'd probably find countless bugs, issues, shout-out-loud errors and stupid ways of doing things.
- Lots of things are repeated, not a lot is re-used, so I haven't followed the [Don't Repeat Yourself](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) rule.
- I think I have taken a [Procedural approach](https://stackoverflow.com/questions/1530868/simple-explanation-php-oop-vs-procedural) to writing the PHP as well, which is not ideal.
- There is also lots of [spaghetti code](https://t2informatik.de/en/smartpedia/spaghetti-code/), so all in all while this site work, there are 1,001 reasons why it shouldn't be used as an example of the correct way to do things.
- For my basic hobbyist needs it works for me so I have put the code on Github in case anyone else finds it useful.

## Issues

- If you have any problems with this repository, please [raise a new issue](https://github.com/jpxwb/php-mysql-extended-spotify-streaming-history/issues/new).