grooveondemand/groove/shell/load.py

29 lines
671 B
Python
Raw Normal View History

2022-11-30 00:09:23 -08:00
from .base import BasePrompt
from slugify import slugify
from groove.playlist import Playlist
2022-12-02 00:21:19 -08:00
class load(BasePrompt):
2022-11-30 00:09:23 -08:00
"""Create a new playlist."""
@property
def usage(self):
2022-12-02 00:21:19 -08:00
return "load PLAYLIST_NAME"
2022-11-30 00:09:23 -08:00
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,
2022-12-02 00:21:19 -08:00
create_ok=True
2022-11-30 00:09:23 -08:00
)
2022-12-07 18:19:38 -08:00
print(self.parent.playlist.info)
2022-11-30 00:09:23 -08:00
return self.parent.commands['_playlist'].start()