diff --git a/package.json b/package.json index 0c8bd08..a32fa7f 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "dependencies": { "blowfish-cbc": "^1.0.1", "image-size": "^1.1.1", - "librespot": "^0.2.11", + "librespot": "^0.2.12", "undici": "^6.19.4", "xmldom-qsa": "^1.1.3" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2dcb24d..d2e3006 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ importers: specifier: ^1.1.1 version: 1.1.1 librespot: - specifier: ^0.2.11 - version: 0.2.11 + specifier: ^0.2.12 + version: 0.2.12 undici: specifier: ^6.19.4 version: 6.19.4 @@ -464,8 +464,8 @@ packages: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} - librespot@0.2.11: - resolution: {integrity: sha512-WAbqvBCqiyutBSC+3rxIsIJcsFcb7l9fyAHVtvPLh3qHyIimV4jqN46GkLgJDASzTuNK9F6v3yG6EQcSh0Zn8Q==} + librespot@0.2.12: + resolution: {integrity: sha512-c3/bikWtgu64S2zWjiKXM4xs2YfsodpZGtHhpQ6fLqqw414rvO85NcwPnadh6GRHdYeSE4z8k5qF4n9rBeQAow==} locate-path@6.0.0: resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} @@ -658,6 +658,9 @@ packages: resolution: {integrity: sha512-i3uaEUwNdkRq2qtTRRJb13moW5HWqviu7Vl7oYRYz++uPtGHJj+x7TGjcEuwS5Mt2P4nA0U9dhIX3DdB6JGY0g==} engines: {node: '>=18.17'} + unplayplay@1.0.0: + resolution: {integrity: sha512-ukQX79Ze9I4+gZARvyQY36ZRkkoFrzvDZmzL39DCODvFjRARVjo+hD/azDBkIa3b73tmd8hKMszrQzfi7hi+SQ==} + uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} @@ -1135,12 +1138,13 @@ snapshots: prelude-ls: 1.2.1 type-check: 0.4.0 - librespot@0.2.11: + librespot@0.2.12: dependencies: fast-xml-parser: 4.3.4 protobufjs: 7.2.6 shannon-bindings: 0.1.0 undici: 5.28.3 + unplayplay: 1.0.0 locate-path@6.0.0: dependencies: @@ -1305,6 +1309,10 @@ snapshots: undici@6.19.4: {} + unplayplay@1.0.0: + dependencies: + node-addon-api: 8.1.0 + uri-js@4.4.1: dependencies: punycode: 2.3.1 diff --git a/src/streamers/spotify/main.ts b/src/streamers/spotify/main.ts index 0a99408..d9cd8a0 100644 --- a/src/streamers/spotify/main.ts +++ b/src/streamers/spotify/main.ts @@ -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)