playlist_search is a Python Flask app that helps users find which Spotify playlists a track is in.
-
Install Redis locally
-
git clone git@github.com:alexpogue/playlist_search.git
-
cd playlist_search
-
Set up config.py as follows
SQLALCHEMY_DATABASE_URI="sqlite:///database.db" SQLALCHEMY_TRACK_MODIFICATIONS=False SPOTIFY_CLIENT_ID="<spotify client id>" SPOTIFY_CLIENT_SECRET="<spotify client secret>" CELERY_BROKER_URL="redis://127.0.0.1:6379" CELERY_RESULT_BACKEND="redis://127.0.0.1:6379"
Note: change
SQLALCHEMY_DATABASE_URI
if you want to post to another database. -
pipenv shell
-
pipenv install --ignore-pipfile
- Open two terminals
cd playlist_search
in bothpipenv shell
in both- Run in one of the terminals:
celery -A celery_worker.celery worker --loglevel=info
- To run the app, in the other terminal, either:
- For Flask dev server:
python main.py
- For gunicorn:
gunicorn --bind 0.0.0.0:5000 wsgi
- For Flask dev server:
cd wordpress_plugin
zip -r playlist-search-plugin.zip playlist-search-plugin
- Navigate to the Wordpress plugins page and install it from the zip file.
- To put the tool somewhere in wordpress, insert the shortcode
[playlist-search-tool]
into any Wordpress post. - To update the database with the
particledetector
andsoundsofspotify
playlists, navigate to the plugin settings from the main Wordpress dashboard and press theUpdate db
button. A loading bar should appear showing the status.
- Copy
etc/systemd/system/playlist_search.service
in the repo to/etc/systemd/system/playlist_search.service
- In the above file, under
[Service]
, change the WorkingDirectory to the location the repo is cloned to. chmod 644 /etc/systemd/system/playlist_search.service
- To start, run
systemctl start playlist_search
- To enable on boot:
systemctl enable playlist_search
- Ensure
systemctl status playlist_search
outputs "enabled" as in the following output:vvvvvvv Loaded: loaded (/etc/systemd/system/playlist_search.service; enabled; vendor preset: disabled)
- Copy
etc/default/celeryd
in the repo to/etc/default/celeryd
- In the above file, change
cd
portion ofCELERY_BIN
to the location the repo is cloned to. chmod 755 /etc/default/celeryd
- To start, run
service celeryd start
- To enable on boot:
chkconfig --add celeryd
- Ensure
chkconfig --list celeryd
outputs the following:celeryd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
- If above command returned more things listed
off
, try runningchkconfig celeryd on
and try again
- If there are errors in db update, the loading bar will show red, and you should press
Update db
again. This can happen frequently with the main fork of spotipy that we use (I don't think it refreshes the auth token or something). - Only press the button once at a time - each press will start a new celery worker. Eventually we might only allow one celery worker, but I haven't started that work.
- The
Download CSV
link takes a second to show up since we run another HTTP request to get the results again. Instead, we can run one HTTP request and generate both the results and the CSV file using the single request. Previously we had the server process the request and send us a CSV download directly, but I don't think that's possible through the Wordpress AJAX proxy.