bump librespot, add stored creds login to spotify

This commit is contained in:
uh wot
2024-09-05 22:22:14 +02:00
parent 98e28d9813
commit b72c8de219
3 changed files with 24 additions and 8 deletions

View File

@@ -9,6 +9,10 @@ import {
Track
} from '../../types.js'
interface SpotifyOptions extends LibrespotOptions {
storedCredential?: boolean
}
class Spotify implements StreamerWithLogin {
client: Librespot
hostnames = ['open.spotify.com']
@@ -27,11 +31,15 @@ class Spotify implements StreamerWithLogin {
}
} as const
constructor(options: LibrespotOptions) {
storedCredential: boolean
constructor(options: SpotifyOptions) {
this.client = new Librespot(options)
this.storedCredential = options.storedCredential == true
}
async login(username: string, password: string) {
return await this.client.login(username, password)
if (this.storedCredential) return await this.client.loginWithStoredCreds(username, password)
else return await this.client.login(username, password)
}
#getUrlParts(url: string): ['artist' | 'album' | 'track' | 'episode' | 'show', string] {
const urlObj = new URL(url)