Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
# MusicBox
<h1 align="center" id="title">Music Box API</h1>

<p align="center"><img src="https://socialify.git.ci/MusicBoxRaspberryPi/MusicBoxAPI/image?description=1&amp;font=Inter&amp;language=1&amp;name=1&amp;owner=1&amp;theme=Light" alt="project-image"></p>


## 🛠️ Installation

1. Clone the repository `git clone https://github.com/MusicBoxRaspberryPi/MusicBoxAPI`
2. Rename `.env.dist` to `.env`
3. Edit `.env` to your needs
4. Install dependencies `pip install -r requirements.txt`
5. [Create Spotify App](https://developer.spotify.com/dashboard) with redirect URIs: `http://localhost:8080`
6. Copy **Client ID** and **Client Secret** from _Spotify App -> Settings -> View client secret_ to `.env`
7. Run `python -m app.spotify.service`, webpage should open in your browser and `.cache` file should be created

## 🚀 Usage

- With Docker: `docker compose up`

- Without Docker: `python -m app.main`
16 changes: 16 additions & 0 deletions app/spotify/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,19 @@ def get_devices_count(self) -> int:
def __get_devices_from_api(self) -> list[Device]:
devices_json = self.__api.devices()["devices"]
return [Device(**device) for device in devices_json]


if __name__ == "__main__":
import dotenv
from app.container import Container

dotenv.load_dotenv()
container = Container()

SpotifyService(
client_id=container.config.spotify.client_id(),
client_secret=container.config.spotify.client_secret(),
redirect_uri=container.config.spotify.redirect_uri()
)

print(".cache file created")