From b35d5cacd4e2133f0f4933bf776f04e4e729424c Mon Sep 17 00:00:00 2001 From: gary510 <46637741+gary510@users.noreply.github.com> Date: Wed, 10 Jun 2020 11:57:34 -0700 Subject: [PATCH 1/2] Add files via upload --- README.md | 252 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 143 insertions(+), 109 deletions(-) diff --git a/README.md b/README.md index bb50ea3..3f70a2a 100644 --- a/README.md +++ b/README.md @@ -1,109 +1,143 @@ -# fresh_script - -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. - -## New Features! -[Flask](http://flask.pocoo.org/) has recently been added to the project. You can read up on how to get it setup [here](flask.md). - -## Getting Started - -### Prerequisites - -This project uses Python3. - -You will need to setup a Spotify developer account and register your app and obtain the following information: -* client id -* client secret -* your spotify username -* playlist id of the playlist you want to add the tracks to -* the url you want to redirect to for authentication, i.e. http://google.com/ - * this must be added under your app settings > Redirect URIs - -You will also need to setup a reddit instance with praw. [Here's](https://pythonforengineers.com/build-a-reddit-bot-part-1/) a useful guide I used to do this. - -### Setup your Credentials - -To set up your credentials, create a new file called `credentials.json` in the root of the project 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]" - } -} -``` - -### Installing dependencies -This project uses a dependency manager called [pipenv](https://pipenv.readthedocs.io). Follow the instructions to install it [here](https://pipenv.readthedocs.io/en/latest/install/#installing-pipenv). - -The project dependencies are listed in a [Pipfile](https://github.com/pypa/pipfile). Using pipenv, you can install all the dependencies with the following commands: -```bash -cd fresh_script -pipenv install -``` - -Pipenv uses [virtualenv](https://virtualenv.pypa.io/en/stable/) to create a python environment with all the dependencies listed in the Pipfile. Before running the fresh.py script, you must first activate the environment: -```bash -pipenv shell -``` - -If you wish to deactivate the environment use the command -```bash -exit -``` - -### Running the script - -Running the program is simple. The first time you run it, you will be asked for your Spotify credientials which will be saved to a config file for ease of use in the future. Choose to sort results by hot or new, enter a post limit, and then enjoy. - -``` -python3 fresh.py -``` - -### Script arguments - -The following arguments can be passed to the script - -| Short | Long | Type | Description | -|-------|------------------|--------|-------------| -| -s | --sort | string | Sort by hot, new, rising, random_rising, controversion or top | -| -l | --limit | int | How many posts to grab | -| -t | --threshold | int | Only posts with score above threshold | -| -f | --fresh | bool | Only add tracks with the \[FRESH\] tag | -| -ia | --include-albums | bool | Include tracks from albums | -| -v | --verbose | bool | Output songs being added and other info | -| -p | --playlists | bool | List, add, or remove playlists to add songs to | - -### 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. - -1. Follow the `running the script` instructions to make sure your `.config.ini` file is generated with the required parameters -2. Run `crontab -e` to open the cron editor, which is similar to vim -3. 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 - ``` - -## Contributing - -I appreciate any help and support. Feel free to [fork](https://github.com/amcquade/fresh_script#fork-destination-box) and [create a pull request](https://github.com/amcquade/fresh_script/compare) +# fresh_script + +Join us on Discord if you have anything to ask or discuss here : https://discord.gg/HQvcV8 + +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. + +## Getting Started + +### Prerequisites + +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/) + +### How to install Python3 + +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 + +1. To install Homebrew, open a ‘Terminal.app” window +2. Paste the below link to install Homebrew: + +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" + +3. In your terminal, type the following: + +brew install python3 + + +### How to set up your Spotify Developer Account + +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/ +1. Click ‘CREATE A CLIENT ID’ +2. Fill out the form +3. Copy the “Client ID” +4. Click “SHOW CLIENT SECRET” +5. Copy the “CLIENT SECRET” id code. +6. 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 + +### How to set up your Reddit Account + +You will need to have a Reddit Account. Please sign up at here: +https://www.reddit.com/register/ + +After signing up follow these instructions: + +1. Visit https://www.reddit.com/prefs/apps/ +2. Select “create another app…” +3. Fill out the form as desired +4. Copy the client id (located under your created app name) +5. Copy the secret id + + +## Download the repository + +The repository need to be downloaded onto your system in order to run. + +1. Visit the Fresh Script Github : https://github.com/amcquade/fresh_script +2. Click the “Clone or download” button and select “Download ZIP” +3. Open the ZIP file and extract the folder onto your computer + + +### Setup your Credentials + +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. + + +### Installing dependencies + +You will have to run steps 1 and 2 to set up the environment. + +1. Open the Command Prompt or Terminal App +2. Type the following depending on your systems: + +‘pip install --user pipenv’ + +### Running the script + +In your Command Prompt or Terminal App: + +1. Type in : ‘pipenv shell’ +2. Type in : ‘python3 fresh.py’ or ‘python fresh.py’ +3. Copy the link from the browser popup and enter it into the prompt +4. Choose the playlist that you would like to update +5. Enter the amount of songs you would like to add to the playlist +6. Choose the sorting method for the playlist order +7. Indicate if you would like to add songs with the “Fresh” tag +8. Refresh your Spotify app or site +9. 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 + +## Contributing + +I appreciate any help and support. Feel free to [fork](https://github.com/amcquade/fresh_script#fork-destination-box) and [create a pull request](https://github.com/amcquade/fresh_script/compare) + From 92ccf809dbeac3dfba18590607a7074b0e87cf63 Mon Sep 17 00:00:00 2001 From: gary510 <46637741+gary510@users.noreply.github.com> Date: Wed, 10 Jun 2020 12:07:24 -0700 Subject: [PATCH 2/2] Add files via upload --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f70a2a..2742ebb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # fresh_script -Join us on Discord if you have anything to ask or discuss here : https://discord.gg/HQvcV8 +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.