Skip to content

Commit

Permalink
fixed popup flow, disabled internal cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ztripez von Matérn committed Jan 16, 2025
1 parent 892a1f1 commit d800ccf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 4 additions & 3 deletions music_assistant/providers/audible/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import asyncio
import os
import webbrowser
from collections.abc import AsyncGenerator
from logging import getLevelName
from typing import TYPE_CHECKING, cast
Expand All @@ -17,7 +16,7 @@
ConfigValueType,
ProviderConfig,
)
from music_assistant_models.enums import ConfigEntryType, MediaType, ProviderFeature
from music_assistant_models.enums import ConfigEntryType, EventType, MediaType, ProviderFeature
from music_assistant_models.errors import LoginFailed

from music_assistant.models.music_provider import MusicProvider
Expand Down Expand Up @@ -111,7 +110,9 @@ async def get_config_entries(
values[CONF_CODE_VERIFIER] = code_verifier
values[CONF_SERIAL] = serial
values[CONF_LOGIN_URL] = login_url
webbrowser.open_new_tab(login_url)
session_id = str(values["session_id"])
mass.signal_event(EventType.AUTH_SESSION, session_id, login_url)
await asyncio.sleep(15)

if action == CONF_ACTION_VERIFY:
code_verifier = str(values.get(CONF_CODE_VERIFIER))
Expand Down
11 changes: 7 additions & 4 deletions music_assistant/providers/audible/audible_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ async def get_library(self) -> AsyncGenerator[Audiobook, None]:
while True:
library = await self._call_api(
"library",
use_cache=False,
response_groups=",".join(response_groups),
page=page,
num_results=page_size,
Expand Down Expand Up @@ -204,13 +205,15 @@ async def set_last_position(self, asin: str, pos: int) -> Any:
"""Report last position."""

async def _call_api(self, path: str, **kwargs: Any) -> Any:
response = None
use_cache = False
params_str = json.dumps(kwargs, sort_keys=True)
params_hash = hashlib.md5(params_str.encode()).hexdigest()
cache_key_with_params = f"{path}:{params_hash}"

response = await self.mass.cache.get(
key=cache_key_with_params, base_key=CACHE_DOMAIN, category=CACHE_CATEGORY_API
)
if use_cache:
response = await self.mass.cache.get(
key=cache_key_with_params, base_key=CACHE_DOMAIN, category=CACHE_CATEGORY_API
)
if not response:
response = await self.client.get(path, **kwargs)
await self.mass.cache.set(
Expand Down

0 comments on commit d800ccf

Please sign in to comment.