Ejemplo n.º 1
0
def main():
    st = time.time()
    Spotify.main()
    Sp_Analysis.main()
    Sp_Comparable.main()
    Sp_Prep.main()
    print('Script Finished. Total time {} seconds'.format(time.time() - st))
Ejemplo n.º 2
0
def spotifyLabelClick(p1):
    if Spotify().isSpotifyPlaying:
        song = Spotify().currentSong
        l = Genius.getLyrics(song.title, song.artist)
        print(l)
        destroy_window()
        input("\n\n\n\n\tPremi invio per uscire")
    sys.stdout.flush()
Ejemplo n.º 3
0
def get_artist(id):
    existing_albums = request.get_json()
    send_back = Spotify.get_albums_and_songs(artist_id=id,
                                             existing_albums=existing_albums)
    if send_back is None:
        send_back = {'error': "Could not retrieve albums."}
    return jsonify(send_back)
Ejemplo n.º 4
0
def find_spotify():
    title = request.form["title"]
    if len(title) > 0:
        track_detail = Spotify.find_track(title)
        return ML_feature(track_detail)

    else:
        return index(default_track_data)
Ejemplo n.º 5
0
 def __init__(self, settings):
     log.debug("__init__")
     threading.Thread.__init__(self)
     self.stopping = False
     self.settings = settings
     self.spotify = Spotify.Spotify()
     self.spotify.login(settings.get("spotify_user"), settings.get("spotify_pass"))
     self.play_thread = None
     self.pause_thread = None
     self.resume_thread = None
     self.stop_thread = None
Ejemplo n.º 6
0
import Spotify
import pyechonest
import spotipy

print "Welcome to Spoons&Tunes"
print "Spoons&Tunes helps to organize your event, by:"
print "    1) Making a Spotify playlist custom for your hangout based on your personal taste and bands in your area."
print "    2) Finding the perfect food choice for you to order (cater) Food from by using the ordr.in API"
#print "    3) Tweeting to your friends on twitter and letting them know about your hangout!

location = raw_input("Please enter the address of your event:")
#print location
city = raw_input("Now the city please:")
#print city
state = raw_input("State of residence please!")
#print state
zipcode = raw_input("Please enter the zipcode of your event:")
#print zipcode
username = raw_input("Please enter the username for Spotify:")
#print username
playlist = raw_input("Please enter the Playlist name for this event:")
#print playlist
genre = raw_input("What type of music would you want for this event?")
#print genre
numSongs = raw_input("How many songs do you want for this")
#print numSongs

spotLoc = state+" , "+state
Spotify.make_playlist(username, playlist, genre, spotLoc, numSongs)

Ejemplo n.º 7
0
from flask import Flask, render_template, url_for, request, redirect, jsonify
import Spotify
import json

playlist = ""

app = Flask(__name__)

spotify = Spotify.apiTest()


@app.route("/", methods=["POST", "GET"])
@app.route("/home", methods=["POST", "GET"])
def home():

    return render_template("home.html", values=spotify.show_playslits())


@app.route("/add", methods=["POST", "GET"])
def add():

    global playlist

    if playlist == "":
        playlist = request.form["playName"]

    else:

        if request.method == "POST":

            try:
Ejemplo n.º 8
0
import Spotify
#import Food
import sys


location = sys.argv[1]
city = sys.argv[2]
state = sys.argv[3]
zipcode = sys.argv[4]
username = sys.argv[5]
playlistName = sys.argv[6]
genre = sys.argv[7]
numSongs = int(sys.argv[8])

assert numSongs < 100

Spotify.make_playlist(username, playlistName, genre, city + "," + state, numSongs)
#Food.getFood(genre, location, city, state, 3.28)



Ejemplo n.º 9
0
import Spotify as spot
import pandas as pd
from matplotlib import pyplot as plt

sp = spot.user_log_in()
liked_songs = spot.user_liked_songs()
bad_songs = spot.user_playlist_by_name('squarebrush')

features = spot.song_features(liked_songs, target=1)
bad_features = spot.song_features(bad_songs, target=0)
features.extend(bad_features)

data = pd.DataFrame(features)


def plot_pos_neg(data, feature):
    """
    function to plot the positive/negative song values 
    of a certain feature
    features are:
    danceablity, energy, key, loudness, mode, speechiness,
    acousticness, instrumentalness, liveness, valence,
    tempo
    """
    if feature not in list(features[0].keys()):
        print('Cannot plot a feature that is not an audio features')
        return None
    else:
        pos = data[data['target'] == 1][feature]
        neg = data[data['target'] == 0][feature]
Ejemplo n.º 10
0
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#d9d9d9'  # X11 color: 'gray85'

        top.geometry("404x200+775+335")
        top.title("Get Lyrics")
        top.configure(background="#212121")
        top.configure(highlightcolor="black")

        self.btnGo = Button(top)
        self.btnGo.place(relx=0.77, rely=0.25, height=49, width=79)
        self.btnGo.configure(activebackground="#d9d9d9")
        self.btnGo.configure(background="#212121")
        self.btnGo.configure(borderwidth="0")
        self.btnGo.configure(foreground="#ffffff")
        self.btnGo.configure(text='''Vai!''')
        self.btnGo.bind(
            '<Button-1>', lambda e: lyrics_support.btnGoClick(
                e, self.txtTitle, self.txtArtist))

        self.txtArtist = Entry(top)
        self.txtArtist.place(relx=0.1, rely=0.2, height=21, relwidth=0.53)
        self.txtArtist.configure(background="#424242")
        self.txtArtist.configure(borderwidth="0")
        self.txtArtist.configure(font="TkFixedFont")
        self.txtArtist.configure(foreground="#ffffff")
        self.txtArtist.configure(selectbackground="#c4c4c4")

        self.labelArtist = Label(top)
        self.labelArtist.place(relx=0.07, rely=0.05, height=21, width=39)
        self.labelArtist.configure(activebackground="#424242")
        self.labelArtist.configure(activeforeground="white")
        self.labelArtist.configure(activeforeground="#ffffff")
        self.labelArtist.configure(background="#212121")
        self.labelArtist.configure(foreground="#ffffff")
        self.labelArtist.configure(text='''Artist''')

        self.txtTitle = Entry(top)
        self.txtTitle.place(relx=0.1, rely=0.45, height=21, relwidth=0.53)
        self.txtTitle.configure(background="#424242")
        self.txtTitle.configure(borderwidth="0")
        self.txtTitle.configure(font="TkFixedFont")
        self.txtTitle.configure(foreground="#ffffff")
        self.txtTitle.configure(selectbackground="#c4c4c4")

        self.labelTitle = Label(top)
        self.labelTitle.place(relx=0.07, rely=0.35, height=19, width=31)
        self.labelTitle.configure(activebackground="#f9f9f9")
        self.labelTitle.configure(background="#212121")
        self.labelTitle.configure(borderwidth="0")
        self.labelTitle.configure(foreground="#ffffff")
        self.labelTitle.configure(text='''Title''')

        self.labelSpotify = Label(top)
        self.labelSpotify.place(relx=0.02, rely=0.7, height=60, width=379)
        self.labelSpotify.configure(activebackground="#f9f9f9")
        self.labelSpotify.configure(background="#212121")
        self.labelSpotify.configure(foreground="#ffffff")
        self.labelSpotify.bind('<Button-1>',
                               lambda e: lyrics_support.spotifyLabelClick(e))
        if Spotify.Spotify().isSpotifyPlaying:
            s = Spotify.Spotify().currentSong
            output = f"Stai ascoltando:\n{s.title} di {s.artist}.\nClicca qui per avere il testo"
            self.labelSpotify.configure(text=output)
Ejemplo n.º 11
0
import Spotify
#import Food
import sys

location = sys.argv[1]
city = sys.argv[2]
state = sys.argv[3]
zipcode = sys.argv[4]
username = sys.argv[5]
playlistName = sys.argv[6]
genre = sys.argv[7]
numSongs = int(sys.argv[8])

assert numSongs < 100

Spotify.make_playlist(username, playlistName, genre, city + "," + state,
                      numSongs)
#Food.getFood(genre, location, city, state, 3.28)
Ejemplo n.º 12
0
import argparse
from Spotify import *
from WikiData import *

wikidata = WikiData()
spotify = Spotify()


def suggestions(query):
    name = query.title()

    print('Fetching suggestions for: ')
    print(name)

    artists = spotify.search(name)
    return artists
Ejemplo n.º 13
0
import Music
import Spotify
import pyechonest
import spotipy

print "Welcome to Spoons&Tunes"
print "Spoons&Tunes helps to organize your event, by:"
print "    1) Making a Spotify playlist custom for your hangout based on your personal taste and bands in your area."
print "    2) Finding the perfect food choice for you to order (cater) Food from by using the ordr.in API"
#print "    3) Tweeting to your friends on twitter and letting them know about your hangout!

location = raw_input("Please enter the address of your event:")
#print location
city = raw_input("Now the city please:")
#print city
state = raw_input("State of residence please!")
#print state
zipcode = raw_input("Please enter the zipcode of your event:")
#print zipcode
username = raw_input("Please enter the username for Spotify:")
#print username
playlist = raw_input("Please enter the Playlist name for this event:")
#print playlist
genre = raw_input("What type of music would you want for this event?")
#print genre
numSongs = raw_input("How many songs do you want for this")
#print numSongs

spotLoc = state + " , " + state
Spotify.make_playlist(username, playlist, genre, spotLoc, numSongs)
Ejemplo n.º 14
0
import Spotify
import Matching
import MediaMonkey

spotify = Spotify.Spotify()
media_monkey = MediaMonkey.MediaMonkey()


def find_match_for_album(local_album):
    if not local_album.name:
        return None
    search_results = list(
        spotify.search_album(local_album.name + ' ' + local_album.artist))
    if len(search_results) == 0:
        search_results = list(spotify.search_album(local_album.name))
    return Matching.best_match(search_results, [
        Matching.text_matcher(lambda input: input.name, local_album.name, 100),
        Matching.text_matcher(lambda input: input.first_artist,
                              local_album.artist, 50)
    ], 100)


def find_track_matches_for_album_tracks(local_album):
    album = find_match_for_album(local_album)
    if album:
        album_tracks = list(spotify.get_album_tracks(album.spotify_uri))
        for local_track in local_album.tracks:
            if not local_track.spotify_uri:
                best_match = Matching.best_match(album_tracks, [
                    Matching.text_matcher(lambda input: input.name,
                                          local_track.name, 100),
Ejemplo n.º 15
0
import Spotify as spot
from MLClassifier import predictions
from Training import trained_model

disc_weekly_songs = spot.user_playlist_by_name('Discover Weekly')
disc_weekly_features = spot.song_features(disc_weekly_songs)

predictions = predictions(trained_model, disc_weekly_features)

recommended = []
rec_ids = []
for i in range(len(disc_weekly_songs)):
    if predictions[i] >= 0.9:
        recommended.append(disc_weekly_songs[i]['track']['name'])
        rec_ids.append(disc_weekly_songs[i]['track']['id'])

if recommended is not None:
    print('The following songs are recommeneded based on your saved songs:')
    print('\n')
    for song in recommended:
        print(song)
else:
    print('No songs matched your likes by over 80%')

if rec_ids is not None:
    spot.add_tracks(rec_ids, 'Recommended')
Ejemplo n.º 16
0
from Spotify import *
import sys
import string


def doSearch(search_term):
    print(search_term, end='')
    this_result = json.loads(s.trackSearch(search_term))
    success = True
    if this_result['num_results'] == 0:
        success = False
    return this_result, success


s = Spotify()

punct = re.sub('\'', '', string.punctuation)
phrase = ' '.join(sys.argv[1:])
phrase = re.sub('[' + punct + ']', '', phrase)
words = phrase.split(' ')

res = []
i = len(words) - 1
idx_last_added = -1
need_to_pop = False
added_post_word = False
search_term = ''
while i >= 0:
    this_result = []
    # start with the last single word
    search_term = words[i]
Ejemplo n.º 17
0
            except:
                try:
                    with HiddenPrints():
                        return cls.api.search_song(
                            title.split("feat")[0], artist).lyrics
                except:
                    try:
                        with HiddenPrints():
                            return cls.api.search_song(
                                title.split("ft.")[0], artist).lyrics
                    except:
                        pass
        return "Lyrics not found :/"


if __name__ == "__main__":
    import Spotify as sp
    songToFind = sp.Song("", "")
    try:
        args = parser.parse_args()
        if args is not None:
            if args.artist is not None:
                songToFind.artist = args.artist[0]
            if args.title is not None:
                songToFind.title = args.title[0]
        if songToFind.artist == "" and songToFind.title == "":
            songToFind = sp.Spotify().currentSong
    except:
        pass
    print(Genius.getLyrics(songToFind.title, songToFind.artist))