Skip to content

Commit ffcc522

Browse files
authored
Merge pull request #6 from MusicBoxRaspberryPi/develop
Add ReadMe and .cache Creation
2 parents 3142825 + db243e1 commit ffcc522

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
# MusicBox
1+
<h1 align="center" id="title">Music Box API</h1>
2+
3+
<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>
4+
5+
6+
## 🛠️ Installation
7+
8+
1. Clone the repository `git clone https://github.com/MusicBoxRaspberryPi/MusicBoxAPI`
9+
2. Rename `.env.dist` to `.env`
10+
3. Edit `.env` to your needs
11+
4. Install dependencies `pip install -r requirements.txt`
12+
5. [Create Spotify App](https://developer.spotify.com/dashboard) with redirect URIs: `http://localhost:8080`
13+
6. Copy **Client ID** and **Client Secret** from _Spotify App -> Settings -> View client secret_ to `.env`
14+
7. Run `python -m app.spotify.service`, webpage should open in your browser and `.cache` file should be created
15+
16+
## 🚀 Usage
17+
18+
- With Docker: `docker compose up`
19+
20+
- Without Docker: `python -m app.main`

app/spotify/service.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,19 @@ def get_devices_count(self) -> int:
9393
def __get_devices_from_api(self) -> list[Device]:
9494
devices_json = self.__api.devices()["devices"]
9595
return [Device(**device) for device in devices_json]
96+
97+
98+
if __name__ == "__main__":
99+
import dotenv
100+
from app.container import Container
101+
102+
dotenv.load_dotenv()
103+
container = Container()
104+
105+
SpotifyService(
106+
client_id=container.config.spotify.client_id(),
107+
client_secret=container.config.spotify.client_secret(),
108+
redirect_uri=container.config.spotify.redirect_uri()
109+
)
110+
111+
print(".cache file created")

0 commit comments

Comments
 (0)