Skip to content

vulpeace/last.fm-wrapped

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

last.fm-wrapped

A node.js app that collects the data for your own 'wrapped' showcase from your Last.fm profile

Usage: node app.js -u Vulpeace

You will need to pass either -u or --username followed by a Last.fm username to the app.

Don't forget to rename .env.example to .env and fill in the fields. You will need to procure your own Last.fm and Spotify API keys.

https://developer.spotify.com/dashboard

https://www.last.fm/api/accounts


How it works

The app fetches the user's 12-month-old stats using user.getTopTracks method. Unfortunately, Last.fm doesn't provide the length for each and every track, that's why we have to look it up from Spotify for the entries where duration is 0. After the app combines the data from Last.fm and Spotify, it formats the result as a json, outputs it to the console and writes it to file named wrapped.json.

{
    "artists": [
        {
            "name": "Teminite",
            "playMinutes": 4939
        },
        {
            "name": "cYsmix",
            "playMinutes": 4256
        },
        {
            "name": "Haywyre",
            "playMinutes": 2792
        },
        {
            "name": "Evilwave",
            "playMinutes": 2494
        },
        {
            "name": "Nhato",
            "playMinutes": 2023
        }
    ],
    "songs": [
        {
            "name": "Believe",
            "playCount": "103",
            "playMinutes": 583
        },
        {
            "name": "With Or Without",
            "playCount": "96",
            "playMinutes": 358
        },
        {
            "name": "Gekka",
            "playCount": "88",
            "playMinutes": 542
        },
        {
            "name": "Break Free",
            "playCount": "87",
            "playMinutes": 439
        },
        {
            "name": "Change Your Mind",
            "playCount": "84",
            "playMinutes": 235
        }
    ],
    "minutesListened": 38961,
    "tracksTotal": 1778,
    "strayMinutes": 2438
}

strayMinutes is a sum of playcount values for the tracks that could not be found on Spotify multiplied by the average track length.

About

A node.js app that fetches data for your own "wrapped" showcase

Resources

License

Stars

Watchers

Forks