handling optional access key, added player

This commit is contained in:
aj 2019-09-15 03:34:00 +01:00
parent 435f16b779
commit 0cc962cf0d
3 changed files with 10 additions and 7 deletions

View File

@ -23,8 +23,8 @@ def create_playlist(username, name):
net = Network(NetworkUser(spotify_keys['clientid'], net = Network(NetworkUser(spotify_keys['clientid'],
spotify_keys['clientsecret'], spotify_keys['clientsecret'],
user_dict['access_token'], user_dict['refresh_token'],
user_dict['refresh_token'])) user_dict['access_token']))
resp = net.create_playlist(net.user.username, name) resp = net.create_playlist(net.user.username, name)

View File

@ -10,6 +10,7 @@ from spotframework.engine.processor.deduplicate import DeduplicateByID
from spotframework.net.network import Network from spotframework.net.network import Network
from spotframework.net.user import NetworkUser from spotframework.net.user import NetworkUser
from spotframework.player.player import Player
import spotify.db.database as database import spotify.db.database as database
from spotify.db.part_generator import PartGenerator from spotify.db.part_generator import PartGenerator
@ -55,12 +56,14 @@ def play_user_playlist(username,
net = Network(NetworkUser(spotify_keys['clientid'], net = Network(NetworkUser(spotify_keys['clientid'],
spotify_keys['clientsecret'], spotify_keys['clientsecret'],
user_dict['access_token'], user_dict['refresh_token'],
user_dict['refresh_token'])) user_dict['access_token']))
engine = PlaylistEngine(net) engine = PlaylistEngine(net)
engine.load_user_playlists() engine.load_user_playlists()
player = Player(net)
processors = [DeduplicateByID()] processors = [DeduplicateByID()]
if shuffle: if shuffle:
@ -92,7 +95,7 @@ def play_user_playlist(username,
include_recommendations=include_recommendations, include_recommendations=include_recommendations,
recommendation_limit=int(recommendation_sample)) recommendation_limit=int(recommendation_sample))
net.play(uris=[i.uri for i in tracks]) player.play(tracks=tracks)
else: else:
logger.critical(f'multiple/no user(s) found ({username})') logger.critical(f'multiple/no user(s) found ({username})')

View File

@ -48,8 +48,8 @@ def run_user_playlist(username, playlist_name):
net = Network(NetworkUser(spotify_keys['clientid'], net = Network(NetworkUser(spotify_keys['clientid'],
spotify_keys['clientsecret'], spotify_keys['clientsecret'],
user_dict['access_token'], user_dict['refresh_token'],
user_dict['refresh_token'])) user_dict['access_token']))
engine = PlaylistEngine(net) engine = PlaylistEngine(net)
engine.load_user_playlists() engine.load_user_playlists()