grooveondemand/groove/shell/load.py
2022-12-02 00:21:19 -08:00

29 lines
674 B
Python

from .base import BasePrompt
from slugify import slugify
from groove.playlist import Playlist
class load(BasePrompt):
"""Create a new playlist."""
@property
def usage(self):
return "load PLAYLIST_NAME"
def process(self, cmd, *parts):
name = ' '.join(parts)
if not name:
print(f"Usage: {self.usage}")
return
slug = slugify(name)
self.parent._playlist = Playlist(
slug=slug,
name=name,
session=self.manager.session,
create_ok=True
)
print(self.parent.playlist.summary)
return self.parent.commands['_playlist'].start()