mirror of
https://github.com/jarulsamy/Plex-Bot.git
synced 2024-08-19 15:01:55 +02:00
added option to show available playlists
This commit is contained in:
parent
139ce07d24
commit
52099fa794
@ -31,6 +31,7 @@ Plex:
|
|||||||
play <SONG_NAME> - Play a song from the plex server.
|
play <SONG_NAME> - Play a song from the plex server.
|
||||||
album <ALBUM_NAME> - Queue an entire album to play.
|
album <ALBUM_NAME> - Queue an entire album to play.
|
||||||
playlist <PLAYLIST_NAME> - Queue an entire playlist to play.
|
playlist <PLAYLIST_NAME> - Queue an entire playlist to play.
|
||||||
|
show_playlists <ARG> <ARG> - Query for playlists with a name matching any of the arguments.
|
||||||
lyrics - Print the lyrics of the song (Requires Genius API)
|
lyrics - Print the lyrics of the song (Requires Genius API)
|
||||||
np - Print the current playing song.
|
np - Print the current playing song.
|
||||||
stop - Halt playback and leave vc.
|
stop - Halt playback and leave vc.
|
||||||
@ -267,6 +268,15 @@ class Plex(commands.Cog):
|
|||||||
except NotFound:
|
except NotFound:
|
||||||
raise MediaNotFoundError("Playlist cannot be found")
|
raise MediaNotFoundError("Playlist cannot be found")
|
||||||
|
|
||||||
|
def _get_playlists(self):
|
||||||
|
"""
|
||||||
|
Search the Plex music db for playlist
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
List of plexapi.playlist
|
||||||
|
"""
|
||||||
|
return self.pms.playlists()
|
||||||
|
|
||||||
async def _play(self):
|
async def _play(self):
|
||||||
"""
|
"""
|
||||||
Heavy lifting of playing songs
|
Heavy lifting of playing songs
|
||||||
@ -627,6 +637,41 @@ class Plex(commands.Cog):
|
|||||||
except MediaNotFoundError:
|
except MediaNotFoundError:
|
||||||
await ctx.send(message="Playlist "+title+" seems to be empty!")
|
await ctx.send(message="Playlist "+title+" seems to be empty!")
|
||||||
bot_log.debug("Playlist empty - %s", title)
|
bot_log.debug("Playlist empty - %s", title)
|
||||||
|
@command()
|
||||||
|
async def show_playlists(self, ctx, *args):
|
||||||
|
"""
|
||||||
|
User command to show playlists
|
||||||
|
|
||||||
|
Searchs plex db and shows playlists matching.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
ctx: discord.ext.commands.Context message context from command
|
||||||
|
*args: String filter for playlist names
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
None
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
None
|
||||||
|
"""
|
||||||
|
# Save the context to use with async callbacks
|
||||||
|
self.ctx = ctx
|
||||||
|
|
||||||
|
playlists = self._get_playlists()
|
||||||
|
|
||||||
|
try:
|
||||||
|
await self._validate(ctx)
|
||||||
|
except VoiceChannelError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
for playlist in playlists:
|
||||||
|
if args and not any(arg in playlist.title for arg in args):
|
||||||
|
continue
|
||||||
|
from datetime import timedelta
|
||||||
|
if playlist.duration:
|
||||||
|
seconds = playlist.duration / 1000
|
||||||
|
embed, img = self._build_embed_playlist(self, playlist, playlist.title, "{:0>8}".format(str(timedelta(seconds=seconds))))
|
||||||
|
await ctx.send(embed=embed, file=img)
|
||||||
|
|
||||||
@command()
|
@command()
|
||||||
async def stop(self, ctx):
|
async def stop(self, ctx):
|
||||||
|
Loading…
Reference in New Issue
Block a user