Mixonomer/music/tasks/create_playlist.py

27 lines
666 B
Python

from google.cloud import firestore
import logging
import music.db.database as database
from spotframework.net.network import SpotifyNetworkException
db = firestore.Client()
logger = logging.getLogger(__name__)
def create_playlist(user, name):
if user is None:
logger.error(f'username not provided')
return
logger.info(f'creating spotify playlist for {user.username} / {name}')
net = database.get_authed_spotify_network(user)
try:
return net.create_playlist(net.user.user.display_name, name)
except SpotifyNetworkException as e:
logger.error(f'error ocurred {user.username} / {name} - {e}')
return