grooveondemand/groove/shell/load.py
2022-12-07 18:19:38 -08:00

29 lines
671 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.info)
return self.parent.commands['_playlist'].start()