https://github.com/eyeblech/mu5ic-sugg3st
"Python script to get notified of a random music to listen to, on Discord, using Spotify API and Discord Webhook."
https://github.com/eyeblech/mu5ic-sugg3st
api notifier python recommender-system service spotify-api tools webhooks
Last synced: 12 months ago
JSON representation
"Python script to get notified of a random music to listen to, on Discord, using Spotify API and Discord Webhook."
- Host: GitHub
- URL: https://github.com/eyeblech/mu5ic-sugg3st
- Owner: eyeblech
- License: gpl-3.0
- Created: 2024-07-20T06:39:48.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-20T07:18:04.000Z (almost 2 years ago)
- Last Synced: 2025-06-03T07:45:10.589Z (about 1 year ago)
- Topics: api, notifier, python, recommender-system, service, spotify-api, tools, webhooks
- Language: Python
- Homepage: https://eyeblech.github.io/mu5ic-sugg3st/
- Size: 21.5 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Introduction
"Python script to get notified of a random music to listen to, on Discord, using Spotify API and Discord Webhook."
# Getting Started
## Step 1: Set up a Discord Webhook
* Open your Discord server.
* Go to Server Settings > Integrations > Webhooks.
* Click "New Webhook" and customize it as you like.
* Copy the Webhook URL.
## Step 2: Set Up Spotify API Access
* Create a Spotify Developer Account:
* Go to the Spotify Developer Dashboard and log in with your Spotify account.
Create a New Spotify App:
* Click "Create an App" and fill in the required fields (App name, App description, etc)
* After creating the app, you'll receive a "Client ID" and "Client Secret." Save these credentials.
### Get Access Token:
* Use the Spotify Web API Console or the Authorization Code Flow to get an access token.
* For simplicity, you can manually obtain a token via the Web API Console:
* Go to the Spotify Web API Console.
Log in with your Spotify account and click "Get Token" to authorize and get an access token.
```sh
curl -X POST "https://accounts.spotify.com/api/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=your-client-id&client_secret=your-client-secret"
```
* replace the client_id and client_secret before sending the request to get your access token
## Step 3: Preparing the Python Script
* Install required libraries
```sh
pip install requests
```
* copy the python script and make a new python file `song-notifier.py`
* Replace Placeholder Values
Open the `song-notifier.py` file and replace
`client_id`, `client_secret`,`access_token` and
`YOUR_DISCORD_WEBHOOK_URL`
* you can always modify the genre e.g `metal,rock,pop,rap,country e.t.c`, to get recommended, genre specified songs

## Running locally/cloud
* You can use Google Console , AWS or Heroku e.t.c
* "Instead, you choose to run it locally, create a cron job so that it can automatically run at specified intervals of time."
```sh
crontab -e
```
```sh
0 */8 * * * /usr/bin/python /home/samsep10l/Desktop/song-notifier.py
```
* to list cron jobs
```sh
crontab -l
```

