mirror of
https://codeberg.org/lucida/lucida.git
synced 2026-11-17 00:57:25 -05:00
add token login for qobuz, bump version
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "lucida",
|
"name": "lucida",
|
||||||
"version": "1.2.5",
|
"version": "1.2.6",
|
||||||
"description": "A modular downloader tool",
|
"description": "A modular music downloader tool",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"types": "build/index.d.ts",
|
"types": "build/index.d.ts",
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ function md5(str: string): string {
|
|||||||
interface QobuzOptions {
|
interface QobuzOptions {
|
||||||
appSecret: string
|
appSecret: string
|
||||||
appId: string
|
appId: string
|
||||||
|
token?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Qobuz implements StreamerWithLogin {
|
export default class Qobuz implements StreamerWithLogin {
|
||||||
@@ -34,6 +35,7 @@ export default class Qobuz implements StreamerWithLogin {
|
|||||||
constructor(options: QobuzOptions) {
|
constructor(options: QobuzOptions) {
|
||||||
this.appSecret = options.appSecret
|
this.appSecret = options.appSecret
|
||||||
this.appId = options.appId
|
this.appId = options.appId
|
||||||
|
if (options.token) this.token = options.token
|
||||||
}
|
}
|
||||||
|
|
||||||
async #get(url: string, params: { [key: string]: string | number }) {
|
async #get(url: string, params: { [key: string]: string | number }) {
|
||||||
@@ -88,18 +90,20 @@ export default class Qobuz implements StreamerWithLogin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async login(username: string, password: string) {
|
async login(username: string, password: string) {
|
||||||
const params: { [key: string]: string } = {
|
if (!this.token) {
|
||||||
username,
|
const params: { [key: string]: string } = {
|
||||||
password: md5(password),
|
username,
|
||||||
extra: 'partner',
|
password: md5(password),
|
||||||
app_id: this.appId
|
extra: 'partner',
|
||||||
}
|
app_id: this.appId
|
||||||
|
}
|
||||||
|
|
||||||
interface LoginResponse {
|
interface LoginResponse {
|
||||||
user_auth_token: string
|
user_auth_token: string
|
||||||
|
}
|
||||||
|
const loginResponse = <LoginResponse>await this.#getSigned('user/login', params)
|
||||||
|
this.token = loginResponse.user_auth_token
|
||||||
}
|
}
|
||||||
const loginResponse = <LoginResponse>await this.#getSigned('user/login', params)
|
|
||||||
this.token = loginResponse.user_auth_token
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async search(query: string, limit = 10): Promise<SearchResults> {
|
async search(query: string, limit = 10): Promise<SearchResults> {
|
||||||
|
|||||||
@@ -65,9 +65,7 @@ export async function parseAlbum(raw: RawAlbum): Promise<Album> {
|
|||||||
artists: [parseArtist(raw.user)]
|
artists: [parseArtist(raw.user)]
|
||||||
}
|
}
|
||||||
if (raw.tracks?.[0]?.artwork_url != undefined) {
|
if (raw.tracks?.[0]?.artwork_url != undefined) {
|
||||||
album.coverArtwork = [
|
album.coverArtwork = [await parseCoverArtwork(raw?.tracks?.[0]?.artwork_url)]
|
||||||
await parseCoverArtwork(raw?.tracks?.[0]?.artwork_url)
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
return album
|
return album
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user