mirror of
https://github.com/jarulsamy/Plex-Bot.git
synced 2024-08-19 15:01:55 +02:00
Compare commits
20 Commits
dev
...
19360e3101
Author | SHA1 | Date | |
---|---|---|---|
19360e3101 | |||
52099fa794 | |||
139ce07d24 | |||
5f9c83b75e | |||
f8e5af87b6 | |||
a45ccb657e | |||
bcbce98d91 | |||
6521e7e26c | |||
add1a1af0d | |||
8f05f5e27f | |||
eeb430c016 | |||
1ffa5a7229 | |||
f4cd675502 | |||
921dfc02b8 | |||
9fb091e9e1 | |||
efdd604d65 | |||
7d6060ed15 | |||
d6f5174d20 | |||
151f650bb2 | |||
57490cdf17 |
@ -1,8 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
Plex music bot for discord.
|
Plex music bot for discord.
|
||||||
|
|
||||||
Do not import this module, it is intended to be
|
|
||||||
used exclusively within a docker environment.
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
@ -19,7 +17,7 @@ plex_log = logging.getLogger("Plex")
|
|||||||
bot_log = logging.getLogger("Bot")
|
bot_log = logging.getLogger("Bot")
|
||||||
|
|
||||||
|
|
||||||
def load_config(filename: str) -> Dict[str, str]:
|
def load_config(basedir: str,filename: str) -> Dict[str, str]:
|
||||||
"""Loads config from yaml file
|
"""Loads config from yaml file
|
||||||
|
|
||||||
Grabs key/value config pairs from a file.
|
Grabs key/value config pairs from a file.
|
||||||
@ -35,12 +33,12 @@ def load_config(filename: str) -> Dict[str, str]:
|
|||||||
"""
|
"""
|
||||||
# All config files should be in /config
|
# All config files should be in /config
|
||||||
# for docker deployment.
|
# for docker deployment.
|
||||||
filename = Path("/config", filename)
|
filename = Path(basedir, filename)
|
||||||
try:
|
try:
|
||||||
with open(filename, "r") as config_file:
|
with open(filename, "r") as config_file:
|
||||||
config = yaml.safe_load(config_file)
|
config = yaml.safe_load(config_file)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
root_log.fatal("Configuration file not found.")
|
root_log.fatal("Configuration file not found at '"+str(filename)+"'.")
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# Convert str level type to logging constant
|
# Convert str level type to logging constant
|
||||||
@ -56,7 +54,7 @@ def load_config(filename: str) -> Dict[str, str]:
|
|||||||
config["plex"]["log_level"] = levels[config["plex"]["log_level"].upper()]
|
config["plex"]["log_level"] = levels[config["plex"]["log_level"].upper()]
|
||||||
config["discord"]["log_level"] = levels[config["discord"]["log_level"].upper()]
|
config["discord"]["log_level"] = levels[config["discord"]["log_level"].upper()]
|
||||||
|
|
||||||
if config["lyrics"]["token"].lower() == "none":
|
if config["lyrics"] and config["lyrics"]["token"].lower() == "none":
|
||||||
config["lyrics"]["token"] = None
|
config["lyrics"] = None
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
@ -11,7 +11,11 @@ from .bot import General
|
|||||||
from .bot import Plex
|
from .bot import Plex
|
||||||
|
|
||||||
# Load config from file
|
# Load config from file
|
||||||
config = load_config("config.yaml")
|
configdir = "config"
|
||||||
|
from os import geteuid
|
||||||
|
if geteuid() == 0:
|
||||||
|
configdir = "/config"
|
||||||
|
config = load_config(configdir,"config.yaml")
|
||||||
|
|
||||||
BOT_PREFIX = config["discord"]["prefix"]
|
BOT_PREFIX = config["discord"]["prefix"]
|
||||||
TOKEN = config["discord"]["token"]
|
TOKEN = config["discord"]["token"]
|
||||||
@ -20,8 +24,11 @@ BASE_URL = config["plex"]["base_url"]
|
|||||||
PLEX_TOKEN = config["plex"]["token"]
|
PLEX_TOKEN = config["plex"]["token"]
|
||||||
LIBRARY_NAME = config["plex"]["library_name"]
|
LIBRARY_NAME = config["plex"]["library_name"]
|
||||||
|
|
||||||
LYRICS_TOKEN = config["lyrics"]["token"]
|
if config["lyrics"]:
|
||||||
|
LYRICS_TOKEN = config["lyrics"]["token"]
|
||||||
|
else:
|
||||||
|
LYRICS_TOKEN = None
|
||||||
|
|
||||||
# Set appropiate log level
|
# Set appropiate log level
|
||||||
root_log = logging.getLogger()
|
root_log = logging.getLogger()
|
||||||
plex_log = logging.getLogger("Plex")
|
plex_log = logging.getLogger("Plex")
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"""Track version number of package."""
|
"""Track version number of package."""
|
||||||
VERSION = "1.0.2"
|
VERSION = "1.0.3"
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print(VERSION)
|
print(VERSION)
|
||||||
|
226
PlexBot/bot.py
226
PlexBot/bot.py
@ -3,14 +3,15 @@ import asyncio
|
|||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
import requests
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
import lyricsgenius
|
|
||||||
from async_timeout import timeout
|
from async_timeout import timeout
|
||||||
from discord import FFmpegPCMAudio
|
from discord import FFmpegPCMAudio
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.ext.commands import command
|
from discord.ext.commands import command
|
||||||
from plexapi.exceptions import Unauthorized
|
from plexapi.exceptions import Unauthorized
|
||||||
|
from plexapi.exceptions import NotFound
|
||||||
from plexapi.server import PlexServer
|
from plexapi.server import PlexServer
|
||||||
|
|
||||||
from .exceptions import MediaNotFoundError
|
from .exceptions import MediaNotFoundError
|
||||||
@ -29,11 +30,14 @@ General:
|
|||||||
Plex:
|
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.
|
||||||
|
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.
|
||||||
pause - Pause playback.
|
pause - Pause playback.
|
||||||
resume - Resume playback.
|
resume - Resume playback.
|
||||||
|
skip - Skip the current song.
|
||||||
clear - Clear play queue.
|
clear - Clear play queue.
|
||||||
|
|
||||||
[] - Optional args.
|
[] - Optional args.
|
||||||
@ -41,13 +45,15 @@ Plex:
|
|||||||
|
|
||||||
|
|
||||||
class General(commands.Cog):
|
class General(commands.Cog):
|
||||||
"""General commands
|
"""
|
||||||
|
General commands
|
||||||
|
|
||||||
Manage general bot behavior
|
Manage general bot behavior
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
"""Initialize commands
|
"""
|
||||||
|
Initialize commands
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
bot: discord.ext.command.Bot, bind for cogs
|
bot: discord.ext.command.Bot, bind for cogs
|
||||||
@ -62,7 +68,8 @@ class General(commands.Cog):
|
|||||||
|
|
||||||
@command()
|
@command()
|
||||||
async def kill(self, ctx, *args):
|
async def kill(self, ctx, *args):
|
||||||
"""Kill the bot
|
"""
|
||||||
|
Kill the bot
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
ctx: discord.ext.commands.Context message context from command
|
ctx: discord.ext.commands.Context message context from command
|
||||||
@ -82,7 +89,8 @@ class General(commands.Cog):
|
|||||||
|
|
||||||
@command(name="help")
|
@command(name="help")
|
||||||
async def help(self, ctx):
|
async def help(self, ctx):
|
||||||
"""Prints command help
|
"""
|
||||||
|
Prints command help
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
ctx: discord.ext.commands.Context message context from command
|
ctx: discord.ext.commands.Context message context from command
|
||||||
@ -98,7 +106,8 @@ class General(commands.Cog):
|
|||||||
|
|
||||||
@command()
|
@command()
|
||||||
async def cleanup(self, ctx, limit=250):
|
async def cleanup(self, ctx, limit=250):
|
||||||
"""Delete old messages from bot
|
"""
|
||||||
|
Delete old messages from bot
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
ctx: discord.ext.commands.Context message context from command
|
ctx: discord.ext.commands.Context message context from command
|
||||||
@ -148,7 +157,8 @@ class Plex(commands.Cog):
|
|||||||
# within the bot.
|
# within the bot.
|
||||||
|
|
||||||
def __init__(self, bot, **kwargs):
|
def __init__(self, bot, **kwargs):
|
||||||
"""Initializes Plex resources
|
"""
|
||||||
|
Initializes Plex resources
|
||||||
|
|
||||||
Connects to Plex library and sets up
|
Connects to Plex library and sets up
|
||||||
all asyncronous communications.
|
all asyncronous communications.
|
||||||
@ -173,6 +183,7 @@ class Plex(commands.Cog):
|
|||||||
self.bot_prefix = bot.command_prefix
|
self.bot_prefix = bot.command_prefix
|
||||||
|
|
||||||
if kwargs["lyrics_token"]:
|
if kwargs["lyrics_token"]:
|
||||||
|
import lyricsgenius
|
||||||
self.genius = lyricsgenius.Genius(kwargs["lyrics_token"])
|
self.genius = lyricsgenius.Genius(kwargs["lyrics_token"])
|
||||||
else:
|
else:
|
||||||
plex_log.warning("No lyrics token specified, lyrics disabled")
|
plex_log.warning("No lyrics token specified, lyrics disabled")
|
||||||
@ -202,7 +213,8 @@ class Plex(commands.Cog):
|
|||||||
self.bot.loop.create_task(self._audio_player_task())
|
self.bot.loop.create_task(self._audio_player_task())
|
||||||
|
|
||||||
def _search_tracks(self, title: str):
|
def _search_tracks(self, title: str):
|
||||||
"""Search the Plex music db for track
|
"""
|
||||||
|
Search the Plex music db for track
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
title: str title of song to search for
|
title: str title of song to search for
|
||||||
@ -220,7 +232,8 @@ class Plex(commands.Cog):
|
|||||||
raise MediaNotFoundError("Track cannot be found")
|
raise MediaNotFoundError("Track cannot be found")
|
||||||
|
|
||||||
def _search_albums(self, title: str):
|
def _search_albums(self, title: str):
|
||||||
"""Search the Plex music db for album
|
"""
|
||||||
|
Search the Plex music db for album
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
title: str title of album to search for
|
title: str title of album to search for
|
||||||
@ -237,8 +250,36 @@ class Plex(commands.Cog):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
raise MediaNotFoundError("Album cannot be found")
|
raise MediaNotFoundError("Album cannot be found")
|
||||||
|
|
||||||
|
def _search_playlists(self, title: str):
|
||||||
|
"""
|
||||||
|
Search the Plex music db for playlist
|
||||||
|
|
||||||
|
Args:
|
||||||
|
title: str title of playlist to search for
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
plexapi.playlist pointing to best matching title
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
MediaNotFoundError: Title of playlist can't be found in plex db
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
return self.pms.playlist(title)
|
||||||
|
except NotFound:
|
||||||
|
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
|
||||||
|
|
||||||
Grabs the appropiate streaming URL, sends the `now playing`
|
Grabs the appropiate streaming URL, sends the `now playing`
|
||||||
message, and initiates playback in the vc.
|
message, and initiates playback in the vc.
|
||||||
@ -266,7 +307,8 @@ class Plex(commands.Cog):
|
|||||||
self.np_message_id = await self.ctx.send(embed=embed, file=img)
|
self.np_message_id = await self.ctx.send(embed=embed, file=img)
|
||||||
|
|
||||||
async def _audio_player_task(self):
|
async def _audio_player_task(self):
|
||||||
"""Coroutine to handle playback and queuing
|
"""
|
||||||
|
Coroutine to handle playback and queuing
|
||||||
|
|
||||||
Always-running function awaiting new songs to be added.
|
Always-running function awaiting new songs to be added.
|
||||||
Auto disconnects from VC if idle for > 15 seconds.
|
Auto disconnects from VC if idle for > 15 seconds.
|
||||||
@ -300,7 +342,8 @@ class Plex(commands.Cog):
|
|||||||
await self.np_message_id.delete()
|
await self.np_message_id.delete()
|
||||||
|
|
||||||
def _toggle_next(self, error=None):
|
def _toggle_next(self, error=None):
|
||||||
"""Callback for vc playback
|
"""
|
||||||
|
Callback for vc playback
|
||||||
|
|
||||||
Clears current track, then activates _audio_player_task
|
Clears current track, then activates _audio_player_task
|
||||||
to play next in queue or disconnect.
|
to play next in queue or disconnect.
|
||||||
@ -319,7 +362,8 @@ class Plex(commands.Cog):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _build_embed_track(track, type_="play"):
|
def _build_embed_track(track, type_="play"):
|
||||||
"""Creates a pretty embed card for tracks
|
"""
|
||||||
|
Creates a pretty embed card for tracks
|
||||||
|
|
||||||
Builds a helpful status embed with the following info:
|
Builds a helpful status embed with the following info:
|
||||||
Status, song title, album, artist and album art. All
|
Status, song title, album, artist and album art. All
|
||||||
@ -337,7 +381,7 @@ class Plex(commands.Cog):
|
|||||||
ValueError: Unsupported type of embed {type_}
|
ValueError: Unsupported type of embed {type_}
|
||||||
"""
|
"""
|
||||||
# Grab the relevant thumbnail
|
# Grab the relevant thumbnail
|
||||||
img_stream = urlopen(track.thumbUrl)
|
img_stream = requests.get(track.thumbUrl, stream=True).raw
|
||||||
img = io.BytesIO(img_stream.read())
|
img = io.BytesIO(img_stream.read())
|
||||||
|
|
||||||
# Attach to discord embed
|
# Attach to discord embed
|
||||||
@ -367,7 +411,8 @@ class Plex(commands.Cog):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _build_embed_album(album):
|
def _build_embed_album(album):
|
||||||
"""Creates a pretty embed card for albums
|
"""
|
||||||
|
Creates a pretty embed card for albums
|
||||||
|
|
||||||
Builds a helpful status embed with the following info:
|
Builds a helpful status embed with the following info:
|
||||||
album, artist, and album art. All pertitent information
|
album, artist, and album art. All pertitent information
|
||||||
@ -384,7 +429,7 @@ class Plex(commands.Cog):
|
|||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
# Grab the relevant thumbnail
|
# Grab the relevant thumbnail
|
||||||
img_stream = urlopen(album.thumbUrl)
|
img_stream = requests.get(album.thumbUrl, stream=True).raw
|
||||||
img = io.BytesIO(img_stream.read())
|
img = io.BytesIO(img_stream.read())
|
||||||
|
|
||||||
# Attach to discord embed
|
# Attach to discord embed
|
||||||
@ -401,8 +446,47 @@ class Plex(commands.Cog):
|
|||||||
|
|
||||||
return embed, art_file
|
return embed, art_file
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _build_embed_playlist(self, playlist, title, descrip):
|
||||||
|
"""
|
||||||
|
Creates a pretty embed card for playlists
|
||||||
|
|
||||||
|
Builds a helpful status embed with the following info:
|
||||||
|
playlist art. All pertitent information
|
||||||
|
is grabbed dynamically from the Plex db.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
playlist: plexapi.playlist object of playlist
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
embed: discord.embed fully constructed payload.
|
||||||
|
thumb_art: io.BytesIO of playlist thumbnail img.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
None
|
||||||
|
"""
|
||||||
|
# Grab the relevant thumbnail
|
||||||
|
try:
|
||||||
|
img_stream = requests.get(self.pms.url(playlist.composite, True), stream=True).raw
|
||||||
|
img = io.BytesIO(img_stream.read())
|
||||||
|
except:
|
||||||
|
raise MediaNotFoundError("no image available")
|
||||||
|
|
||||||
|
# Attach to discord embed
|
||||||
|
art_file = discord.File(img, filename="image0.png")
|
||||||
|
|
||||||
|
embed = discord.Embed(
|
||||||
|
title=title, description=descrip, colour=discord.Color.red()
|
||||||
|
)
|
||||||
|
embed.set_author(name="Plex")
|
||||||
|
embed.set_thumbnail(url="attachment://image0.png")
|
||||||
|
bot_log.debug("Built embed for playlist - %s", playlist.title)
|
||||||
|
|
||||||
|
return embed, art_file
|
||||||
|
|
||||||
async def _validate(self, ctx):
|
async def _validate(self, ctx):
|
||||||
"""Ensures user is in a vc
|
"""
|
||||||
|
Ensures user is in a vc
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
ctx: discord.ext.commands.Context message context from command
|
ctx: discord.ext.commands.Context message context from command
|
||||||
@ -426,7 +510,8 @@ class Plex(commands.Cog):
|
|||||||
|
|
||||||
@command()
|
@command()
|
||||||
async def play(self, ctx, *args):
|
async def play(self, ctx, *args):
|
||||||
"""User command to play song
|
"""
|
||||||
|
User command to play song
|
||||||
|
|
||||||
Searchs plex db and either, initiates playback, or
|
Searchs plex db and either, initiates playback, or
|
||||||
adds to queue. Handles invalid usage from the user.
|
adds to queue. Handles invalid usage from the user.
|
||||||
@ -468,7 +553,8 @@ class Plex(commands.Cog):
|
|||||||
|
|
||||||
@command()
|
@command()
|
||||||
async def album(self, ctx, *args):
|
async def album(self, ctx, *args):
|
||||||
"""User command to play song
|
"""
|
||||||
|
User command to play song
|
||||||
|
|
||||||
Searchs plex db and either, initiates playback, or
|
Searchs plex db and either, initiates playback, or
|
||||||
adds to queue. Handles invalid usage from the user.
|
adds to queue. Handles invalid usage from the user.
|
||||||
@ -506,9 +592,91 @@ class Plex(commands.Cog):
|
|||||||
for track in album.tracks():
|
for track in album.tracks():
|
||||||
await self.play_queue.put(track)
|
await self.play_queue.put(track)
|
||||||
|
|
||||||
|
@command()
|
||||||
|
async def playlist(self, ctx, *args):
|
||||||
|
"""
|
||||||
|
User command to play playlist
|
||||||
|
|
||||||
|
Searchs plex db and either, initiates playback, or
|
||||||
|
adds to queue. Handles invalid usage from the user.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
ctx: discord.ext.commands.Context message context from command
|
||||||
|
*args: Title of playlist to play
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
None
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
None
|
||||||
|
"""
|
||||||
|
# Save the context to use with async callbacks
|
||||||
|
self.ctx = ctx
|
||||||
|
title = " ".join(args)
|
||||||
|
|
||||||
|
try:
|
||||||
|
playlist = self._search_playlists(title)
|
||||||
|
except MediaNotFoundError:
|
||||||
|
await ctx.send(f"Can't find playlist: {title}")
|
||||||
|
bot_log.debug("Failed to queue playlist, can't find - %s", title)
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
await self._validate(ctx)
|
||||||
|
except VoiceChannelError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
embed, img = self._build_embed_playlist(self, playlist, "Added playlist to queue", playlist.title)
|
||||||
|
await ctx.send(embed=embed, file=img)
|
||||||
|
|
||||||
|
for item in playlist.items():
|
||||||
|
if (item.TYPE == "track"):
|
||||||
|
await self.play_queue.put(item)
|
||||||
|
bot_log.debug("Added to queue - %s", title)
|
||||||
|
except MediaNotFoundError:
|
||||||
|
await ctx.send(message="Playlist "+title+" seems to be empty!")
|
||||||
|
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):
|
||||||
"""User command to stop playback
|
"""
|
||||||
|
User command to stop playback
|
||||||
|
|
||||||
Stops playback and disconnects from vc.
|
Stops playback and disconnects from vc.
|
||||||
|
|
||||||
@ -531,7 +699,8 @@ class Plex(commands.Cog):
|
|||||||
|
|
||||||
@command()
|
@command()
|
||||||
async def pause(self, ctx):
|
async def pause(self, ctx):
|
||||||
"""User command to pause playback
|
"""
|
||||||
|
User command to pause playback
|
||||||
|
|
||||||
Pauses playback, but doesn't reset anything
|
Pauses playback, but doesn't reset anything
|
||||||
to allow playback resuming.
|
to allow playback resuming.
|
||||||
@ -552,7 +721,8 @@ class Plex(commands.Cog):
|
|||||||
|
|
||||||
@command()
|
@command()
|
||||||
async def resume(self, ctx):
|
async def resume(self, ctx):
|
||||||
"""User command to resume playback
|
"""
|
||||||
|
User command to resume playback
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
ctx: discord.ext.commands.Context message context from command
|
ctx: discord.ext.commands.Context message context from command
|
||||||
@ -570,7 +740,8 @@ class Plex(commands.Cog):
|
|||||||
|
|
||||||
@command()
|
@command()
|
||||||
async def skip(self, ctx):
|
async def skip(self, ctx):
|
||||||
"""User command to skip song in queue
|
"""
|
||||||
|
User command to skip song in queue
|
||||||
|
|
||||||
Skips currently playing song. If no other songs in
|
Skips currently playing song. If no other songs in
|
||||||
queue, stops playback, otherwise moves to next song.
|
queue, stops playback, otherwise moves to next song.
|
||||||
@ -592,7 +763,8 @@ class Plex(commands.Cog):
|
|||||||
|
|
||||||
@command(name="np")
|
@command(name="np")
|
||||||
async def now_playing(self, ctx):
|
async def now_playing(self, ctx):
|
||||||
"""User command to get currently playing song.
|
"""
|
||||||
|
User command to get currently playing song.
|
||||||
|
|
||||||
Deletes old `now playing` status message,
|
Deletes old `now playing` status message,
|
||||||
Creates a new one with up to date information.
|
Creates a new one with up to date information.
|
||||||
@ -618,7 +790,8 @@ class Plex(commands.Cog):
|
|||||||
|
|
||||||
@command()
|
@command()
|
||||||
async def clear(self, ctx):
|
async def clear(self, ctx):
|
||||||
"""User command to clear play queue.
|
"""
|
||||||
|
User command to clear play queue.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
ctx: discord.ext.commands.Context message context from command
|
ctx: discord.ext.commands.Context message context from command
|
||||||
@ -635,7 +808,8 @@ class Plex(commands.Cog):
|
|||||||
|
|
||||||
@command()
|
@command()
|
||||||
async def lyrics(self, ctx):
|
async def lyrics(self, ctx):
|
||||||
"""User command to get lyrics of a song.
|
"""
|
||||||
|
User command to get lyrics of a song.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
ctx: discord.ext.commands.Context message context from command
|
ctx: discord.ext.commands.Context message context from command
|
||||||
|
@ -63,6 +63,9 @@ Plex-Bot runs entirely in a Docker container. Ensure you have Docker and docker-
|
|||||||
token: "<PLEX_TOKEN>"
|
token: "<PLEX_TOKEN>"
|
||||||
library_name: "<LIBRARY_NAME>"
|
library_name: "<LIBRARY_NAME>"
|
||||||
log_level: "debug"
|
log_level: "debug"
|
||||||
|
|
||||||
|
lyrics:
|
||||||
|
token: "none" # Add your token here if you enable lyrics
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Create a Discord bot application:
|
4. Create a Discord bot application:
|
||||||
@ -91,8 +94,6 @@ Plex-Bot runs entirely in a Docker container. Ensure you have Docker and docker-
|
|||||||
|
|
||||||
6. Get your Lyrics Genius token (Optional):
|
6. Get your Lyrics Genius token (Optional):
|
||||||
|
|
||||||
If you wanty to disable this feature, set token to `None` in `config/config.yaml`
|
|
||||||
|
|
||||||
If you would like to enable the lyrics feature of the bot, you need to signup for a free GeniusLyrics account, [here](https://genius.com/api-clients).
|
If you would like to enable the lyrics feature of the bot, you need to signup for a free GeniusLyrics account, [here](https://genius.com/api-clients).
|
||||||
|
|
||||||
After you make an account:
|
After you make an account:
|
||||||
@ -103,7 +104,7 @@ Plex-Bot runs entirely in a Docker container. Ensure you have Docker and docker-
|
|||||||
|
|
||||||
3. Set the redirect url to: `http://localhost`
|
3. Set the redirect url to: `http://localhost`
|
||||||
|
|
||||||
4. Copy the **Client Access Token** to `config/config.yaml`
|
4. Copy the **Client Access Token** and replace `None` with your token in `config/config.yaml`
|
||||||
|
|
||||||
7. Customize remaining settings
|
7. Customize remaining settings
|
||||||
|
|
||||||
@ -137,6 +138,7 @@ General:
|
|||||||
Plex:
|
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.
|
||||||
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.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
discord.py==1.3.4
|
discord.py==1.4.1
|
||||||
PlexAPI==4.0.0
|
PlexAPI==4.0.0
|
||||||
fuzzywuzzy==0.18.0
|
fuzzywuzzy==0.18.0
|
||||||
pynacl==1.4.0
|
pynacl==1.4.0
|
||||||
|
Reference in New Issue
Block a user