Skip to content

Commit

Permalink
LastFM added to database
Browse files Browse the repository at this point in the history
  • Loading branch information
Choromanski committed Mar 20, 2019
1 parent 9dd683f commit 12b6c9f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
14 changes: 10 additions & 4 deletions app.py
Expand Up @@ -5,7 +5,7 @@
from werkzeug.security import generate_password_hash, check_password_hash
from functools import wraps
from time import sleep
import os, secrets, spotipy, pylast
import os, secrets, spotipy, pylast, pprint
import spotipy.oauth2 as oauth2

app = Flask(__name__)
Expand All @@ -31,6 +31,8 @@

lastfm = pylast.LastFMNetwork(api_key=lastfm_id, api_secret=lastfm_secret)

pp = pprint.PrettyPrinter(indent=4)


@app.route('/', methods=['GET', 'POST'])
def homepage():
Expand Down Expand Up @@ -62,11 +64,13 @@ def homepage():
if len(results['artists']['items'][count]['images']) == 0:
data.append({"img": "static/img/note.png",
"name": results['artists']['items'][count]['name'],
"artist": results['artists']['items'][count]['name']})
"artist": results['artists']['items'][count]['name'],
"spotifyid": results['artists']['items'][count]['id']})
else:
data.append({"img": results['artists']['items'][count]['images'][0]['url'],
"name": results['artists']['items'][count]['name'],
"artist": results['artists']['items'][count]['name']})
"artist": results['artists']['items'][count]['name'],
"spotifyid": results['artists']['items'][count]['id']})
count += 1
else:
for i in results['albums']['items']:
Expand Down Expand Up @@ -109,7 +113,9 @@ def create(type, spotifyid):
artist = result['artists'][0]['name']
lstfm = lastfm.get_track(artist, track).get_url()[26:]
elif type == "artist":
result = spotify.artis(tspotifyid)
result = spotify.artist(spotifyid)
artist = result['name']
lstfm = lastfm.get_artist(artist).get_url()[26:]
song = Song(url=key, type=type, spotifyid=spotifyid, lastfm=lstfm)
db.session.add(song)
db.session.commit()
Expand Down
14 changes: 7 additions & 7 deletions requirements.txt
@@ -1,9 +1,9 @@
alembic==1.0.8
aniso8601==5.1.0
aniso8601==6.0.0
apple-music-python==1.0.2
asn1crypto==0.24.0
cachetools==3.1.0
certifi==2018.11.29
certifi==2019.3.9
cffi==1.12.2
chardet==3.0.4
Click==7.0
Expand All @@ -22,24 +22,24 @@ httplib2==0.12.1
idna==2.8
itsdangerous==1.1.0
Jinja2==2.10
Mako==1.0.7
Mako==1.0.8
MarkupSafe==1.1.1
psycopg2==2.7.7
pyasn1==0.4.5
pyasn1-modules==0.2.4
pycparser==2.19
PyJWT==1.7.1
pylast==3.0.0
pylast==3.1.0
python-dateutil==2.8.0
python-editor==1.0.4
pytz==2018.9
relativetimebuilder==0.2.0
relativetimebuilder==1.0.0
requests==2.21.0
rsa==4.0
six==1.12.0
spotipy==2.4.4
SQLAlchemy==1.3.0
SQLAlchemy==1.3.1
tidalapi==0.5.0
uritemplate==3.0.0
urllib3==1.24.1
Werkzeug==0.14.1
Werkzeug==0.15.0

0 comments on commit 12b6c9f

Please sign in to comment.