https://github.com/lacymorrow/album-art
๐ฝ Fetch cover art for an artist or album: "The Beatles" โ http://path/to/beatles.jpg
https://github.com/lacymorrow/album-art
album album-art artists cli javascript nextjs nodejs plugin react
Last synced: about 1 month ago
JSON representation
๐ฝ Fetch cover art for an artist or album: "The Beatles" โ http://path/to/beatles.jpg
- Host: GitHub
- URL: https://github.com/lacymorrow/album-art
- Owner: lacymorrow
- License: mit
- Created: 2014-04-07T04:30:49.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2024-09-01T20:26:55.000Z (almost 2 years ago)
- Last Synced: 2024-10-29T10:36:09.737Z (over 1 year ago)
- Topics: album, album-art, artists, cli, javascript, nextjs, nodejs, plugin, react
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/album-art
- Size: 564 KB
- Stars: 111
- Watchers: 7
- Forks: 12
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
---
> [!IMPORTANT]
> This library is **feature-complete** and only receives bug-fix updates. Feature requests still welcome โ please open an issue.
> [!NOTE]
> Last.fm [cannabilized their own API](https://getsatisfaction.com/lastfm/topics/api-announcement-dac8oefw5vrxq) and broke many applications, including this one. `album-art` now uses Spotify for image data. The public API is fully backwards-compatible.
## Features
- Use anywhere, browser or Node (UMD bundle โ [browser support](https://caniuse.com/#feat=fetch))
- Works in React + Next.js, client and server, via [cross-fetch](https://www.npmjs.com/package/cross-fetch)
- Promise **and** callback API
- Fetch images for albums or artists
- Multiple size options (`small` ยท `medium` ยท `large`)
- Powered by Spotify's catalog
## Install
```bash
npm install album-art
```
In the browser:
```html
```
Also available via [JSDelivr](https://cdn.jsdelivr.net/npm/album-art/index.min.js).
## Usage
```js
const albumArt = require("album-art");
albumArt("Rush").then(console.log);
//=> http://path/to/rush.jpg
```
### Callback form
```js
albumArt("Rush", (error, response) => {
console.log(response);
//=> http://path/to/rush.jpg
});
```
### With album and size options
```js
albumArt("Rush", { album: "2112", size: "small" }).then(console.log);
//=> http://path/to/rush_2112_small.jpg
```
> [!TIP]
> Try it live without installing โ [open in RunKit](https://runkit.com/lacymorrow/album-art) (here's an [example output](https://runkit.io/lacymorrow/album-art/branches/master?search=Ben+Folds&album=Songs+for+Silverman)).
## API
### `albumArt(artist [, options] [, callback])`
Accepts an artist string to search for. Returns a Promise that resolves to a URL string.
| Argument | Type | Required | Description |
|---|---|:---:|---|
| `artist` | `string` | โ
| Artist to search for |
| `options.album` | `string` | | Album to search for |
| `options.size` | `"small" \| "medium" \| "large"` | | Requested image size |
| `callback` | `(err, response) => void` | | Optional Node-style callback |
## CLI
Install globally to use from the shell:
```bash
npm install --global album-art
album-art --help
# Usage
# $ album-art artist [album] [size]
#
# Example
# $ album-art 'The Beatles' --album 'Abbey Road' --size 'large'
# http://path/to/beatles/abbey_road_large.jpg
```
## Related
Part of a small family of media-data utilities:
- [movie-info](https://github.com/lacymorrow/movie-info) โ Get info, images, and ratings about a movie.
- [movie-trailer](https://github.com/lacymorrow/movie-trailer) โ Find the trailer for a movie.
- [movie-art](https://github.com/lacymorrow/movie-art) โ Get the poster art for a movie.
## Acknowledgments
- [Spotify Web API](https://developer.spotify.com/documentation/web-api) โ image data (subject to the [Spotify API Terms](https://developer.spotify.com/terms/)).
- The original [Last.fm API](https://www.last.fm/api) โ RIP, you were the source for the first three major versions of this library.
## License
[MIT](./LICENSE) ยฉ [Lacy Morrow](https://lacymorrow.com)
If album-art saved you time, consider sponsoring on GitHub, supporting on Patreon, or buying a coffee.