mirror of
https://github.com/jarulsamy/Plex-Bot.git
synced 2024-08-19 15:01:55 +02:00
Attempting to fix the Codacy Static Code Analysis issues.
This commit is contained in:
parent
921dfc02b8
commit
f4cd675502
@ -3,6 +3,7 @@ import asyncio
|
|||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
from urllib.request import Request
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
import lyricsgenius
|
import lyricsgenius
|
||||||
@ -240,7 +241,8 @@ class Plex(commands.Cog):
|
|||||||
raise MediaNotFoundError("Album cannot be found")
|
raise MediaNotFoundError("Album cannot be found")
|
||||||
|
|
||||||
def _search_playlists(self, title: str):
|
def _search_playlists(self, title: str):
|
||||||
"""Search the Plex music db for playlist
|
"""
|
||||||
|
Search the Plex music db for playlist
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
title: str title of playlist to search for
|
title: str title of playlist to search for
|
||||||
@ -251,7 +253,6 @@ class Plex(commands.Cog):
|
|||||||
Raises:
|
Raises:
|
||||||
MediaNotFoundError: Title of playlist can't be found in plex db
|
MediaNotFoundError: Title of playlist can't be found in plex db
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return self.pms.playlist(title)
|
return self.pms.playlist(title)
|
||||||
except NotFound:
|
except NotFound:
|
||||||
@ -339,7 +340,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
|
||||||
@ -357,7 +359,8 @@ 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)
|
req = Request(track.thumbUrl)
|
||||||
|
img_stream = urlopen(req)
|
||||||
img = io.BytesIO(img_stream.read())
|
img = io.BytesIO(img_stream.read())
|
||||||
|
|
||||||
# Attach to discord embed
|
# Attach to discord embed
|
||||||
@ -387,7 +390,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
|
||||||
@ -404,7 +408,8 @@ class Plex(commands.Cog):
|
|||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
# Grab the relevant thumbnail
|
# Grab the relevant thumbnail
|
||||||
img_stream = urlopen(album.thumbUrl)
|
req = Request(album.thumbUrl)
|
||||||
|
img_stream = urlopen(req)
|
||||||
img = io.BytesIO(img_stream.read())
|
img = io.BytesIO(img_stream.read())
|
||||||
|
|
||||||
# Attach to discord embed
|
# Attach to discord embed
|
||||||
@ -423,7 +428,8 @@ class Plex(commands.Cog):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _build_embed_playlist(self, playlist):
|
def _build_embed_playlist(self, playlist):
|
||||||
"""Creates a pretty embed card for playlists
|
"""
|
||||||
|
Creates a pretty embed card for playlists
|
||||||
|
|
||||||
Builds a helpful status embed with the following info:
|
Builds a helpful status embed with the following info:
|
||||||
playlist art. All pertitent information
|
playlist art. All pertitent information
|
||||||
@ -440,7 +446,8 @@ class Plex(commands.Cog):
|
|||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
# Grab the relevant thumbnail
|
# Grab the relevant thumbnail
|
||||||
img_stream = urlopen(self.pms.url(playlist.composite, True))
|
req = Request(self.pms.url(playlist.composite, True))
|
||||||
|
img_stream = urlopen(req)
|
||||||
img = io.BytesIO(img_stream.read())
|
img = io.BytesIO(img_stream.read())
|
||||||
|
|
||||||
# Attach to discord embed
|
# Attach to discord embed
|
||||||
|
Loading…
Reference in New Issue
Block a user