Some code cleanup before release

This commit is contained in:
cloudwithax 2021-10-28 17:55:48 -04:00
parent 2e0daa4840
commit 10506a1fbe
4 changed files with 15 additions and 16 deletions

View File

@ -1,4 +1,3 @@
from re import S
from typing import Optional
from discord.ext import commands

View File

@ -74,21 +74,20 @@ class Client:
return Track(data)
elif spotify_type == "album":
return Album(data)
else:
tracks = [Track(track["track"]) for track in data["tracks"]["items"]]
next_page_url = data["tracks"]["next"]
# processing a playlist result
tracks = [Track(track["track"]) for track in data["tracks"]["items"]]
next_page_url = data["tracks"]["next"]
while next_page_url is not None:
async with self.session.get(next_page_url, headers=self._bearer_headers) as resp:
if resp.status != 200:
raise SpotifyRequestException(
f"Error while fetching results: {resp.status} {resp.reason}"
)
while next_page_url is not None:
async with self.session.get(next_page_url, headers=self._bearer_headers) as resp:
if resp.status != 200:
raise SpotifyRequestException(
f"Error while fetching results: {resp.status} {resp.reason}"
)
next_data: dict = await resp.json()
next_data: dict = await resp.json()
tracks += [Track(track["track"]) for track in next_data["items"]]
next_page_url = next_data["next"]
tracks += [Track(track["track"]) for track in next_data["items"]]
next_page_url = next_data["next"]
return Playlist(data, tracks)
return Playlist(data, tracks)

View File

@ -4,4 +4,5 @@ class SpotifyRequestException(Exception):
class InvalidSpotifyURL(Exception):
"""An invalid Spotify URL was passed"""
pass

View File

@ -14,7 +14,7 @@ setuptools.setup(
long_description=readme,
long_description_content_type="text/markdown",
include_package_data=True,
install_requires=['discord.py>=1.7.1'],
install_requires=['discord.py>=2.0.0a'],
extra_require=None,
classifiers=[
"Framework :: AsyncIO",