Beispiel #1
0
import spotipy
from spotipy.oauth2 import SpotifyOAuth
from spotipy.oauth2 import SpotifyClientCredentials
from config_reader import ConfigReader
from datetimeformatting_class import DateTimeFormatting
import json

#Objects
cfg = ConfigReader('config.cfg')
dtf_obj = DateTimeFormatting()

client_id = cfg.read_client_id_from_config_file()
client_secret = cfg.read_client_secret_from_config_file()
scope = cfg.read_scope_from_config_file()
username = cfg.read_username_from_config_file()


def get_token(client_id, client_secret, scope, username):
    token = spotipy.util.prompt_for_user_token(
        username,
        scope,
        client_id=client_id,
        client_secret=client_secret,
        redirect_uri='http://localhost:8080/callback')
    return token


def get_my_todays_recently_played_songs(today_timestamp):
    todays_history = sp.current_user_recently_played(limit=50,
                                                     after=None,
                                                     before=None)