Spotify.py is broken

This commit is contained in:
Bradlee Speice 2021-07-03 20:46:25 -04:00
parent 3e0657724f
commit 2faf0426df
2 changed files with 12 additions and 8 deletions

View File

@ -4,7 +4,7 @@ Find an album using the `spotify_actions` API and echo its contents.
from argparse import ArgumentParser from argparse import ArgumentParser
from asyncio import get_event_loop from asyncio import get_event_loop
from logging import basicConfig, DEBUG from logging import DEBUG, basicConfig
from spotify_actions.echo import echo_album from spotify_actions.echo import echo_album
from spotify_actions.search import search_album from spotify_actions.search import search_album

View File

@ -2,15 +2,15 @@
Utility methods for working with the Spotify API Utility methods for working with the Spotify API
""" """
from asyncio import AbstractEventLoop from asyncio import AbstractEventLoop
from pathlib import Path
from typing import Optional, Awaitable, Dict, Any
from logging import getLogger from logging import getLogger
from pathlib import Path
from typing import Any, Awaitable, Dict, Optional
import yaml import yaml
from aiohttp import TraceConfig, ClientSession, TraceRequestEndParams, TraceResponseChunkReceivedParams from aiohttp import (ClientSession, TraceConfig, TraceRequestEndParams,
TraceResponseChunkReceivedParams)
from spotify import Client, HTTPClient from spotify import Client, HTTPClient
LOGGER = getLogger(__name__) LOGGER = getLogger(__name__)
@ -49,12 +49,14 @@ class UnescapeClient(Client):
_default_http_client = UnescapeHTTPClient _default_http_client = UnescapeHTTPClient
def read_credentials(path: Path, loop: AbstractEventLoop, trace_config: Optional[TraceConfig] = None) -> Client: def read_credentials(
path: Path, loop: AbstractEventLoop, trace_config: Optional[TraceConfig] = None
) -> Client:
"Read credentials from a YAML file and construct a Spotify client" "Read credentials from a YAML file and construct a Spotify client"
if trace_config: if trace_config:
class TracingHTTPClient(UnescapeHTTPClient):
class TracingHTTPClient(UnescapeHTTPClient):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
@ -73,4 +75,6 @@ def read_credentials(path: Path, loop: AbstractEventLoop, trace_config: Optional
with open(path, "r") as credentials_file: with open(path, "r") as credentials_file:
credentials = yaml.safe_load(credentials_file) credentials = yaml.safe_load(credentials_file)
return client_cls(credentials["client_id"], credentials["client_secret"], loop=loop) return client_cls(
credentials["client_id"], credentials["client_secret"], loop=loop
)