zenxha / kpop

Tri 3 Project site built with flask
http://rubinfamily.dyndns.org:5000/
0 stars 2 forks source link

image

Kpop Music Site!

Group Project for tri3!

Links

Collaborators

How It's Made

Theme Section (5pt)

Finding similar song recommendations [API USE!] (Komay)

API use Code

import requests
import json
import os

# http://ws.audioscrobbler.com/2.0/?method=track.getsimilar&artist=official+hige+dandism&track=pretender&api_key=630846faaf3ca8d5cf4d712e56bd4989&format=json
class Song:
    """Initializer of class takes song info parameters and returns Class Object"""

    def __init__(self, artist, song, sorttype):
        self._artist = artist
        self._song = song
        self._sorttype = sorttype

    @property
    def similar_songs_list(self):
        artist_query_name = self._artist.replace(' ', '+')
        song_query_name = self._song.replace(' ', '+')
        response = requests.get('http://ws.audioscrobbler.com/2.0/?method=track.getsimilar&artist=' + artist_query_name + '&track=' + song_query_name + '&api_key=630846faaf3ca8d5cf4d712e56bd4989&format=json')
        res = response.json()

        res_array = []

        if 'similartracks' in res:
            for song in res['similartracks']['track']:
                res_array.append(song)

            if (self._sorttype == 'playcount'):
                res_array.sort(key=lambda x: x['playcount'], reverse=True)
            if (self._sorttype == 'alphabetical'):
                res_array.sort(key=lambda x: x['name'])
            if self._sorttype == 'similarity':
                res_array = res_array
                print(self._sorttype)

            return res_array
        else:
            return [                {
                "name": "Check your parameters again",
                "playcount": 0,
                "match": 0,
                "url": "https://www.last.fm/music/Official+HIGE+DANdism/_/Shukumei",
                "artist": {
                    "name": "Invalid Artist Link",
                    "url": "https://www.last.fm/music/Official+HIGE+DANdism"
                },
            }]

Home Page CSS(Chris)

About The Creators (Charlie)

About The Creators

{% endblock %}

## Database Functions (Devam)
- Controls the inputs of the form
- Holds all the URL's to the spotify playlist links that people input
```python
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()

# Function that initializes the db and creates the tables
def db_init(app):
    db.init_app(app)

    # Creates the logs tables if the db doesnt already exist
    with app.app_context():
        db.create_all()
        print('h')

class Playlist(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    playlistname = db.Column(db.Text, nullable=False)
    username = db.Column(db.Text, nullable=False)
    url = db.Column(db.Text, nullable=False)

class MV(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    songname = db.Column(db.Text, nullable=False)
    username = db.Column(db.Text, nullable=False)
    url = db.Column(db.Text, nullable=False)

Rating Page (Eshaan)



## Our Idea Including Support for Individuals (Routes, Blueprints etc.)
- We aim for a simple and clean site that contains everything about kpop and music in general. On the site you’ll be able to upload your favorite songs, and explore other people's musical interests.
- The site will contain blueprints and seperate routes that will directly lead to each of our individual work.
- Here is one such example:
![image](https://user-images.githubusercontent.com/72889453/112710377-dfb26a00-8e7d-11eb-8df4-5c0594f5edeb.png)