{"id":16228701,"url":"https://github.com/wsmd/github-now-playing","last_synced_at":"2025-03-16T12:32:00.245Z","repository":{"id":36463767,"uuid":"180037988","full_name":"wsmd/github-now-playing","owner":"wsmd","description":"🎵 Display what you're listening to right on your Github profile","archived":false,"fork":false,"pushed_at":"2023-01-07T12:24:32.000Z","size":1364,"stargazers_count":79,"open_issues_count":15,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-12T10:42:11.039Z","etag":null,"topics":["github","github-profile","itunes","lastfm","macos","music","now-playing","spotify"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/wsmd.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":"2019-04-07T23:50:45.000Z","updated_at":"2025-02-15T00:36:47.000Z","dependencies_parsed_at":"2023-01-17T02:00:22.415Z","dependency_job_id":null,"html_url":"https://github.com/wsmd/github-now-playing","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wsmd%2Fgithub-now-playing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wsmd%2Fgithub-now-playing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wsmd%2Fgithub-now-playing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wsmd%2Fgithub-now-playing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wsmd","download_url":"https://codeload.github.com/wsmd/github-now-playing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814880,"owners_count":20352037,"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":["github","github-profile","itunes","lastfm","macos","music","now-playing","spotify"],"created_at":"2024-10-10T12:56:13.750Z","updated_at":"2025-03-16T12:31:59.892Z","avatar_url":"https://github.com/wsmd.png","language":"TypeScript","readme":"\u003ch1 align=\"center\"\u003egithub-now-playing\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/github-now-playing\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/github-now-playing.svg\" alt=\"Current Release\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://travis-ci.org/wsmd/github-now-playing\"\u003e\n    \u003cimg src=\"https://travis-ci.org/wsmd/github-now-playing.svg?branch=master\" alt=\"CI Build\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://coveralls.io/github/wsmd/github-now-playing?branch=master\"\u003e\n    \u003cimg src=\"https://coveralls.io/repos/github/wsmd/github-now-playing/badge.svg?branch=master\" alt=\"Coverage Status\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/wsmd/github-now-playing/blob/master/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/wsmd/github-now-playing.svg\" alt=\"Licence\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e📖 Table of Contents\u003c/summary\u003e\n\u003cp\u003e\n\n- [Motivation](#motivation)\n- [Installation](#installation)\n- [Example](#example)\n- [API](#api)\n  - [Class: `GitHubNowPlaying`](#class-githubnowplaying)\n    - [Constructor Options](#constructor-options)\n    - [Methods](#methods)\n      - [`nowPlaying.setSource(source)`](#nowplayingsetsourcesource)\n      - [`nowPlaying.on(event, listener)`](#nowplayingonevent-listener)\n      - [`nowPlaying.off(event, listener)`](#nowplayingoffevent-listener)\n      - [`nowPlaying.listen()`](#nowplayinglisten)\n      - [`nowPlaying.stop()`](#nowplayingstop)\n  - [Sources Providers: `GitHubNowPlaying.Sources`](#sources-providers-githubnowplayingsources)\n    - [`LastFM`](#lastfm)\n    - [`ITunes`](#itunes)\n    - [`Spotify`](#spotify)\n  - [Events: `GitHubNowPlaying.Events`](#events-githubnowplayingevents)\n    - [`Error`](#error)\n    - [`ListenStart`](#listenstart)\n    - [`ListenStop`](#listenstop)\n    - [`StatusUpdated`](#statusupdated)\n    - [`StatusCleared`](#statuscleared)\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n## Motivation\n\nGitHub introduced a [new feature](https://github.blog/changelog/2019-01-09-set-your-status/) that allows you to set a status on your profile, so I thought it would be a cool idea if I could share the music I'm listening to — kind of like #NowPlaying — right on my GitHub profile!\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg width=\"694\" alt=\"Screen Shot 2019-04-09 at 7 28 36 PM\" src=\"https://user-images.githubusercontent.com/2100222/70015382-2ffc0f00-154b-11ea-9b1f-3d492c81687d.png\"\u003e\n\u003c/div\u003e\n\n## Installation\n\nThis library is available on the [npm](https://www.npmjs.com/package/github-now-playing) registry as a [node](https://nodejs.org/en/) module and can be installed by running:\n\n```sh\n# via npm\nnpm install --save github-now-playing\n\n# via yarn\nyarn add github-now-playing\n```\n\nYou also need to generate a [personal access token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) with the **user** scope to allow this library to communicate with GitHub.\n\n## Example\n\n```ts\nimport { GitHubNowPlaying } from 'github-now-playing';\n\nconst nowPlaying = new GitHubNowPlaying({\n token: process.env.GITHUB_ACCESS_TOKEN,\n});\n\n// Create a new source to retrieve the track that is currently playing\nconst spotifySource = new GitHubNowPlaying.Sources.Spotify({\n // wait time in milliseconds between checks for any track changes\n updateFrequency: 1000,\n});\n\n// Make sure a source is set before calling listen()\nnowPlaying.setSource(spotifySource);\n\n// Don't forget to handle the error event!\nnowPlaying.on(GitHubNowPlaying.Events.Error, error =\u003e {\n  console.log('something went wrong');\n});\n\n// Listen to any track changes and update the profile status accordingly.\nnowPlaying.listen();\n\n// Don't forget to stop reporting any track changes when the process exists.\nprocess.on('SIGINT', () =\u003e {\n  // Calling the stop() method will clear the profile status.\n  nowPlaying.stop()\n});\n```\n\n## API\n\n`github-now-playing` exposes a named export class `GitHubNowPlaying` that is also a namespace for various [source providers](#sources-providers-githubnowplayingsources) and [event names](#events-githubnowplayingevents).\n\n### Class: `GitHubNowPlaying`\n\n```ts\nnew GitHubNowPlaying(options: GitHubNowPlayingConstructorOptions)\n```\n\nCreates a new instance of `GitHubNowPlaying`.\n\n#### Constructor Options\n\nAn object with the following keys:\n\n- `token: string`: a [personal access token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) with the **user** scope.\n\n#### Methods\n\n##### `nowPlaying.setSource(source)`\n\nAssigns a [source provider object](#sources) from which the currently-playing track will be retrieved.\n\nThis method must be called before calling [`listen()`](#listen-void).\n\n##### `nowPlaying.on(event, listener)`\n\nAdds the `listener` function as an event handler for the named `event`. The `event` parameter can be one of the values available under the [`GitHubNowPlaying.Events` namespace](#events).\n\nReturns a reference to the `GitHubNowPlaying` instance, so that calls can be chained.\n\n##### `nowPlaying.off(event, listener)`\n\nRemoves the specified `listener` function for the named `event`.\n\nThe `event` parameter can be one of the values available under the [`GitHubNowPlaying.Events` namespace](#events).\n\nReturns a reference to the `GitHubNowPlaying` instance, so that calls can be chained.\n\n##### `nowPlaying.listen()`\n\nStarts listening to any track changes coming from the specified source and updates the GitHub profile status accordingly.\n\nThe event `GitHubNowPlaying.Events.ListenStart` is emitted upon calling this method.\n\nAdditionally, every time the profile status is updated, the event `GitHubNowPlaying.Events.StatusUpdated` is emitted with the [profile status](https://github.com/wsmd/github-profile-status#userstatus) object.\n\nNote that upon calling `listen()`, the profile status will be updated immediately to reflect the currently playing track.\n\n##### `nowPlaying.stop()`\n\nStops listening to any track changes.\n\nCalling this method will result in clearing the profile status if it has been already updated with a currently playing track.\n\nIf the status is cleared, the event `GitHubNowPlaying.Events.StatusCleared` is emitted, then followed by the event `GitHubNowPlaying.Events.ListenStop`.\n\nThis method is asynchronous and will resolve after clearing the profile status.\n\n----\n\n### Sources Providers: `GitHubNowPlaying.Sources`\n\n`GitHubNowPlaying` relies on a source provider object that retrieves the currently playing track from a specific source.\n\nThese sources can be either local desktop applications, such [iTunes](https://www.apple.com/itunes/) or [Spotify](https://www.spotify.com/us/), or even via web APIs, such as Last.fm.\n\n`GitHubNowPlaying` comes with built-in support for all of these sources. Note that support for desktop applications is currently limited to macOS.\n\nThe following sources are available under the namespace `GitHubNowPlaying.Sources`:\n\n#### `LastFM`\n\nFetches information about the currently-playing track via Last.fm.\n\n```js\nconst lastFmSource = new GitHubNowPlaying.Sources.LastFM({\n apiKey: process.env.LAST_FM_API_KEY, // Your Last.fm API key\n updateFrequency: 1000,\n});\n\nnowPlaying.setSource(lastFmSource);\n```\n\n#### `ITunes`\n\nFetches information about the currently-playing track in [iTunes](https://www.apple.com/itunes/).\n\n```js\nconst iTunesSource = new GitHubNowPlaying.Sources.ITunes({\n updateFrequency: 1000,\n});\n\nnowPlaying.setSource(iTunesSource);\n```\n\nPlatforms supported: macOS\n\n#### `Spotify`\n\nFetches information about the currently-playing track in Spotify.\n\n```js\nconst spotifySource = new GitHubNowPlaying.Sources.Spotify({\n updateFrequency: 1000,\n});\n\nnowPlaying.setSource(spotifySource);\n```\n\nPlatforms supported: macOS\n\n---\n\n### Events: `GitHubNowPlaying.Events`\n\nInstances of `GitHubNowPlaying` emit various events during the program life-cycle. You can add or remove event listeners via [`on()`](#nowplayingonevent-listener) and [`off()`](#nowplayingoffevent-listener) respectively.\n\n#### `Error`\n\nEmitted when an error occurs:\n\n```ts\nnowPlaying.on(GitHubNowPlaying.Events.Error, (error) =\u003e { /* ... */ });\n```\n\n#### `ListenStart`\n\nEmitted when `GitHubNowPlaying` starts listening to track changes via the specified source:\n\n```ts\nnowPlaying.on(GitHubNowPlaying.Events.ListenStart, () =\u003e { /* ... */ });\n```\n\n#### `ListenStop`\n\n\nEmitted when `GitHubNowPlaying` has stopped listening to track changes via the specified source:\n\n```ts\nnowPlaying.on(GitHubNowPlaying.Events.ListenStop, () =\u003e { /* ... */ });\n```\n\n#### `StatusUpdated`\n\nEmitted when `GitHubNowPlaying` has updated the profile status with currently-playing track successfully. Listeners of this event are called with the [user-status object](https://github.com/wsmd/github-profile-status#userstatus).\n\n```ts\nnowPlaying.on(GitHubNowPlaying.Events.ListenStop, (status) =\u003e { /* ... */ });\n```\n\n#### `StatusCleared`\n\n\nEmitted when `GitHubNowPlaying` has cleared the profile status after it has been updated with a currently playing track. This happens when the source provider reports that there are no tracks are currently playing, or when [`stop()`](#nowplayingstop) is called.\n\n```ts\nnowPlaying.on(GitHubNowPlaying.Events.StatusCleared, () =\u003e { /* ... */ });\n```\n\n# See Also\n\n- [`github-profile-status`](https://github.com/wsmd/github-profile-status)\n\n# License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwsmd%2Fgithub-now-playing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwsmd%2Fgithub-now-playing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwsmd%2Fgithub-now-playing/lists"}