{"id":13910427,"url":"https://github.com/mashb1t/spotisights","last_synced_at":"2025-04-22T07:31:50.985Z","repository":{"id":36987378,"uuid":"451251010","full_name":"mashb1t/spotisights","owner":"mashb1t","description":"statistic dashboards for Spotify","archived":false,"fork":false,"pushed_at":"2024-12-05T11:50:41.000Z","size":1232,"stargazers_count":20,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-04-01T20:41:25.502Z","etag":null,"topics":["docker","docker-compose","grafana","grafana-influxdb","influxdb","php","spotify"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/mashb1t.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-01-23T22:50:41.000Z","updated_at":"2025-03-11T12:32:59.000Z","dependencies_parsed_at":"2024-02-04T09:02:40.777Z","dependency_job_id":null,"html_url":"https://github.com/mashb1t/spotisights","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mashb1t%2Fspotisights","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mashb1t%2Fspotisights/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mashb1t%2Fspotisights/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mashb1t%2Fspotisights/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mashb1t","download_url":"https://codeload.github.com/mashb1t/spotisights/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250195033,"owners_count":21390230,"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":["docker","docker-compose","grafana","grafana-influxdb","influxdb","php","spotify"],"created_at":"2024-08-07T00:01:23.047Z","updated_at":"2025-04-22T07:31:50.977Z","avatar_url":"https://github.com/mashb1t.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# SpotiSights - Spotify Insights\n\n[![Website Status](https://img.shields.io/website?url=https%3A%2F%2Fspotisights.mashb1t.de)](https://spotisights.mashb1t.de)\n[![License](https://img.shields.io/github/license/mashb1t/spotisights)](https://github.com/mashb1t/spotisights/blob/master/LICENSE)\n\nThis project displays Spotify statistics for multiple users via Grafana.\n\nIt uses Laravel commands for data collection from the Spotify API and InfluxDB as data storage.\n\n![](https://raw.githubusercontent.com/mashb1t/spotisights/master/images/spotisights-current-user.png)\n\n## Setup\n\n1. Copy ``config/*.env.dist`` to ``config/*.env`` and change the credentials\n2. Run ``composer install`` in ``php/src`` to make sure vendor exists for volume mount (only dev environment)\n3. Run ``docker-compose up -d`` to provision Grafana, InfluxDB and PHP+Nginx\n4. Log in to the [Spotify Developer] website\n5. Set up a new Spotify App, add the callback URL ``http://localhost:8080/spotify/callback`` and add client id and client secret to ``php.env``\n6. Log in to Grafana and remove the permission \"View\" on dashboard \"All Users\" (navigate settings \u003e permissions \u003e click on group \"SpotiSights\" \u003e remove role \"Viewer\" from board)\n\n## Data Flow / User setup\n\n1. Admin: add user email to permitted users in your Spotify app\n2. User: Call http://localhost:8080/ and connect services (technical reference: see auth section)\n3. User: initial crawl is executed for new users on first successful connection (**pulls max. 50 last listened tracks**)\n4. Admin: find username by new session name in file system / username in admin dashboard \n5. Admin: create user with email, username = Spotify username and \"Viewer\" permissions (default)\n6. Cronjob: collects recent tracks fron the authorized user and saves them to InfluxDB (**interval defined in docker-cron**)\n7. User: Log in to Grafana at http://localhost:3000/ and navigate to the Dashboard \"spotisights\" (http://localhost:3000/?orgId=1\u0026search=open)\n8. User: There should be a dashboard called \"Current User\" whch only shows data for the current user\n\n## Auth\n\nThis app implements the [Authorization Code Flow] of Spotify with [Refresh Tokens] by using file sessions.\n\n### API Scopes\n\n| scope                     | reason                                    | api endpoint        |\n|---------------------------|-------------------------------------------|---------------------|\n| user-read-recently-played | used for statistic collection             | getMyRecentTracks() |\n| user-read-private         | used for reading username                 | me()                |\n| user-read-email           | currently not used, but required          | me()                |\n| playlist-modify-public    | create playlist based on input parameters | createPlaylist()    |\n| playlist-modify-public    | create playlist based on input parameters | createPlaylist()    |\n\n\n## Disclaimer ARM CPUs (code: see branch \"arm\")\n\nWhile there are alternatives for each image and building / running them on linux/amd64 will work with minor adjustments\nbuilding and running them on ARM is problematic. \n\nIn any case the image ``mendhak/arm32v6-influxdb`` isn't a 1:1 replacement and you have to manually create the database\nafter startup or write a script for that.\n\nYou also have to start crond manually due to using the user \"nobody\" during runtime:\n\n    crond -b -L /docker.stdout\n\n### linux/arm/v6\n\nGrafana is only compatible with linux/armv7, the container will not start.\n\n### linux/arm/v7\n\nDespite Grafana now working the php container will not start due to one of the following errors:\n\n```\ndns for composer resolution will fail, even when adding the dns server directly to the docker daemon config\n```\n\n```\nphp_1       | Fatal Python error: init_interp_main: can't initialize time\nphp_1       | Python runtime state: core initialized\nphp_1       | PermissionError: [Errno 1] Operation not permitted\nphp_1       |\nphp_1       | Current thread 0x76f87390 (most recent call first):\nphp_1       | \u003cno Python frame\u003e\n```\n\nThis most likely has to do with libseccomp2 not being compatible.\n\n**I stopped debugging and used a system with a linux/amd64 CPU.**\n\n\n## References\n\n### Spotify API\n- https://developer.spotify.com/console/get-recently-played/?limit=2\u0026after=\u0026before=\n- https://github.com/jwilsson/spotify-web-api-php\n\n### InfluxDB\n- https://github.com/influxdata/influxdb-client-php\n\n[Authorization Code Flow]: https://developer.spotify.com/documentation/general/guides/authorization/code-flow/\n[Laravel Valet]: https://laravel.com/docs/master/valet\n[Refresh Tokens]: https://github.com/jwilsson/spotify-web-api-php/blob/main/docs/examples/refreshing-access-tokens.md\n[Spotify Developer]: https://developer.spotify.com/dashboard/\n\n## License\n\nThis project is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmashb1t%2Fspotisights","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmashb1t%2Fspotisights","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmashb1t%2Fspotisights/lists"}