Application is online in here
-
1 User signs up
-
1.2. main.py writes user's id, name, mail and hashed password to USER table.
-
2 User signs in
-
2.1. main.py checks whether user has selected movies in order to get recommendations.
def get_album_tracks(album_id): | |
""" | |
Returns: dictionary object. | |
Track ids as keys, track names as values. | |
""" | |
tracks = [] | |
results = sp.album_tracks(album_id) | |
tracks.extend(results['items']) | |
# By default album_tracks function can obtain up to 50 item from spotify API in one try. | |
# If there is more than 50 items, this function will return 'next'. |
def get_artist_albums(artist): | |
""" | |
---------- | |
artist: artist's information that obtained by get_artist function. | |
---------- | |
Returns: dictionary object. | |
Album names as keys, album ids as values. | |
""" | |
albums = [] | |
results = sp.artist_albums(artist['id'], album_type='album') |
def get_artist(name): | |
""" | |
---------- | |
name: 'Name of Spotify artist' | |
---------- | |
Returns: dictionary object. | |
Given Spotify Artist's information. | |
""" | |
results = sp.search(q='artist:' + name, type='artist') | |
items = results['artists']['items'] |
import spotipy | |
from spotipy.oauth2 import SpotifyClientCredentials | |
with open('app_token.txt', 'r') as file: | |
tokens = file.read() | |
token_dict = json.loads(tokens) | |
client_credentials_manager = \ | |
SpotifyClientCredentials(client_id=token_dict['client_id'], |
movie_names = movies.set_index('movieId')['title'].to_dict() | |
g=ratings.groupby('movieId')['rating'].count() | |
#TopMovies are top 3000 movies that got more user reviews than others. | |
topMovies=g.sort_values(ascending=False).index.values[:3000] | |
uniq = ratings.movieId.unique() # Ids of unique movies. | |
name2idx = {o:i for i,o in enumerate(uniq)} | |
topMovieIdx = np.array([name2idx[o] for o in topMovies]) # Indices of top rated movies in ratings.csv |
import pandas as pd | |
import numpy as np | |
import tensorflow as tf | |
from tensorflow.keras import datasets, layers, models | |
from tensorflow.keras.layers import Input, add, dot, Flatten, Embedding,Dropout, concatenate | |
from tensorflow.keras.regularizers import l2 | |
from tensorflow.keras import optimizers | |
ratings = pd.read_csv('./data/ratings.csv') | |
ratings.drop('timestamp', 1, inplace=True) |
1 User signs up
1.2. main.py writes user's id, name, mail and hashed password to USER table.
2 User signs in
2.1. main.py checks whether user has selected movies in order to get recommendations.