No description
Find a file
2025-08-30 11:26:43 -06:00
.github I guess nott 2025-05-31 16:58:11 -06:00
librespot fix: license + login5 2025-08-30 11:25:07 -06:00
librespot_player first commit 2025-05-30 21:28:21 -06:00
proto first commit 2025-05-30 21:28:21 -06:00
tests fix: license + login5 2025-08-30 11:25:07 -06:00
.gitignore first commit 2025-05-30 21:28:21 -06:00
LICENSE fix: license + login5 2025-08-30 11:25:07 -06:00
MANIFEST.in fix: license + login5 2025-08-30 11:25:07 -06:00
NOTICE fix: license + login5 2025-08-30 11:25:07 -06:00
README.md fix: README url 2025-08-30 11:26:43 -06:00
requirements.txt first commit 2025-05-30 21:28:21 -06:00
setup.py fix: license + login5 2025-08-30 11:25:07 -06:00

librespot-spotizerr

Spotizerr's librespot python integration

About The Project

This project is to further add more features for the Spotizerr project, forked from librespot-python

Getting Started

Prerequisites

Installation

pip install librespot-spotizerr

Usage

Use Zeroconf for Login (no premium required)

from librespot.zeroconf import ZeroconfServer
import time
import logging
import pathlib

zs = ZeroconfServer.Builder().create()
logging.warning("Transfer playback from desktop client to librespot-spotizerr via Spotify Connect in order to store session")

while True:
    time.sleep(1)
    if zs._ZeroconfServer__session:
        logging.warning(f"Grabbed {zs._ZeroconfServer__session} for {zs._ZeroconfServer__session.username()}")
        
        if pathlib.Path("credentials.json").exists():
            logging.warning("Session stored in credentials.json. Now you can Ctrl+C")
            break

Get Music Stream

*Currently, music streaming is supported, but it may cause unintended behavior.

from librespot.core import Session
from librespot.metadata import TrackId
from librespot.audio.decoders import AudioQuality, VorbisOnlyAudioQuality

session = Session.Builder() \
    .user_pass("Username", "Password") \
    .create()

track_id = TrackId.from_uri("spotify:track:xxxxxxxxxxxxxxxxxxxxxx")
stream = session.content_feeder().load(track_id, VorbisOnlyAudioQuality(AudioQuality.VERY_HIGH), False, None)
# stream.input_stream.stream().read() to get one byte of the music stream.

Debug

To display the debug information, you need to inject the following code at the top of the code.

import logging


logging.basicConfig(level=logging.DEBUG)

Contributing

Pull requests are welcome.

License

Licensed under the Apache License, Version 2.0. See LICENSE for more information.