@solely/simple-fm
Advanced tools
Comparing version 1.4.0 to 1.4.1
import { request } from '../request.js'; | ||
import { sanitizeURL } from '../utils/links.js'; | ||
export default class Album { | ||
@@ -52,3 +53,3 @@ token; | ||
name: album.artist, | ||
url: `https://www.last.fm/music/${encodeURIComponent(album.artist)}`, | ||
url: `https://www.last.fm/music/${sanitizeURL(album.artist)}`, | ||
}, | ||
@@ -90,3 +91,3 @@ stats: { | ||
name: attr.artist, | ||
url: `https://www.last.fm/music/${encodeURIComponent(attr.artist)}`, | ||
url: `https://www.last.fm/music/${sanitizeURL(attr.artist)}`, | ||
}, | ||
@@ -120,3 +121,3 @@ tags, | ||
name: album.artist, | ||
url: `https://www.last.fm/music/${encodeURIComponent(album.artist)}`, | ||
url: `https://www.last.fm/music/${sanitizeURL(album.artist)}`, | ||
}, | ||
@@ -123,0 +124,0 @@ url: album.url, |
import { request } from '../request.js'; | ||
import { sanitizeURL } from '../utils/links.js'; | ||
export default class Artist { | ||
@@ -19,5 +20,2 @@ token; | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
if (!artist) | ||
throw new Error('This artist could not be found.'); | ||
const response = { | ||
@@ -59,3 +57,3 @@ name: artist.name, | ||
name: attr.artist, | ||
url: `https://www.last.fm/music/${encodeURIComponent(attr.artist)}`, | ||
url: `https://www.last.fm/music/${sanitizeURL(attr.artist)}`, | ||
}, | ||
@@ -101,3 +99,3 @@ }, | ||
name: attr.artist, | ||
url: `https://www.last.fm/music/${encodeURIComponent(attr.artist)}`, | ||
url: `https://www.last.fm/music/${sanitizeURL(attr.artist)}`, | ||
}, | ||
@@ -131,3 +129,3 @@ page: Number(attr.page), | ||
name: attr.artist, | ||
url: `https://www.last.fm/music/${encodeURIComponent(attr.artist)}`, | ||
url: `https://www.last.fm/music/${sanitizeURL(attr.artist)}`, | ||
}, | ||
@@ -169,3 +167,3 @@ tags, | ||
name: attr.artist, | ||
url: `https://www.last.fm/music/${encodeURIComponent(attr.artist)}`, | ||
url: `https://www.last.fm/music/${sanitizeURL(attr.artist)}`, | ||
}, | ||
@@ -172,0 +170,0 @@ page: Number(attr.page), |
import { request } from '../request.js'; | ||
import { sanitizeURL } from '../utils/links.js'; | ||
export default class Tag { | ||
@@ -23,3 +24,3 @@ token; | ||
}, | ||
url: `https://www.last.fm/tag/${encodeURIComponent(tag.name)}`, | ||
url: `https://www.last.fm/tag/${sanitizeURL(tag.name)}`, | ||
}; | ||
@@ -54,3 +55,3 @@ } | ||
}, | ||
url: `https://www.last.fm/music/${encodeURIComponent(album.artist.name)}/${encodeURIComponent(album.name)}`, | ||
url: `https://www.last.fm/music/${sanitizeURL(album.artist.name)}/${sanitizeURL(album.name)}`, | ||
image, | ||
@@ -57,0 +58,0 @@ }; |
import { request } from '../request.js'; | ||
import { sanitizeURL } from '../utils/links.js'; | ||
export default class Track { | ||
@@ -96,5 +97,5 @@ token; | ||
name: attr.artist, | ||
url: `https://www.last.fm/music/${encodeURIComponent(attr.artist)}`, | ||
url: `https://www.last.fm/music/${sanitizeURL(attr.artist)}`, | ||
}, | ||
url: `https://www.last.fm/music/${encodeURIComponent(attr.artist)}/_/${encodeURIComponent(trackName)}`, | ||
url: `https://www.last.fm/music/${sanitizeURL(attr.artist)}/_/${sanitizeURL(trackName)}`, | ||
tracks, | ||
@@ -125,5 +126,5 @@ }; | ||
name: attr.artist, | ||
url: `https://www.last.fm/music/${encodeURIComponent(attr.artist)}`, | ||
url: `https://www.last.fm/music/${sanitizeURL(attr.artist)}`, | ||
}, | ||
url: `https://www.last.fm/music/${encodeURIComponent(attr.artist)}/_/${encodeURIComponent(attr.track)}`, | ||
url: `https://www.last.fm/music/${sanitizeURL(attr.artist)}/_/${sanitizeURL(attr.track)}`, | ||
tags, | ||
@@ -146,8 +147,2 @@ }; | ||
const tracks = track.map((track) => { | ||
const image = track.image.map((i) => { | ||
return { | ||
size: i.size, | ||
url: i['#text'], | ||
}; | ||
}); | ||
return { | ||
@@ -158,6 +153,5 @@ name: track.name, | ||
name: track.artist, | ||
url: `https://www.last.fm/music/${encodeURIComponent(track.artist)}`, | ||
url: `https://www.last.fm/music/${sanitizeURL(track.artist)}`, | ||
}, | ||
url: track.url, | ||
image, | ||
}; | ||
@@ -164,0 +158,0 @@ }); |
import { request } from '../request.js'; | ||
import { sanitizeURL } from '../utils/links.js'; | ||
export default class User { | ||
@@ -218,3 +219,3 @@ token; | ||
name: track.artist['#text'], | ||
url: `https://www.last.fm/music/${encodeURIComponent(track.artist['#text'])}`, | ||
url: `https://www.last.fm/music/${sanitizeURL(track.artist['#text'])}`, | ||
}, | ||
@@ -221,0 +222,0 @@ album: track.album['#text'] || null, |
import { SearchParameters } from 'ofetch'; | ||
import { requestMethods } from './types/index.js'; | ||
export declare function request<T = unknown, M = requestMethods>(method: M, params: SearchParameters): Promise<T>; | ||
import { RequestMethods } from './types/index.js'; | ||
export declare function request<T = unknown, M = RequestMethods>(method: M, params: SearchParameters): Promise<T>; |
@@ -1,2 +0,3 @@ | ||
import { $fetch } from 'ofetch'; | ||
import { $fetch, FetchError } from 'ofetch'; | ||
import LastFMError from './utils/error.js'; | ||
export async function request(method, params) { | ||
@@ -13,4 +14,7 @@ const baseURL = 'https://ws.audioscrobbler.com/2.0'; | ||
}, | ||
}).catch((err) => { | ||
if (err instanceof FetchError && !err.response?.ok) | ||
throw new LastFMError(err.data); | ||
}); | ||
return data; | ||
} |
@@ -24,3 +24,3 @@ import type { ImageType } from './index.js'; | ||
url: string; | ||
image?: ImageType[] | null; | ||
image: ImageType[]; | ||
} | ||
@@ -53,4 +53,4 @@ export declare interface AlbumGetTopTagsType { | ||
url: string; | ||
image?: ImageType[] | null; | ||
image: ImageType[]; | ||
}>; | ||
} |
@@ -58,3 +58,3 @@ import type { ImageType } from './index.js'; | ||
url: string; | ||
image?: ImageType[] | null; | ||
image: ImageType[]; | ||
}>; | ||
@@ -61,0 +61,0 @@ } |
export type PersonalTagTypes = 'album' | 'artist' | 'track'; | ||
export type requestMethods = 'album.getInfo' | 'album.getTopTags' | 'album.search' | 'artist.getInfo' | 'artist.getSimilar' | 'artist.getTopAlbums' | 'artist.getTopTags' | 'artist.getTopTracks' | 'artist.search' | 'chart.getTopArtists' | 'chart.getTopTags' | 'chart.getTopTracks' | 'geo.getTopArtists' | 'geo.getTopTracks' | 'library.getArtists' | 'tag.getInfo' | 'tag.getTopAlbums' | 'tag.getTopArtists' | 'tag.getTopTags' | 'tag.getTopTracks' | 'tag.getWeeklyChartList' | 'track.getInfo' | 'track.getSimilar' | 'track.getTopTags' | 'track.search' | 'user.getFriends' | 'user.getInfo' | 'user.getLovedTracks' | 'user.getPersonalTags' | 'user.getRecentTracks' | 'user.getTopAlbums' | 'user.getTopTags' | 'user.getTopTracks'; | ||
export type ImageSizes = 'extralarge' | 'large' | 'medium' | 'mega' | 'small'; | ||
export type RequestMethods = 'album.getInfo' | 'album.getTopTags' | 'album.search' | 'artist.getInfo' | 'artist.getSimilar' | 'artist.getTopAlbums' | 'artist.getTopTags' | 'artist.getTopTracks' | 'artist.search' | 'chart.getTopArtists' | 'chart.getTopTags' | 'chart.getTopTracks' | 'geo.getTopArtists' | 'geo.getTopTracks' | 'library.getArtists' | 'tag.getInfo' | 'tag.getTopAlbums' | 'tag.getTopArtists' | 'tag.getTopTags' | 'tag.getTopTracks' | 'tag.getWeeklyChartList' | 'track.getInfo' | 'track.getSimilar' | 'track.getTopTags' | 'track.search' | 'user.getFriends' | 'user.getInfo' | 'user.getLovedTracks' | 'user.getPersonalTags' | 'user.getRecentTracks' | 'user.getTopAlbums' | 'user.getTopTags' | 'user.getTopTracks'; | ||
export interface Image { | ||
@@ -4,0 +5,0 @@ size: string; |
@@ -27,3 +27,3 @@ import type { ImageType } from './index.js'; | ||
url: string; | ||
image?: ImageType[] | null; | ||
image: ImageType[]; | ||
}>; | ||
@@ -30,0 +30,0 @@ } |
@@ -18,3 +18,3 @@ import type { ImageType } from './index.js'; | ||
name: string | null; | ||
image?: ImageType[] | null; | ||
image: ImageType[]; | ||
url: string | null; | ||
@@ -40,3 +40,2 @@ }; | ||
url: string; | ||
image?: ImageType[] | null; | ||
}>; | ||
@@ -61,3 +60,3 @@ } | ||
url: string; | ||
image?: ImageType[] | null; | ||
image: ImageType[]; | ||
}>; | ||
@@ -64,0 +63,0 @@ } |
@@ -30,3 +30,3 @@ import type { ImageType, PersonalTagType } from './index.js'; | ||
url: string; | ||
image?: ImageType[] | null; | ||
image: ImageType[]; | ||
}>; | ||
@@ -40,3 +40,3 @@ } | ||
url: string; | ||
image?: ImageType[] | null; | ||
image: ImageType[]; | ||
} | ||
@@ -89,3 +89,3 @@ export declare interface UserLovedTracksType { | ||
url: string; | ||
image?: ImageType[] | null; | ||
image: ImageType[]; | ||
}>; | ||
@@ -110,3 +110,3 @@ } | ||
url: string; | ||
image?: ImageType[] | null; | ||
image: ImageType[]; | ||
}>; | ||
@@ -144,4 +144,4 @@ } | ||
url: string; | ||
image?: ImageType[] | null; | ||
image: ImageType[]; | ||
}>; | ||
} |
{ | ||
"name": "@solely/simple-fm", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"license": "Zlib", | ||
@@ -38,5 +38,5 @@ "type": "module", | ||
"devDependencies": { | ||
"@types/jest": "^29.5.0", | ||
"@typescript-eslint/eslint-plugin": "^5.58.0", | ||
"@typescript-eslint/parser": "^5.58.0", | ||
"@types/jest": "^29.5.1", | ||
"@typescript-eslint/eslint-plugin": "^5.59.0", | ||
"@typescript-eslint/parser": "^5.59.0", | ||
"eslint": "^8.38.0", | ||
@@ -52,2 +52,3 @@ "eslint-config-clarity": "^1.0.1", | ||
"ts-node": "^10.9.1", | ||
"tsx": "^3.12.6", | ||
"typescript": "^5.0.4", | ||
@@ -54,0 +55,0 @@ "zod": "^3.21.4" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
94707
57
2697
0
16