Skip to content

CalPolySEC/spotbot

Repository files navigation

SecLab Spotify Webpage

This is a Flask app to run the SecLab Spotify Webpage

===================

Prerequisites

  • Python 3
  • Pip3
  • Librespot

Running the app (development environment)

To run the site, install virtualenv on your machine with

pip install virtualenv

create a new virtualenv in the root of the git repository and activate it with

virtualenv .
source bin/activate

install the required pip packages with

pip install -r requirements.txt

And finally, run the app with

python app.py

then go to localhost:3000

For production

  1. Create a separate symlink for each file from etc/systemd/system/ into /etc/systemd/system/
sudo ln -s etc/systemd/system/librespot.service /etc/systemd/system/librespot.service
sudo ln -s etc/systemd/system/spotbot.service /etc/systemd/system/spotbot.service
sudo ln -s etc/systemd/system/spotbot_script.service /etc/systemd/system/spotbot_script.service
sudo ln -s etc/systemd/system/spotbot_script.timer /etc/systemd/system/spotbot_script.timer
  1. Edit the system service configuration files as needed to point to the correct directories and use the correct arguments to run script.sh.
  2. Start and enable the services on boot with
sudo systemctl start librespot.service
sudo systemctl enable librespot.service
sudo systemctl start spotbot.service
sudo systemctl enable spotbot.service
sudo systemctl start spotbot_script.service
sudo systemctl enable spotbot_script.service
sudo systemctl start spotbot_script.timer
  1. Create a symlink from etc/nginx/sites-available/spotbot into /etc/nginx/sites-available/spotbot
sudo ln -s etc/nginx/sites-available/spotbot /etc/nginx/sites-available/spotbot
  1. Create a symlink in sites-enabled to the site configuration file and reload nginx.
sudo ln -s /etc/nginx/sites-available/spotbot /etc/nginx/sites-enabled/spotbot
  1. Edit the nginx configuration file as needed to have uwsgi pointing to the correct directory.
  2. Add the following lines to your user crontab:
45 * * * * rm auth_token; authtoken
00 00 * * * rm librespot.log; touch librespot.log
  1. The site should now be live at your machine's IP address.