Skip to content

Commit

Permalink
Instructions Update
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurVardevanyan committed Apr 1, 2021
1 parent db67e66 commit 29f8b70
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 60 deletions.
119 changes: 118 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Analytics for Spotify
### Not Currently Setup For Deployment
### WIP


Self Hosted Last.FM Alternative to keeping track of your Spotify History
Expand All @@ -24,3 +24,120 @@ Notes:

![Alt text](img/SpotifyAnalyticsSample.png?raw=true "Sample Output")



## Installation Instructions
## This contains only installation instructions. Thier are currently no Update Instructions!!!
### Instructions are for installing a VM / No Other Websites Hosted.
### This Project is a work in progress.<br> The database structure could change in future versions.
#### Installation Instructions are also a work in progress and were tested on Ubuntu Server 20.04.2.
I currently run this virtualized on a Virtual Machine running Debian 10.
#### Please Thoroughly Read The Instructions
### Note:
This must run on a machine that is always on or<br />
it must be on and running when you want to keep track of play history.

Ideal Setup is a Local Server or a Local Machine<br />

Do not run on an external machine or allow external network access.<br />
It is Not Setup for Secure External Operation.

Default Installation are as follows. <br />

### Get Spotify API Credentials:
Create a Non-Commercial Spotify App: https://developer.spotify.com/dashboard

For API Redirect URL Box<br />
Same Machine: http://localhost:PORT<br />
Local Server http://IPV4ADDRESS:PORT <br>
(Replace with the Local IPv4 Address of your server)<br />
Port 80 is recommended. However if you already using port 80 for another service, you will need to use a different port.

Keep Track of your Client ID, Secret Key, and Redirect Url<br />


### Code:
SSH into Local Server or run on local machine.<br />
Default Installation is ~/.

```
cd ~/
git clone https://github.com/ArthurVardevanyan/Analytics-for-Spotify.git
```


### Database Setup :
If you have a mariaDB or mySQL database setup with proper credentials, ou may skip this section.
```
sudo apt-get install mariadb-server
```
Log Into MySql (sudo password, if asked)
```
sudo mysql
```
Within mysql Create User, Grant Privileges, and create database. <br/>
Note: Alter statement may error out on older versions of MySql, you can ignore the error and continue.
```
CREATE USER 'spotify'@'localhost' IDENTIFIED BY 'spotify';
GRANT ALL PRIVILEGES ON *.* TO 'spotify'@'localhost';
alter user 'spotify'@'localhost' identified with mysql_native_password by 'spotify';
flush privileges;
create database spotify;
exit;
```

The default database credentials are:
```
host = localhost
database = spotify
user = spotify
password = spotify
```
### Project Setup :
Run the setup.py to setup the project.
```
sudo apt-get install python3-pip libmariadb-dev
```
```
cd Analytics-for-Spotify
pip3 install -r requirements.txt && sudo pip3 install -r requirements.txt
python3 setup.py
```



### WSGI Apache WebServer Setup:
If you have an existing webserver you will need to modify the below to run on a different port / virtual host.<br>
Otherwise just delete everything in the file below and replace with this.<br>
You must change "PATH_TO_PROGRAM" with your path.
```
sudo apt-get install apache2 libapache2-mod-wsgi-py3
sudo nano /etc/apache2/sites-available/000-default.conf
```

```
<VirtualHost *:80>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /spotify /PATH_TO_PROGRAM/Analytics-for-Spotify/webFrontend
<Directory /PATH_TO_PROGRAM/Analytics-for-Spotify/webFrontend>
Require all granted
</Directory>
<Directory /PATH_TO_PROGRAM/Analytics-for-Spotify/AnalyticsforSpotify>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess AnalyticsforSpotify python-path=//PATH_TO_PROGRAM/Analytics-for-Spotify/
WSGIScriptAlias / /PATH_TO_PROGRAM/Analytics-for-Spotify/AnalyticsforSpotify/wsgi.py process-group=AnalyticsforSpotify application-group=%{GLOBAL}
WSGIProcessGroup AnalyticsforSpotify
</VirtualHost>
```

```
sudo systemctl restart apache2
```
After Navigating to the IP, Click "Start Service"
10 changes: 3 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

def unzip():
with zipfile.ZipFile("webFrontend/node_modules.zip", 'r') as zip_ref:
zip_ref.extractall("webFrontend/node_modules")
zip_ref.extractall("webFrontend/")


def executeScriptsFromFile(c, filename):
Expand All @@ -34,11 +34,7 @@ def executeScriptsFromFile(c, filename):


def main():
print("*Disclaimer*, DO NOT USE WITH PUBLIC ACCESS")
print("Installing OS Dependencies")
os.system("sudo apt-get install python3-pip libmariadb-dev")
print("Installing Python Dependencies")
os.system("pip install -r requirements.txt")
print("*Disclaimer*, DO NOT USE WITH PUBLIC ACCESS")
unzip()
CLIENT = input("Enter Spotify Client Key:")
SECRET = input("Enter Spotify Secret Key:")
Expand All @@ -60,7 +56,7 @@ def main():
ENV = [
"D_DEBUG = True",
"D_SECRET = '" + str(DJANGO_PRIVATE) + "'",
"HOSTS = []",
"HOSTS = ['*']",
]
with open("AnalyticsforSpotify/env.py", 'w+') as f:
f.writelines('\n'.join(ENV))
Expand Down
43 changes: 0 additions & 43 deletions songMonitoringBackend/log.py

This file was deleted.

12 changes: 3 additions & 9 deletions songMonitoringBackend/spotify.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import songMonitoringBackend.playlistSongs as playlistSongs
import songMonitoringBackend.database as database
from webBackend.credentials import refresh_token as authorize
import requests
import time
import _thread
Expand All @@ -8,15 +11,6 @@
from _datetime import timedelta
import sys
sys.path.append("..")
from webBackend.credentials import refresh_token as authorize
import songMonitoringBackend.database as database
import songMonitoringBackend.log as log
import songMonitoringBackend.playlistSongs as playlistSongs

os.chdir(os.path.abspath(os.path.dirname(__file__)))
log.logInit("spotify")
print = log.Print
input = log.Input


def update_status(user, status, value):
Expand Down

0 comments on commit 29f8b70

Please sign in to comment.