Skip to content

Instantly share code, notes, and snippets.

@chrisvoo
Created May 10, 2021 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisvoo/4eef37cd6bfecf7654f826dd2f970039 to your computer and use it in GitHub Desktop.
Save chrisvoo/4eef37cd6bfecf7654f826dd2f970039 to your computer and use it in GitHub Desktop.
Retrieving artist's top albums
/* 57034 results for 1141 pages! */
import dotenv from 'dotenv';
import LastFM from 'last-fm';
import { envSchema } from './utils';
import { showResult } from './utils/terminal';
const result = dotenv.config();
if (result.error) {
console.error(result.error.message);
process.exit(1);
}
const { error } = envSchema.validate(result.parsed);
if (error) {
console.error(error.message);
process.exit(1);
}
(async () => {
const lastfm = new LastFM(process.env.API_KEY, {
userAgent: 'DiscoCLI/0.0.1 (https://github.com/chrisvoo/discocli)',
});
lastfm.artistTopAlbums({ name: 'blink182' }, (err: any, data: any) => {
if (err) {
console.error(err);
process.exit(1);
}
showResult(data);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment