Full rewrite for typescript (#6)
Release to Prod / deploy-to-netlify (push) Has been cancelled
Details
Release to Prod / deploy-to-netlify (push) Has been cancelled
Details
Reviewed-on: #6 Co-authored-by: chris b <blue.iron1752@chrisb.xyz> Co-committed-by: chris b <blue.iron1752@chrisb.xyz>
This commit is contained in:
parent
62f3b5c28d
commit
08447f19d9
|
@ -0,0 +1 @@
|
|||
.eslintrc.js
|
18
.eslintrc
18
.eslintrc
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"extends": ["eslint:recommended", "airbnb-base"],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6
|
||||
},
|
||||
"rules": {
|
||||
"strict": 0,
|
||||
"quotes": [1, "single"],
|
||||
"comma-dangle": [2, "never"],
|
||||
"eol-last": [1, "never"],
|
||||
"no-plusplus": [0],
|
||||
"no-console": ["warn"],
|
||||
"no-underscore-dangle": [0],
|
||||
"func-names": [0],
|
||||
"prefer-promise-reject-errors": [0],
|
||||
"camelcase": [0]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
const path = require("path");
|
||||
|
||||
module.exports = {
|
||||
parser: "@typescript-eslint/parser",
|
||||
plugins: ["@typescript-eslint", "no-relative-import-paths"],
|
||||
extends: [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/stylistic-type-checked",
|
||||
"plugin:@typescript-eslint/strict-type-checked",
|
||||
"prettier",
|
||||
],
|
||||
parserOptions: {
|
||||
project: [path.resolve(__dirname, "tsconfig.json")],
|
||||
sourceType: "module",
|
||||
extraFileExtensions: [
|
||||
".yaml",
|
||||
".json",
|
||||
".yml",
|
||||
".gql",
|
||||
".html",
|
||||
".graphql",
|
||||
],
|
||||
},
|
||||
env: { node: true },
|
||||
rules: {
|
||||
"no-relative-import-paths/no-relative-import-paths": [
|
||||
"warn",
|
||||
{ allowSameFolder: false, rootDir: "lib", prefix: "~" },
|
||||
],
|
||||
},
|
||||
};
|
|
@ -0,0 +1,49 @@
|
|||
name: Release to Prod
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
deploy-to-netlify:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: ⚛️ Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "lts/*"
|
||||
cache: "npm"
|
||||
token: ${{ secrets.GH_NODE_TOKEN }}
|
||||
|
||||
- name: 🏎️ Install dependencies
|
||||
run: npm i --no-save --no-fund --no-audit --no-progress
|
||||
|
||||
- name: 🔨 Install netlify cli
|
||||
run: npm i --no-save --no-fund --no-audit --no-progress netlify-cli
|
||||
|
||||
- name: 🌳 Extract branch name
|
||||
id: extract_branch
|
||||
shell: bash
|
||||
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: 🛠️ Build and Upload to Netlify
|
||||
id: upload
|
||||
uses: "https://git.chriswb.dev/chrisw-b/ci-cd/deploy-to-netlify@v6.3.1"
|
||||
with:
|
||||
GITHUB_API_URL: ${{ github.api_url }}
|
||||
GITHUB_REPOSITORY: ${{ github.repository }}
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
GITEA_TOKEN: ${{ secrets.NETLIFY_GITEA_TOKEN }}
|
||||
NETLIFY_CONTEXT: "production"
|
||||
PR_NUMBER: ${{ github.event.number }}
|
||||
SOURCE_BRANCH: ${{ steps.extract_branch.outputs.branch }}
|
||||
env:
|
||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
|
||||
|
||||
- name: ⏳ Verify deployment
|
||||
run: |
|
||||
curl -H 'Content-Type: application/json' -X POST -d '{"query": "{name}"}' ${{ steps.upload.outputs.preview_url }} 2>&1 | grep "Chris Barry"
|
|
@ -0,0 +1,51 @@
|
|||
name: Lint Project
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
check-prettier:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "lts/*"
|
||||
cache: "npm"
|
||||
|
||||
- run: npm i --no-savec --no-fund --no-audit --no-progress
|
||||
|
||||
- run: npm run prettier:check
|
||||
|
||||
check-eslint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "lts/*"
|
||||
cache: "npm"
|
||||
|
||||
- run: npm i --no-savec --no-fund --no-audit --no-progress
|
||||
|
||||
- run: npm run lint:js
|
||||
|
||||
check-typescript:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "lts/*"
|
||||
cache: "npm"
|
||||
|
||||
- run: npm i --no-savec --no-fund --no-audit --no-progress
|
||||
|
||||
- run: npm run typescript
|
|
@ -0,0 +1,37 @@
|
|||
name: Release to NPM
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
# Publish to github using npm
|
||||
#
|
||||
# We do not commit the new tag; it's only used in the published package.json
|
||||
# This means that package.json will always list the version as 0.0.0,
|
||||
# but here we use the release tag to set a version just before publishing
|
||||
# which updates the package.json. This change is never committed to the repo.
|
||||
# The repo will use the GitHub Releases page to track versions.
|
||||
publish:
|
||||
name: Publish
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "lts/*"
|
||||
cache: "npm"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
|
||||
- run: npm i --no-save --no-fund --no-audit --no-progress
|
||||
|
||||
- name: Get tag for env
|
||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
|
||||
- run: npm run build
|
||||
- run: cd dist/ && npm version --new-version $RELEASE_VERSION --no-git-tag-version
|
||||
- run: cd dist/ && npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@ -1,5 +1,23 @@
|
|||
node_modules
|
||||
config.js
|
||||
.jshintrc
|
||||
npm-debug.log
|
||||
.eslintrc.json
|
||||
.cache/
|
||||
_build/
|
||||
reports/
|
||||
dist/
|
||||
node_modules/
|
||||
.DS_Store
|
||||
*.tgz
|
||||
|
||||
|
||||
# .env and .env.${NODE_ENV} are shared configuration
|
||||
# .env.local and .env.${NODE_ENV}.local are ignored
|
||||
*.local
|
||||
.env
|
||||
.envrc
|
||||
|
||||
# private data
|
||||
.npmrc
|
||||
|
||||
# Local Netlify folder
|
||||
.netlify
|
||||
|
||||
# Caches
|
||||
.eslintcache
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
{
|
||||
"html": {
|
||||
"allowed_file_extensions": ["htm", "html", "xhtml", "shtml", "xml", "svg"],
|
||||
"brace_style": "collapse", // [collapse|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line, or attempt to keep them where they are
|
||||
"end_with_newline": true, // End output with newline
|
||||
"indent_char": " ", // Indentation character
|
||||
"indent_handlebars": true, // e.g. {{#foo}}, {{/foo}}
|
||||
"indent_inner_html": true, // Indent <head> and <body> sections
|
||||
"indent_scripts": "keep", // [keep|separate|normal]
|
||||
"indent_size": 2, // Indentation size
|
||||
"max_preserve_newlines": 0, // Maximum number of line breaks to be preserved in one chunk (0 disables)
|
||||
"preserve_newlines": true, // Whether existing line breaks before elements should be preserved (only works before elements, not inside tags or for text)
|
||||
"unformatted": ["a", "span", "img", "code", "pre", "sub", "sup", "em", "strong", "b", "i", "u", "strike", "big", "small", "pre", "h1", "h2", "h3", "h4", "h5", "h6"], // List of tags that should not be reformatted
|
||||
"wrap_line_length": 0 // Lines should wrap at next opportunity after this number of characters (0 disables)
|
||||
},
|
||||
"css": {
|
||||
"allowed_file_extensions": ["css", "sass", "less"],
|
||||
"end_with_newline": true, // End output with newline
|
||||
"indent_char": " ", // Indentation character
|
||||
"indent_size": 2, // Indentation size
|
||||
"newline_between_rules": true, // Add a new line after every css rule
|
||||
"selector_separator": " ",
|
||||
"max_preserve_newlines": 2,
|
||||
"preserve_newlines": true,
|
||||
"selector_separator_newline": false // Separate selectors with newline or not (e.g. "a,\nbr" or "a, br")
|
||||
},
|
||||
"js": {
|
||||
"brace_style": "collapse,preserve-inline",
|
||||
"break_chained_methods": false,
|
||||
"eol": "\n",
|
||||
"eval_code": true,
|
||||
"indent_char": " ",
|
||||
"indent_level": 0,
|
||||
"indent_size": 2,
|
||||
"indent_with_tabs": false,
|
||||
"jslint_happy": true,
|
||||
"keep_array_indentation": false,
|
||||
"keep_function_indentation": false,
|
||||
"max_preserve_newlines": 2,
|
||||
"preserve_newlines": true,
|
||||
"space_after_anon_function": true,
|
||||
"space_before_anon_function": true,
|
||||
"space_before_conditional": true,
|
||||
"wrap_attributes": "auto",
|
||||
"wrap_attributes_indent_size": 0,
|
||||
"wrap_line_length": 0,
|
||||
"e4x": true,
|
||||
"operator_position": "after-newline"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"plugins": ["prettier-plugin-import-sort", "prettier-plugin-packagejson"]
|
||||
}
|
|
@ -0,0 +1,937 @@
|
|||
# LastFM-njs
|
||||
|
||||
A fully featured interface for Node and the Last.FM api
|
||||
|
||||
The full Last.FM API description can be found [here](http://www.last.fm/api)
|
||||
|
||||
You'll need an API key from [Create API Account](http://www.last.fm/api/account/create)
|
||||
|
||||
You can install using `npm install --save lastfm-njs`
|
||||
|
||||
Then you can set up like so, where username is a default username:
|
||||
|
||||
```ts
|
||||
var lastfm = require("lastfm-njs");
|
||||
var config = require("./config");
|
||||
var lfm = new lastfm.default({
|
||||
apiKey: config.key,
|
||||
apiSecret: config.secret,
|
||||
username: config.username,
|
||||
});
|
||||
```
|
||||
|
||||
If a method requires writing to an account, then you also need a password
|
||||
|
||||
```ts
|
||||
var lfm = new lastfm.default({
|
||||
apiKey: config.key,
|
||||
apiSecret: config.secret,
|
||||
username: config.username,
|
||||
password: config.password,
|
||||
});
|
||||
```
|
||||
|
||||
This library supports both esm and cjs importing, commonjs will export as a default. You can use modules like
|
||||
|
||||
```ts
|
||||
import LastFM from 'lastfm-njs';
|
||||
|
||||
const client = new LastFM(...)
|
||||
```
|
||||
|
||||
or require with
|
||||
|
||||
```ts
|
||||
const LastFM = require("lastfm-njs");
|
||||
|
||||
const client = new LastFM.default(...)
|
||||
```
|
||||
|
||||
After this, you can use any of the methods
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Authentication Methods](#authentication-methods)
|
||||
- [Album Methods](#album-methods)
|
||||
- [Artist Methods](#artist-methods)
|
||||
- [Geo Methods](#geo-methods)
|
||||
- [Library Methods](#library-methods)
|
||||
- [Tag Methods](#tag-methods)
|
||||
- [Track Methods](#track-methods)
|
||||
- [User Methods](#user-methods)
|
||||
|
||||
#### All methods use promises
|
||||
|
||||
```ts
|
||||
lastfm
|
||||
.auth_getMobileSession()
|
||||
.then(function (result) {
|
||||
lastfm
|
||||
.album_addTags({
|
||||
artist: "Oh Pep!",
|
||||
album: "Living",
|
||||
tags: "peppy,folk,music",
|
||||
})
|
||||
.then(printRes)
|
||||
.catch(printError);
|
||||
})
|
||||
.catch(printError);
|
||||
```
|
||||
|
||||
See example files for other examples
|
||||
|
||||
### Authentication
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/auth.getMobileSession)
|
||||
|
||||
**A username and password is required**
|
||||
|
||||
`auth_getMobileSession();`
|
||||
|
||||
which either returns
|
||||
|
||||
```ts
|
||||
{
|
||||
success: true,
|
||||
key: 'XXX'
|
||||
}
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```ts
|
||||
{
|
||||
success: false,
|
||||
error: [lastFMError]
|
||||
}
|
||||
```
|
||||
|
||||
### Album Methods
|
||||
|
||||
[Examples](../master/examples/album_examples.ts)
|
||||
|
||||
#### Add Tags\*
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/album.addTags)
|
||||
|
||||
`album_addTags(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req
|
||||
album: album, //req
|
||||
tags: tags, //req, max: 10, comma separated list
|
||||
};
|
||||
```
|
||||
|
||||
_\*Requires Authentication_
|
||||
|
||||
#### Get Info
|
||||
|
||||
[Last.FM Documentation](https://www.last.fm/api/show/album.getInfo)
|
||||
|
||||
`album_getInfo(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
album: album, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
lang: lang, //opt
|
||||
username: username, //opt
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Tags
|
||||
|
||||
[Last.FM Documentation](https://www.last.fm/api/show/album.getTags)
|
||||
|
||||
`album_getTags(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
album: album, //req unless mbid
|
||||
username: username, //req
|
||||
mbid: mbid, //opt
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Top Tags
|
||||
|
||||
[Last.FM Documentation](https://www.last.fm/api/show/album.getTopTags)
|
||||
|
||||
`album_getTopTags(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
album: album, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
};
|
||||
```
|
||||
|
||||
#### Remove Tag\*
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/album.removeTag)
|
||||
|
||||
`album_removeTag(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req
|
||||
album: album, //req
|
||||
tag: tag, //req, single tag to remove
|
||||
};
|
||||
```
|
||||
|
||||
_\*Requires Authentication_
|
||||
|
||||
#### Album Search
|
||||
|
||||
[Last.FM Documentation](https://www.last.fm/api/show/album.search)
|
||||
|
||||
`album_getTopTags(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
album: album, //req
|
||||
limit: limit, //opt, defaults to 30
|
||||
page: page, //opt, defaults to 1
|
||||
};
|
||||
```
|
||||
|
||||
## Artist
|
||||
|
||||
[Examples](../master/examples/artist_examples.ts)
|
||||
|
||||
#### Add Tags\*
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.addTags)
|
||||
|
||||
`artist_addTags(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist //req
|
||||
tags: tags, //req, max 10, comma separated
|
||||
}
|
||||
```
|
||||
|
||||
_\*Requires Authentication_
|
||||
|
||||
#### Get Correction
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.getCorrection)
|
||||
|
||||
`artist_getCorrection(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Info
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.getInfo)
|
||||
|
||||
`artist_getInfo(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
username: username, //opt
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Similar
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.getSimilar)
|
||||
|
||||
`artist_getSimilar(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
limit: limit, //opt
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Tags
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.getTags)
|
||||
|
||||
`artist_getTags(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
user: username, //req
|
||||
mbid: mbid, //opt
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Top Albums
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.getTopAlbums)
|
||||
|
||||
`artist_getTopAlbums(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
page: page, //opt, default is 50
|
||||
limit: limit, //opt, default is 1
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Top Tags
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.getTopTags)
|
||||
|
||||
`artist_getTopTags(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Top Tracks
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.getTopTracks)
|
||||
|
||||
`artist_getTopTracks(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
};
|
||||
```
|
||||
|
||||
#### Remove Tag\*
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.removeTag)
|
||||
|
||||
`artist_removeTag(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist //req
|
||||
tag: tag, //req, 1 tag to be removed
|
||||
}
|
||||
```
|
||||
|
||||
_\*Requires Authentication_
|
||||
|
||||
#### Search
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.search)
|
||||
|
||||
`artist_search(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
};
|
||||
```
|
||||
|
||||
### Chart Methods
|
||||
|
||||
[Examples](../master/examples/chart_examples.ts)
|
||||
|
||||
#### Get Top Artists
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/chart.getTopArtists)
|
||||
|
||||
`chart_getTopArtists(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Top Tags
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/chart.getTopTags)
|
||||
|
||||
`chart_getTopTags(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Top Tracks
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/chart.getTopTracks)
|
||||
|
||||
`chart_getTopTracks(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
};
|
||||
```
|
||||
|
||||
### Geo Methods
|
||||
|
||||
[Examples](../master/examples/geo_examples.ts)
|
||||
|
||||
#### Get Top Artists
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/geo.getTopArtists)
|
||||
|
||||
`geo_getTopArtists(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
country: country, //req, ISO 3166-1 format
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Top Tracks
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/geo.getTopTracks)
|
||||
|
||||
`geo_getTopTracks(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
country: country, //req, ISO 3166-1 format
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
};
|
||||
```
|
||||
|
||||
### Library Methods
|
||||
|
||||
[Examples](../master/examples/library_examples.ts)
|
||||
|
||||
#### Get Artists
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/library.getArtists)
|
||||
|
||||
`library_getArtists(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
user: username, //req
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
};
|
||||
```
|
||||
|
||||
### Tag Methods
|
||||
|
||||
[Examples](../master/examples/library_examples.ts)
|
||||
|
||||
#### Get Info
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/tag.getInfo)
|
||||
|
||||
`tag_getInfo(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
tag: tag, //req
|
||||
lang: lang, //opt
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Similar
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/tag.getSimilar)
|
||||
|
||||
`tag_getSimilar(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
tag: tag, //req
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Top Albums
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/tag.getTopAlbums)
|
||||
|
||||
`tag_getTopAlbums(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
tag: tag, //req
|
||||
limit: limit, //opt, default is 50
|
||||
page: page, //opt, default is 1
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Top Artists
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/tag.getTopArtists)
|
||||
|
||||
`tag_getTopArtists(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
tag: tag, //req
|
||||
limit: limit, //opt, default is 50
|
||||
page: page, //opt, default is 1
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Top Tags
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/tag.getTopTags)
|
||||
|
||||
`tag_getTopTags(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {};
|
||||
```
|
||||
|
||||
#### Get Top Tracks
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/tag.getTopTracks)
|
||||
|
||||
`tag_getTopTracks(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
tag: tag, //req
|
||||
limit: limit, //opt, defaults to 50
|
||||
page: page, //opt, defaults to 1
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Weekly Chart List
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/tag.getWeeklyChartList)
|
||||
|
||||
`tag_getWeeklyChartList(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
tag: tag, //req
|
||||
};
|
||||
```
|
||||
|
||||
### Track Methods
|
||||
|
||||
[Examples](../master/examples/track_examples.ts)
|
||||
|
||||
#### Add Tags\*
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.addTags)
|
||||
|
||||
`track_addTags(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req
|
||||
track: track, //req
|
||||
tags: tags, //req, max: 10
|
||||
};
|
||||
```
|
||||
|
||||
_\*Requires Authentication_
|
||||
|
||||
#### Get Correction
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.getCorrection)
|
||||
|
||||
`track_getCorrection(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req
|
||||
track: track, //req
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Info
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.getInfo)
|
||||
|
||||
`track_getInfo(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
track: track, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
username: username, //opt
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Similar
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.getSimilar)
|
||||
|
||||
`track_getSimilar(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
track: track, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
limit: limit, //opt
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Tags
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.getTags)
|
||||
|
||||
`track_getTags(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
track: track, //req unless mbid
|
||||
username: username, //req
|
||||
mbid: mbid, //opt
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Top Tags
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.getTopTags)
|
||||
|
||||
`track_getTopTags(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
track: track, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
};
|
||||
```
|
||||
|
||||
#### Love Track\*
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.love)
|
||||
|
||||
`track_love(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
track: track, //req unless mbid
|
||||
};
|
||||
```
|
||||
|
||||
_\*Requires Authentication_
|
||||
|
||||
#### Remove Tag\*
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.removeTag)
|
||||
|
||||
`track_removeTag(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req
|
||||
track: track, //req
|
||||
tag: tag, //req, single tag to remove
|
||||
};
|
||||
```
|
||||
|
||||
_\*Requires Authentication_
|
||||
|
||||
#### Scrobble\*
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.scrobble)
|
||||
|
||||
`track_scrobble(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist[i], //req
|
||||
track: track[i], //req
|
||||
timestamp: timestamp[i], //req
|
||||
album: album[i], //opt
|
||||
context: context[i], //opt
|
||||
streamId: streamId[i], //opt
|
||||
chosenByUser: chosenByUser[i], //opt
|
||||
trackNumber: trackNumber[i], //opt
|
||||
mbid: mbid[i], //opt
|
||||
albumArtist: albumArtist[i], //opt
|
||||
duration: duration[i], //opt
|
||||
};
|
||||
```
|
||||
|
||||
_\*Requires Authentication_
|
||||
|
||||
#### Search
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.search)
|
||||
|
||||
`track_search(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
track: track, //req
|
||||
artist: artist, //opt
|
||||
limit: limit, //opt, defaults to 30
|
||||
page: page, //opt, defaults to 1
|
||||
};
|
||||
```
|
||||
|
||||
#### Unlove\*
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.unlove)
|
||||
|
||||
`track_unlove(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
track: track, //req
|
||||
artist: artist, //req
|
||||
};
|
||||
```
|
||||
|
||||
_\*Requires Authentication_
|
||||
|
||||
#### Update Now Playing\*
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.updateNowPlaying)
|
||||
|
||||
`track_updateNowPlaying(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
artist: artist, //req
|
||||
track: track, //req
|
||||
album: album, //opt
|
||||
context: context //opt
|
||||
trackNumber: trackNumber, //opt
|
||||
mbid: mbid, //opt
|
||||
albumArtist: albumArtist, //opt
|
||||
duration: duration, //opt
|
||||
}
|
||||
```
|
||||
|
||||
_\*Requires Authentication_
|
||||
|
||||
### User Methods
|
||||
|
||||
[Examples](../master/examples/user_examples.ts)
|
||||
|
||||
#### Get Artist Tracks
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/user.getArtistTracks)
|
||||
|
||||
`user_getArtistTracks(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
user: username, //opt
|
||||
artist: artist, //req
|
||||
startTimestamp: startTimestamp, //opt defaults to all time
|
||||
page: page, //opt, default is 1
|
||||
endTimestamp: endTimestamp, //opt defaults to all time
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Friends
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/user.getFriends)
|
||||
|
||||
`user_getFriends(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
user: username, //opt
|
||||
recentTracks: recentTracks, //opt, true|false
|
||||
limit: limit, //opt defaults to 50
|
||||
page: page, //opt, default is 1
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Info
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/user.getInfo)
|
||||
|
||||
`user_getInfo(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
user: username, //opt, defaults to init user
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Loved Tracks
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/user.getLovedTracks)
|
||||
|
||||
`user_getLovedTracks(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
user: username, //opt
|
||||
limit: limit, //opt, default is 50
|
||||
page: page, //opt, default is 1
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Personal Tags
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/user.getPersonalTags)
|
||||
|
||||
`user_getPersonalTags(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
user: username, //opt
|
||||
tag: tag, //req
|
||||
taggingtype: artist | album | track, //req
|
||||
limit: limit, //opt, default is 50
|
||||
page: page, //opt, default is 1
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Recent Tracks
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/user.getRecentTracks)
|
||||
|
||||
`user_getRecentTracks(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
user: username, //opt
|
||||
from: startTime, //opt
|
||||
extended: 0 | 1, //opt
|
||||
to: endTime, //opt
|
||||
limit: limit, //opt, default is 50
|
||||
page: page, //opt, default is 1
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Top Albums
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/user.getTopAlbums)
|
||||
|
||||
`user_getTopAlbums(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
user: username, //opt
|
||||
period: overall|7day|1month|3month|6month|12month, //opt, default is overall
|
||||
limit: limit, //opt, default is 50
|
||||
page: page, //opt, default is 1
|
||||
}
|
||||
```
|
||||
|
||||
#### Get Top Artists
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/user.getTopArtists)
|
||||
|
||||
`user_getTopArtists(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
user: username, //opt
|
||||
period: overall|7day|1month|3month|6month|12month, //opt, default is overall
|
||||
limit: limit, //opt, default is 50
|
||||
page: page, //opt, default is 1
|
||||
}
|
||||
```
|
||||
|
||||
#### Get Top Tags
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/user.getTopTags)
|
||||
|
||||
`user_getTopTags(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
user: username, //opt
|
||||
limit: limit, //opt, default is 50
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Top Tracks
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/user.getTopTracks)
|
||||
|
||||
`user_getTopTracks(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
user: username, //opt
|
||||
period: overall|7day|1month|3month|6month|12month, //opt, default is overall
|
||||
limit: limit, //opt, default is 50
|
||||
page: page, //opt, default is 1
|
||||
}
|
||||
```
|
||||
|
||||
#### Get Weekly Album Chart
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/user.getWeeklyAlbumChart)
|
||||
|
||||
`user_getWeeklyAlbumChart(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
user: username, //opt
|
||||
from: startdate, //opt, default is overall
|
||||
to: enddate, //opt, default is 50
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Weekly Artist Chart
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/user.getWeeklyArtistChart)
|
||||
|
||||
`user_getWeeklyArtistChart(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
user: username, //opt
|
||||
from: startdate, //opt, default is overall
|
||||
to: enddate, //opt, default is 50
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Weekly Chart List
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/user.getWeeklyChartList)
|
||||
|
||||
`user_getWeeklyChartList(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
user: username, //opt
|
||||
};
|
||||
```
|
||||
|
||||
#### Get Weekly Track Chart
|
||||
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/user.getWeeklyTrackChart)
|
||||
|
||||
`user_getWeeklyTrackChart(opt)`, where
|
||||
|
||||
```ts
|
||||
opt = {
|
||||
user: username, //opt
|
||||
from: startdate, //opt, default is overall
|
||||
to: enddate, //opt, default is 50
|
||||
};
|
||||
```
|
915
Readme.md
915
Readme.md
|
@ -1,915 +0,0 @@
|
|||
# LastFM-njs
|
||||
A fully featured interface for Node and the Last.FM api
|
||||
|
||||
The full Last.FM API description can be found [here](http://www.last.fm/api)
|
||||
|
||||
You'll need an API key from [Create API Account](http://www.last.fm/api/account/create)
|
||||
|
||||
You can install using `npm install --save lastfm-njs`
|
||||
|
||||
Then you can set up like so, where username is a default username:
|
||||
```js
|
||||
var lastfm = require("lastfm-njs");
|
||||
var config = require("./config");
|
||||
var lfm = new lastfm({
|
||||
apiKey: config.key,
|
||||
apiSecret: config.secret,
|
||||
username: config.username
|
||||
});
|
||||
```
|
||||
|
||||
If a method requires writing to an account, then you also need password
|
||||
|
||||
```js
|
||||
var lfm = new lastfm({
|
||||
apiKey: config.key,
|
||||
apiSecret: config.secret,
|
||||
username: config.username,
|
||||
password: config.password
|
||||
});
|
||||
```
|
||||
|
||||
After this, you can use any of the methods
|
||||
|
||||
## Documentation
|
||||
- [Authentication Methods](#authentication-methods)
|
||||
- [Album Methods](#album-methods)
|
||||
- [Artist Methods](#artist-methods)
|
||||
- [Geo Methods](#geo-methods)
|
||||
- [Library Methods](#library-methods)
|
||||
- [Tag Methods](#tag-methods)
|
||||
- [Track Methods](#track-methods)
|
||||
- [User Methods](#user-methods)
|
||||
|
||||
#### All methods support ES6 promises if callback is not included
|
||||
```js
|
||||
lastfm.auth_getMobileSession(function(res) {
|
||||
if (res.success) {
|
||||
lastfm.album_addTags({
|
||||
artist: 'Oh Pep!',
|
||||
album: 'Living',
|
||||
tags: 'peppy,folk,music',
|
||||
callback(res) {
|
||||
printRes(res);
|
||||
}
|
||||
});
|
||||
}
|
||||
else{
|
||||
printError(res);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
is the same as
|
||||
```js
|
||||
lastfm.auth_getMobileSession().then(function(result) {
|
||||
lastfm.album_addTags({
|
||||
artist: 'Oh Pep!',
|
||||
album: 'Living',
|
||||
tags: 'peppy,folk,music',
|
||||
}).then(printRes).catch(printError);
|
||||
}).catch(printError);
|
||||
|
||||
```
|
||||
|
||||
See example files for other examples
|
||||
|
||||
### Authentication
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/auth.getMobileSession)
|
||||
|
||||
**A username and password is required**
|
||||
|
||||
`auth_getMobileSession(callback);`
|
||||
|
||||
where callback is a function which either returns
|
||||
```js
|
||||
{
|
||||
success: true,
|
||||
key: 'XXX'
|
||||
}
|
||||
```
|
||||
or
|
||||
```js
|
||||
{
|
||||
success: false,
|
||||
error: [lastFMError]
|
||||
}
|
||||
```
|
||||
|
||||
### Album Methods
|
||||
[Examples](../master/examples/album_examples.js)
|
||||
#### Add Tags*
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/album.addTags)
|
||||
|
||||
`album_addTags(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req
|
||||
album: album, //req
|
||||
tags: tags, //req, max: 10, comma separated list
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
_*Requires Authentication_
|
||||
#### Get Info
|
||||
[Last.FM Documentation](https://www.last.fm/api/show/album.getInfo)
|
||||
|
||||
`album_getInfo(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
album: album, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
lang: lang, //opt
|
||||
username: username, //opt
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Tags
|
||||
[Last.FM Documentation](https://www.last.fm/api/show/album.getTags)
|
||||
|
||||
`album_getTags(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
album: album, //req unless mbid
|
||||
username: username, //req
|
||||
mbid: mbid, //opt
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Top Tags
|
||||
[Last.FM Documentation](https://www.last.fm/api/show/album.getTopTags)
|
||||
|
||||
`album_getTopTags(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
album: album, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Remove Tag*
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/album.removeTag)
|
||||
|
||||
`album_removeTag(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req
|
||||
album: album, //req
|
||||
tag: tag, //req, single tag to remove
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
_*Requires Authentication_
|
||||
#### Album Search
|
||||
[Last.FM Documentation](https://www.last.fm/api/show/album.search)
|
||||
|
||||
`album_getTopTags(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
album: album, //req
|
||||
limit: limit, //opt, defaults to 30
|
||||
page: page, //opt, defaults to 1
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
## Artist
|
||||
[Examples](../master/examples/artist_examples.js)
|
||||
|
||||
#### Add Tags*
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.addTags)
|
||||
|
||||
`artist_addTags(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist //req
|
||||
tags: tags, //req, max 10, comma separated
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
_*Requires Authentication_
|
||||
#### Get Correction
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.getCorrection)
|
||||
|
||||
`artist_getCorrection(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Info
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.getInfo)
|
||||
|
||||
`artist_getInfo(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
username: username, //opt
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Similar
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.getSimilar)
|
||||
|
||||
`artist_getSimilar(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
limit: limit, //opt
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Tags
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.getTags)
|
||||
|
||||
`artist_getTags(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
user: username, //req
|
||||
mbid: mbid, //opt
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Top Albums
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.getTopAlbums)
|
||||
|
||||
`artist_getTopAlbums(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
page: page, //opt, default is 50
|
||||
limit: limit, //opt, default is 1
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Top Tags
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.getTopTags)
|
||||
|
||||
`artist_getTopTags(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Top Tracks
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.getTopTracks)
|
||||
|
||||
`artist_getTopTracks(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Remove Tag*
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.removeTag)
|
||||
|
||||
`artist_removeTag(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist //req
|
||||
tag: tag, //req, 1 tag to be removed
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
_*Requires Authentication_
|
||||
#### Search
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/artist.search)
|
||||
|
||||
`artist_search(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
### Chart Methods
|
||||
[Examples](../master/examples/chart_examples.js)
|
||||
|
||||
#### Get Top Artists
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/chart.getTopArtists)
|
||||
|
||||
`chart_getTopArtists(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Top Tags
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/chart.getTopTags)
|
||||
|
||||
`chart_getTopTags(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Top Tracks
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/chart.getTopTracks)
|
||||
|
||||
`chart_getTopTracks(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
### Geo Methods
|
||||
[Examples](../master/examples/geo_examples.js)
|
||||
|
||||
#### Get Top Artists
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/geo.getTopArtists)
|
||||
|
||||
`geo_getTopArtists(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
country: country, //req, ISO 3166-1 format
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Top Tracks
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/geo.getTopTracks)
|
||||
|
||||
`geo_getTopTracks(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
country: country, //req, ISO 3166-1 format
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
### Library Methods
|
||||
[Examples](../master/examples/library_examples.js)
|
||||
|
||||
#### Get Artists
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/library.getArtists)
|
||||
|
||||
`library_getArtists(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
user: username, //req
|
||||
page: page, //opt, default is 1
|
||||
limit: limit, //opt, default is 50
|
||||
callback(res){}
|
||||
}
|
||||
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
### Tag Methods
|
||||
[Examples](../master/examples/library_examples.js)
|
||||
|
||||
#### Get Info
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/tag.getInfo)
|
||||
|
||||
`tag_getInfo(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
tag: tag, //req
|
||||
lang: lang, //opt
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Similar
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/tag.getSimilar)
|
||||
|
||||
`tag_getSimilar(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
tag: tag, //req
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Top Albums
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/tag.getTopAlbums)
|
||||
|
||||
`tag_getTopAlbums(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
tag: tag, //req
|
||||
limit: limit, //opt, default is 50
|
||||
page: page, //opt, default is 1
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Top Artists
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/tag.getTopArtists)
|
||||
|
||||
`tag_getTopArtists(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
tag: tag, //req
|
||||
limit: limit, //opt, default is 50
|
||||
page: page, //opt, default is 1
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Top Tags
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/tag.getTopTags)
|
||||
|
||||
`tag_getTopTags(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Top Tracks
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/tag.getTopTracks)
|
||||
|
||||
`tag_getTopTracks(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
tag: tag, //req
|
||||
limit: limit, //opt, defaults to 50
|
||||
page: page, //opt, defaults to 1
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Weekly Chart List
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/tag.getWeeklyChartList)
|
||||
|
||||
`tag_getWeeklyChartList(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
tag: tag, //req
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
### Track Methods
|
||||
[Examples](../master/examples/track_examples.js)
|
||||
|
||||
#### Add Tags*
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.addTags)
|
||||
|
||||
`track_addTags(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req
|
||||
track: track, //req
|
||||
tags: tags, //req, max: 10
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
_*Requires Authentication_
|
||||
#### Get Correction
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.getCorrection)
|
||||
|
||||
`track_getCorrection(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req
|
||||
track: track, //req
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Info
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.getInfo)
|
||||
|
||||
`track_getInfo(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
track: track, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
username: username, //opt
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Similar
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.getSimilar)
|
||||
|
||||
`track_getSimilar(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
track: track, //req unless mbid
|
||||
mbid: mbid, //opt
|
||||
limit: limit, //opt
|
||||
callback(res){}
|
||||
}
|
||||
```
|
||||
and callback is a function which receives a single object, containing the Last.FM response and `success: false` if there was an error
|
||||
|
||||
#### Get Tags
|
||||
[Last.FM Documentation](http://www.last.fm/api/show/track.getTags)
|
||||
|
||||
`track_getTags(opt)`, where
|
||||
```js
|
||||
opt = {
|
||||
artist: artist, //req unless mbid
|
||||
track: track, //req unless mbid
|
||||
username: username, //req
|
||||
mbid: mbid, //opt
|
||||
|