Join us on Discord if you have anything to ask or discuss here : https://discord.gg/ZAR9ZSp
This program will search for spotify tracks posted in the HipHopHeads subreddit and add them to a playlist of your choice. HipHopHeads is a subreddit dedicated to everything hiphop, including the latest mixtapes, videos, news, and anything else hip hop related from your favorite artists.
To set up this sciprt, you will need to install the following:
- Python3
- Spotify Developer Account
- Reddit Account
- Any code editor o I recommend Visual Studio Code (https://code.visualstudio.com/)
In order to run this script, you must have Python installed on your device.
** For Windows **
1.Visit https://www.python.org/downloads/windows/ and download the installer for your system
2. Run the installer
** For macOS **
Note: macOS users will need to download Homebrew, in order to install Python
- To install Homebrew, open a ‘Terminal.app” window
- Paste the below link to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- In your terminal, type the following:
brew install python3
You will need to setup a Spotify developer account. This account will share the username and password sas your regular Spotify account. You can register here: https://developer.spotify.com/
- Click ‘CREATE A CLIENT ID’
- Fill out the form
- Copy the “Client ID”
- Click “SHOW CLIENT SECRET”
- Copy the “CLIENT SECRET” id code.
- Create or choose any URL to redirect to for authentication, i.e. http://google.com/
- this must be added under your app settings > Redirect URIs
You will need to have a Reddit Account. Please sign up at here: https://www.reddit.com/register/
After signing up follow these instructions:
- Visit https://www.reddit.com/prefs/apps/
- Select “create another app…”
- Fill out the form as desired
- Copy the client id (located under your created app name)
- Copy the secret id
The repository need to be downloaded onto your system in order to run.
- Visit the Fresh Script Github : https://github.com/amcquade/fresh_script
- Click the “Clone or download” button and select “Download ZIP”
- Open the ZIP file and extract the folder onto your computer
Set up your credentials using your code editor. Create a new file called credentials.json
with the following contents:
{
"spotify": {
"username": "[Spotify username]",
"client_id": "[Spotify client id]",
"client_secret": "[Spotify client secret]",
"redirect": "[redirect uri]"
},
"reddit": {
"username": "[reddit username]",
"client_id": "[praw client id]",
"client_secret": "[praw client secret]"
}
}
Save this file to the same folder as your local repository from the ZIP file.
You will have to run steps 1 and 2 to set up the environment.
- Open the Command Prompt or Terminal App
- Type the following depending on your systems:
‘pip install --user pipenv’
In your Command Prompt or Terminal App:
- Type in : ‘pipenv shell’
- Type in : ‘python3 fresh.py’ or ‘python fresh.py’
- Copy the link from the browser popup and enter it into the prompt
- Choose the playlist that you would like to update
- Enter the amount of songs you would like to add to the playlist
- Choose the sorting method for the playlist order
- Indicate if you would like to add songs with the “Fresh” tag
- Refresh your Spotify app or site
- Enjoy your new music!
Running the script using cron We can use cron to automatically run the script periodically in order to keep it up-to-date. You will need either a macOS computer or Linux server to use cron.
Follow the running the script instructions to make sure your .config.ini file is generated with the required parameters Run crontab -e to open the cron editor, which is similar to vim Use the following format to create a line for your cron
-
-
-
-
- command to be executed
-
-
-
| | | | | | | | | ----- Day of week (0 - 7) (Sunday=0 or 7) | | | ------- Month (1 - 12) | | --------- Day of month (1 - 31) | ----------- Hour (0 - 23) ------------- Minute (0 - 59) For example, you would do the following to run this everyday at 9AM 0 9 * * * python /home/jsmith/fresh.py
I appreciate any help and support. Feel free to fork and create a pull request