Mixonomer/music/tasks/create_playlist.py

23 lines
598 B
Python
Raw Normal View History

import logging
2019-10-19 17:14:11 +01:00
import music.db.database as database
from spotframework.net.network import SpotifyNetworkException
logger = logging.getLogger(__name__)
2020-04-30 14:54:05 +01:00
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)
2019-08-14 22:57:58 +01:00
try:
return net.create_playlist(net.user.user.display_name, name)
except SpotifyNetworkException:
logger.exception(f'error ocurred {user.username} / {name}')
return