mirror of
https://codeberg.org/lucida/lucida.git
synced 2026-11-14 23:57:27 -05:00
format and lint
This commit is contained in:
@@ -152,16 +152,15 @@ export default class Deezer implements StreamerWithLogin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async login(username: string, password: string): Promise<void> {
|
async login(username: string, password: string): Promise<void> {
|
||||||
if (this.arl) {
|
if (this.arl) await this.#loginViaArl(this.arl)
|
||||||
await this.#loginViaArl(this.arl)
|
else {
|
||||||
} else {
|
|
||||||
const resp = await fetch('https://www.deezer.com/', { headers: this.headers })
|
const resp = await fetch('https://www.deezer.com/', { headers: this.headers })
|
||||||
const setCookie = resp.headers.get('Set-Cookie') ?? ''
|
const setCookie = resp.headers.get('Set-Cookie') ?? ''
|
||||||
const sid = setCookie.match(/sid=(fr[0-9a-f]+)/)![1]
|
const sid = setCookie.match(/sid=(fr[0-9a-f]+)/)![1]
|
||||||
this.headers['Cookie'] = `sid=${sid}`
|
this.headers['Cookie'] = `sid=${sid}`
|
||||||
|
|
||||||
password = this.#md5(password)
|
password = this.#md5(password)
|
||||||
|
|
||||||
const loginReq = await fetch(
|
const loginReq = await fetch(
|
||||||
`https://connect.deezer.com/oauth/user_auth.php?${new URLSearchParams({
|
`https://connect.deezer.com/oauth/user_auth.php?${new URLSearchParams({
|
||||||
app_id: CLIENT_ID,
|
app_id: CLIENT_ID,
|
||||||
@@ -172,9 +171,9 @@ export default class Deezer implements StreamerWithLogin {
|
|||||||
{ headers: this.headers }
|
{ headers: this.headers }
|
||||||
)
|
)
|
||||||
const { error } = <DeezerLoginResponse>await loginReq.json()
|
const { error } = <DeezerLoginResponse>await loginReq.json()
|
||||||
|
|
||||||
if (error) throw new Error('Error while getting access token, check your credentials')
|
if (error) throw new Error('Error while getting access token, check your credentials')
|
||||||
|
|
||||||
const arl = await this.#apiCall('user.getArl')
|
const arl = await this.#apiCall('user.getArl')
|
||||||
await this.#loginViaArl(arl)
|
await this.#loginViaArl(arl)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user