Example #1
0
 def api_theme_song_open_in_browser(self):
     try:
         auth = spotify().auth
         headers = spotify().head
         uri_id = "3dAUz8qeUL6pKf6gp6iemq"
         url = f"https://api.spotify.com/v1/tracks/{uri_id}?market=SE"
         response = requests.get(url=url, headers=headers)  # api response
         response_json = response.json()  # make it json
         theme_song = response_json.get(
             "preview_url")  # get the url of the song
         webbrowser.open_new_tab(
             url=theme_song)  # opens a tab and plays the song
     except Exception as e:
         print("Update the Spotify-API auth!\n spotify.py -> self.auth")
Example #2
0
    def __init__(self):
        """[intialize controller class to run display]

        Arguments:
            username {[string]} -- [username for spotify]
        """
        self.sp = spotify.spotify()
        self.disp = run_display.run_display(self.sp)
        self.playlist = None
        self.logger = logging.getLogger(__name__)
        self.owner = self.sp.user
Example #3
0
    args.config) else default_file_config
config = toml.load(config_file)

# authenticate the user if not already done
authentication.init(config, config_file)
if args.init:
    authentication.launch()
if not args.init and config['spotify']['access_token'] == '':
    raise Exception(
        'No token provided. To generate a token please run the program with the \'--init\' parameter.'
    )

here = os.path.dirname(__file__)
os.chdir(here)

application = spotify.spotify(config=config['spotify'])

# On créer la bdd et on l'initialise (création des tables)
db_manager = dbManager(config['database']['name'])
db_manager.init_db()

# Si on ne connait pas encore l'utilisateur courant alors on récupère son profil
if config['spotify']['user_id'] == '':
    user = application.get_user_profile()
    config['spotify']['user_id'] = user.id
    # On écrit dans le fichier de config l'id de l'utilisateur
    with open(config_file, 'w') as myfile:
        toml.dump(config, myfile)
    # On créé l'user dans la base
    db_manager.insert_values('user', [user])
Example #4
0
import time
import sys
import os
import traceback
import ctypes
from ctypes import wintypes
import win32con
import win32api
import win32gui
import win32process

from spotify import spotify
from sanitizeInput import sanitizer

spotify = spotify()
sanitizer = sanitizer()

lastWindowTitle = ""


def enumWindowsProc(hwnd, lParam):
    global currentWindowTitle
    if (lParam is None) or (
        (lParam is not None) and
        (win32process.GetWindowThreadProcessId(hwnd)[1] == lParam)):
        text = win32gui.GetWindowText(hwnd)
        if text:
            wStyle = win32api.GetWindowLong(hwnd, win32con.GWL_STYLE)
            if wStyle & win32con.WS_VISIBLE:
                currentWindowTitle = text
Example #5
0
def topSongs(option):
    songsWindow = tkinter.Toplevel()
    songsWindow.title("Songs Search Results")
    width, height = songsWindow.winfo_screenwidth(
    ), songsWindow.winfo_screenheight()
    songsWindow.geometry('%dx%d+0+0' % (width, height))

    num = combo.current() + 1
    header2 = ""

    if (daily_weekly == 'daily'):
        if option == "S":
            results = spotify.spotify(num, 'daily')
            header = "Spotify"

        elif option == "L":
            results = lastfm.lastfm(num, 'songs')
            header = "Last.fm"

        elif option == "SL":
            results = spotify.spotify(num, 'daily')
            header = "Spotify"
            results2 = lastfm.lastfm(num, 'songs')
            header2 = "Last.fm"
    elif (daily_weekly == 'weekly'):
        if option == "S":
            results = spotify.spotify(num, 'weekly')
            header = "Spotify"
        elif option == "B":
            results = billb.billb(num, 'songs')
            header = "Billboard"
        elif option == "SB":
            results = spotify.spotify(num, 'weekly')
            header = "Spotify"
            results2 = billb.billb(num, "songs")
            header2 = "Billboard"

    label = tkinter.Label(songsWindow,
                          text=header,
                          font=("Arial Bold Italics", 40),
                          fg="blue").place(x=0, y=0)

    songsList = [None] * (num + 1)
    for i in range(num + 1):
        songsList[i] = ""
    counter = 0
    check = False
    for row in repr(results):
        if (row != "\\" and row != "n" and row != "\""):
            songsList[counter] += row
        elif (row == "\\"):
            check = True
        elif (row == "n" and check == True):
            counter += 1
            check = False
        elif (row == "n" and check == False):
            songsList[counter] += row

    dic = {}
    i = 0
    for i in range(num):
        dic[i] = tkinter.Button(
            songsWindow,
            text=songsList[i],
            font=("Arial Bold Italics", 15),
            bg="blue",
            fg="white",
            command=partial(Links, songsList[i],
                            "songs")).place(x=0,
                                            y=(height / 15) * (i / 1.6 + 1))

    if (option == "SL" or option == "SB"):

        label2 = tkinter.Label(songsWindow,
                               text=header2,
                               font=("Arial Bold Italics", 40),
                               fg="blue").place(x=width / 1.8, y=0)
        songsList2 = [None] * (num + 1)
        for i in range(num + 1):
            songsList2[i] = ""
        counter = 0
        check = False
        for row in repr(results2):
            if (row != "\\" and row != "n" and row != "\""):
                songsList2[counter] += row
            elif (row == "\\"):
                check = True
            elif (row == "n" and check == True):
                counter += 1
                check = False
            elif (row == "n" and check == False):
                songsList2[counter] += row

        dic = {}
        i = 0
        for i in range(num):
            dic[i] = tkinter.Button(songsWindow,
                                    text=songsList2[i],
                                    font=("Arial Bold Italics", 15),
                                    bg="blue",
                                    fg="white",
                                    command=partial(
                                        Links, songsList2[i], "songs")).place(
                                            x=width / 1.8,
                                            y=(height / 15) * (i / 1.6 + 1))

    backButton = tkinter.Button(songsWindow,
                                text="Go Back",
                                font=("Arial Bold Italics", 40),
                                bg="blue",
                                fg="white",
                                command=songsWindow.destroy).place(
                                    x=width / 2.4, y=height / 1.2)
Example #6
0
import deezer
import re
from spotify import spotify

deezerClient = deezer.Client()
spotifyClient = spotify()
importFails = []

#search for public stuffs

playlists = {
    "Showgun": 7300472344,
    "Showgun II": 7300772364,
    "Showgun III": 7300796284,
    "Showgun IV": 7300846084,
    "Showgun V": 7369522804
}

for playlistName in playlists:
    playlistId = playlists[playlistName]
    rockPlaylistName = "🤘- %s" % playlistName
    # Check if playlist exists in spotify
    spotifyPlaylist = spotifyClient.exactSearchPlaylist(rockPlaylistName)
    if not spotifyPlaylist:
        print("/!\ - %s does not exist do create it" % rockPlaylistName)
        spotifyPlaylist = spotifyClient.createPlaylist(rockPlaylistName)

    print(spotifyPlaylist)

    deezerPlaylist = deezerClient.get_playlist(playlistId)
Example #7
0
 def __init__(self, master = None):
     super().__init__(master)
     self.master = master
     self.pack()
     self.create_widgets()
     self.spot = spotify()