Mixonomer/music/tasks/create_playlist.py
aj e3fd4bb6d5 environment-dependent tag update
error checking
sidebar links
docstrings

closes #13
2020-05-08 15:19:27 +01:00

28 lines
617 B
Python

from google.cloud import firestore
import logging
import music.db.database as database
db = firestore.Client()
logger = logging.getLogger(__name__)
def create_playlist(user, name):
logger.info(f'creating spotify playlist for {user.username} / {name}')
if user is None:
logger.error(f'{user.username} not provided')
return
net = database.get_authed_spotify_network(user)
playlist = net.create_playlist(net.user.username, name)
if playlist is not None:
return playlist
else:
logger.error(f'no response received {user.username} / {name}')
return