Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions music_assistant/providers/ard_audiothek/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from collections.abc import AsyncGenerator, Sequence
from datetime import datetime, timedelta
from datetime import datetime
from typing import TYPE_CHECKING, Any

from gql import Client
Expand Down Expand Up @@ -36,6 +36,7 @@

from music_assistant.constants import CONF_PASSWORD
from music_assistant.controllers.cache import use_cache
from music_assistant.helpers.datetime import from_utc_timestamp, future_timestamp, utc
from music_assistant.models.music_provider import MusicProvider
from music_assistant.providers.ard_audiothek.database_queries import (
get_history_query,
Expand Down Expand Up @@ -248,26 +249,22 @@ async def get_client(self) -> Client:
_password = self.config.get_value(CONF_PASSWORD)
self.token = self.config.get_value(CONF_TOKEN_BEARER)
self.user_id = self.config.get_value(CONF_USERID)
self.token_expire = datetime.fromtimestamp(
float(str(self.config.get_value(CONF_EXPIRY_TIME)))
)
self.token_expire = from_utc_timestamp(float(str(self.config.get_value(CONF_EXPIRY_TIME))))

self.max_bitrate = int(float(str(self.config.get_value(CONF_MAX_BITRATE))))

if (
_email is not None
and _password is not None
and (self.token is None or self.user_id is None or self.token_expire < datetime.now())
and (self.token is None or self.user_id is None or self.token_expire < utc())
):
self.token, self.user_id, _display_name = await _login(
self.mass.http_session, str(_email), str(_password)
)
self._update_config_value(CONF_TOKEN_BEARER, self.token, encrypted=True)
self._update_config_value(CONF_USERID, self.user_id, encrypted=True)
self._update_config_value(CONF_DISPLAY_NAME, _display_name)
self._update_config_value(
CONF_EXPIRY_TIME, str((datetime.now() + timedelta(hours=1)).timestamp())
)
self._update_config_value(CONF_EXPIRY_TIME, str(future_timestamp(hours=1)))
self._client_initialized = False

if not self._client_initialized:
Expand Down
8 changes: 2 additions & 6 deletions music_assistant/providers/deezer/gw_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
cookie based on the api_token.
"""

import datetime
import json
from collections.abc import Mapping
from http.cookies import BaseCookie, Morsel
Expand All @@ -15,7 +14,7 @@
from music_assistant_models.streamdetails import StreamDetails
from yarl import URL

from music_assistant.helpers.datetime import utc_timestamp
from music_assistant.helpers.datetime import future_timestamp, utc_timestamp

USER_AGENT_HEADER = (
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) "
Expand Down Expand Up @@ -89,10 +88,7 @@ async def setup(self) -> None:
await self._update_user_data()

async def _get_license(self) -> str | None:
if (
self._license_expiration_timestamp
< (datetime.datetime.now() + datetime.timedelta(days=1)).timestamp()
):
if self._license_expiration_timestamp < future_timestamp(days=1):
await self._update_user_data()
return self._license

Expand Down
4 changes: 2 additions & 2 deletions music_assistant/providers/phishin/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import annotations

from collections.abc import AsyncGenerator
from datetime import datetime
from typing import TYPE_CHECKING, Any

from music_assistant_models.enums import (
Expand All @@ -30,6 +29,7 @@
from music_assistant_models.unique_list import UniqueList

from music_assistant.controllers.cache import use_cache
from music_assistant.helpers.datetime import now
from music_assistant.models.music_provider import MusicProvider

from .constants import (
Expand Down Expand Up @@ -642,7 +642,7 @@ async def _browse_random(self) -> list[Album]:
async def _browse_today(self) -> list[Album]:
"""Get shows that happened on this day in history."""
try:
today = datetime.now()
today = now()
target_date = today.strftime("%Y-%m-%d")

shows_data = await api_request(
Expand Down
4 changes: 2 additions & 2 deletions music_assistant/providers/spotify_connect/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import json
import os
import urllib.request
from datetime import datetime
from datetime import UTC, datetime

player_event = os.getenv("PLAYER_EVENT")

json_dict = {
"event_time": str(datetime.now()),
"event_time": str(datetime.now(UTC)),
"event": player_event,
}

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ ignore = [
"PYI034",
"G004",
"PGH003",
"DTZ005",
"S104",
"S105",
"S106",
Expand Down
Loading