diff --git a/pomice/__init__.py b/pomice/__init__.py index a44d01c..079a737 100644 --- a/pomice/__init__.py +++ b/pomice/__init__.py @@ -11,7 +11,7 @@ if discord.__version__ != "2.0.0a": "using 'pip install git+https://github.com/Rapptz/discord.py@master'" ) -__version__ = "1.1.2" +__version__ = "1.1.3" __title__ = "pomice" __author__ = "cloudwithax" diff --git a/pomice/events.py b/pomice/events.py index 4c3eb98..6aeb45d 100644 --- a/pomice/events.py +++ b/pomice/events.py @@ -101,7 +101,7 @@ class TrackExceptionEvent(PomiceEvent): class WebSocketClosedPayload: def __init__(self, data: dict): - self.guild = NodePool.get_node().get_player(int(data["guildId"]))._guild + self.guild = NodePool.get_node().bot.get_guild(int(data["guildId"])) self.code: int = data["code"] self.reason: str = data["code"] self.by_remote: bool = data["byRemote"] @@ -142,3 +142,4 @@ class WebSocketOpenEvent(PomiceEvent): def __repr__(self) -> str: return f"" + diff --git a/pomice/filters.py b/pomice/filters.py index 83fc350..306cdd2 100644 --- a/pomice/filters.py +++ b/pomice/filters.py @@ -3,6 +3,12 @@ from .exceptions import FilterInvalidArgument class Filter: + """ + The base class for all filters. + You can use these filters if you have the latest Lavalink version + installed. If you do not have the latest Lavalink version, + these filters will not work. + """ def __init__(self): self.payload = None @@ -37,11 +43,9 @@ class Equalizer(Filter): class Timescale(Filter): """Filter which changes the speed and pitch of a track. - Do be warned that this filter is bugged as of the lastest Lavalink dev version - due to the filter patch not corresponding with the track time. - - In short this means that your track will either end prematurely or end later due to this. - This is not the library's fault. + You can make some very nice effects with this filter, + i.e: a vaporwave-esque filter which slows the track down + a certain amount to produce said effect. """ def __init__( diff --git a/pomice/pool.py b/pomice/pool.py index 7680435..5af860e 100644 --- a/pomice/pool.py +++ b/pomice/pool.py @@ -5,14 +5,18 @@ import json import random import re import socket -import time from typing import Dict, Optional, TYPE_CHECKING from urllib.parse import quote import aiohttp from discord.ext import commands -from . import __version__, spotify + +from . import ( + __version__, + spotify, +) + from .enums import SearchType from .exceptions import ( InvalidSpotifyClientAuthorization, @@ -57,6 +61,7 @@ class Node: port: int, password: str, identifier: str, + secure: bool = False, session: Optional[aiohttp.ClientSession], spotify_client_id: Optional[str], spotify_client_secret: Optional[str], @@ -68,8 +73,10 @@ class Node: self._pool = pool self._password = password self._identifier = identifier + self._secure = secure - self._websocket_uri = f"ws://{self._host}:{self._port}" + + self._websocket_uri = f"{'wss' if self._secure else 'ws'}://{self._host}:{self._port}" self._rest_uri = f"http://{self._host}:{self._port}" self._session = session or aiohttp.ClientSession() @@ -258,7 +265,7 @@ class Node: ) as resp: if not resp.status == 200: raise TrackLoadError( - f"Failed to build track. Check the identifier is correct and try again." + f"Failed to build track. Check if the identifier is correct and try again." ) data: dict = await resp.json() @@ -452,6 +459,7 @@ class NodePool: port: str, password: str, identifier: str, + secure: bool = False, spotify_client_id: Optional[str], spotify_client_secret: Optional[str], session: Optional[aiohttp.ClientSession] = None, @@ -465,7 +473,7 @@ class NodePool: node = Node( pool=cls, bot=bot, host=host, port=port, password=password, - identifier=identifier, spotify_client_id=spotify_client_id, + identifier=identifier, secure=secure, spotify_client_id=spotify_client_id, session=session, spotify_client_secret=spotify_client_secret ) diff --git a/pomice/spotify/client.py b/pomice/spotify/client.py index c0b1572..5487168 100644 --- a/pomice/spotify/client.py +++ b/pomice/spotify/client.py @@ -75,10 +75,15 @@ class Client: elif spotify_type == "album": return Album(data) else: + tracks = [ Track(track["track"]) for track in data["tracks"]["items"] if track["track"] is not None ] + + if not len(tracks): + raise SpotifyRequestException("This playlist is empty and therefore cannot be queued.") + next_page_url = data["tracks"]["next"] while next_page_url is not None: diff --git a/pomice/spotify/playlist.py b/pomice/spotify/playlist.py index edff867..05ab92f 100644 --- a/pomice/spotify/playlist.py +++ b/pomice/spotify/playlist.py @@ -11,7 +11,7 @@ class Playlist: self.owner = data["owner"]["display_name"] self.total_tracks = data["tracks"]["total"] self.id = data["id"] - if data.get("images"): + if data.get("images") and len(data["images"]): self.image = data["images"][0]["url"] else: self.image = None diff --git a/setup.py b/setup.py index c4960d4..3586580 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ with open("README.md") as f: setuptools.setup( name="pomice", author="cloudwithax", - version="1.1.2", + version="1.1.3", url="https://github.com/cloudwithax/pomice", packages=setuptools.find_packages(), license="GPL",