项目作者: lacymorrow

项目描述 :
💽 Fetch cover art for an artist or album: "The Beatles" ➔ http://path/to/beatles.jpg
高级语言: JavaScript
项目地址: git://github.com/lacymorrow/album-art.git
创建时间: 2014-04-07T04:30:49Z
项目社区:https://github.com/lacymorrow/album-art

开源协议:MIT License

下载


[!IMPORTANT]
This library is considered feature-complete and will only receive updates for bug fixes. You may still create an issue if you have a feature request.

album-art



npm version Maintainability Try movie-art on RunKit

Fetch an album or artist image url: “The Beatles” ➔ http://path/to/beatles.jpg

album-art

Try it on RunKit (Output)

NOTE: Last.fm cannabilized their own API and broke many applications, including this one. This library now uses Spotify for image data. The usage for album-art has changed slightly but is fully backwards-compatible. Please report any errors.

Features

  • Use anywhere, browser or Node - UMD (Browser Support)
  • Works in React + NextJS client/server (uses isomorphic-fetch)
  • Promise and Callback API
  • Fetch images for albums or artists
  • Multiple size options
  • Uses Spotify for image data

Install

Using NPM:

  1. $ npm install album-art

In the browser:

  1. <!-- albumArt window global -->
  2. <script type="text/javascript" src="https://unpkg.com/album-art"></script>

(via Unpkg, or via JSDelivr)

Usage

  1. const albumArt = require( 'album-art' )
  2. await albumArt( 'Rush' ).then( console.log )
  3. //=> http://path/to/rush.jpg
Callback
  1. await albumArt( 'Rush', ( error, response ) => {
  2. console.log( response )
  3. //=> http://path/to/rush.jpg
  4. })
Usage with album and size options
  1. await albumArt( 'Rush', {album: '2112', size: 'small'} )
  2. .then( console.log )
  3. //=> http://path/to/rush_2112_small.jpg

API

albumArt(artist [, options] [, callback])

Accepts an artist string to search for.
Returns a Promise which resolves to a string URL.

artist

Required
Type: string

Artist to search for.

callback(error, response)

Function to be called on complete or on error.

Options

A JavaScript object with the following properties:

album

Type: string

Album to search for.

size

Type: string

Requested image size.
possible values: small, medium, large

CLI Usage

You can also run as a CLI app by installing it globally:

  1. $ npm install --global album-art
  2. $ album-art --help
  3. Usage
  4. $ album-art artist [album] [size]
  5. Example
  6. $ album-art 'The Beatles' --album 'Abbey Road' --size 'large'
  7. http://path/to/beatles/abbey_road_large.jpg

License

This package uses the ~Last.fm~ Spotify API for it’s data. You may consult the Spotify API Terms of Service for license details.

MIT © Lacy Morrow