From 30bcd9e9220a26e582a0499e2d5dfb01befc3404 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Tue, 5 Apr 2022 14:44:52 +0200 Subject: [PATCH] some small fixes --- .pre-commit-config.yaml | 6 ++++++ music_assistant/controllers/stream.py | 4 ---- music_assistant/helpers/audio.py | 13 +++++++++---- music_assistant/providers/spotify/__init__.py | 2 +- pylintrc | 5 ++++- setup.py | 2 +- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 34a6d198..7fd5f193 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,10 @@ repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace - repo: https://github.com/psf/black rev: 22.3.0 hooks: diff --git a/music_assistant/controllers/stream.py b/music_assistant/controllers/stream.py index 5cff6f9f..832ec8ea 100644 --- a/music_assistant/controllers/stream.py +++ b/music_assistant/controllers/stream.py @@ -128,16 +128,13 @@ class StreamController: async def reader(): # task that reads flac endoded chunks from the subprocess - self.logger.debug("start reader task") chunksize = 32000 if output_fmt == ContentType.MP3 else 256000 async for audio_chunk in sox_proc.iterate_chunks(chunksize): await resp.write(audio_chunk) - self.logger.debug("reader task finished") # feed raw pcm chunks into sox/ffmpeg to encode to flac async def audio_callback(audio_chunk): if audio_chunk == b"": - self.logger.debug("last chunk received from stream") sox_proc.write_eof() return await sox_proc.write(audio_chunk) @@ -447,7 +444,6 @@ class StreamController: seconds_per_chunk = buffer_size / sample_size seconds_needed = int(time() - start_timestamp + seconds_per_chunk) if (seconds_streamed) > seconds_needed: - self.logger.debug("cooldown %s seconds", seconds_per_chunk / 2) await asyncio.sleep(seconds_per_chunk / 2) # end of the track reached # update actual duration to the queue for more accurate now playing info diff --git a/music_assistant/helpers/audio.py b/music_assistant/helpers/audio.py index a908fbdc..be26e707 100644 --- a/music_assistant/helpers/audio.py +++ b/music_assistant/helpers/audio.py @@ -12,7 +12,7 @@ from music_assistant.constants import EventType from music_assistant.helpers.process import AsyncProcess, check_output from music_assistant.helpers.typing import MusicAssistant, QueueItem from music_assistant.helpers.util import create_tempfile -from music_assistant.models.errors import AudioError +from music_assistant.models.errors import AudioError, MediaNotFoundError from music_assistant.models.media_items import ( ContentType, MediaType, @@ -195,9 +195,14 @@ async def get_stream_details( ) else: # always request the full db track as there might be other qualities available - full_item = await mass.music.get_item_by_uri( - queue_item.uri, force_refresh=not lazy, lazy=lazy - ) + try: + full_item = await mass.music.get_item_by_uri( + queue_item.uri, force_refresh=not lazy, lazy=lazy + ) + except MediaNotFoundError as err: + LOGGER.warning(str(err)) + return None + if not full_item: return None # sort by quality and check track availability diff --git a/music_assistant/providers/spotify/__init__.py b/music_assistant/providers/spotify/__init__.py index 1c343f02..47ee29ec 100644 --- a/music_assistant/providers/spotify/__init__.py +++ b/music_assistant/providers/spotify/__init__.py @@ -155,7 +155,7 @@ class SpotifyProvider(MusicProvider): async def get_track(self, prov_track_id) -> Track: """Get full track details by id.""" - track_obj = await self._get_data("tracks/{prov_track_id}") + track_obj = await self._get_data(f"tracks/{prov_track_id}") return await self._parse_track(track_obj) if track_obj else None async def get_playlist(self, prov_playlist_id) -> Playlist: diff --git a/pylintrc b/pylintrc index 0b60c452..ebb70526 100644 --- a/pylintrc +++ b/pylintrc @@ -53,6 +53,9 @@ disable= enable= use-symbolic-message-instead +[IMPORTS] +ignored-modules=aiofiles,aiohttp,asyncio_throttle,databases,mashumaro,tinytag + [REPORTS] score=no @@ -66,4 +69,4 @@ max-nested-blocks=15 ignored-classes=_CountingAttr [FORMAT] -expected-line-ending-format=LF \ No newline at end of file +expected-line-ending-format=LF diff --git a/setup.py b/setup.py index 43d73977..90f4a62d 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ from setuptools import find_packages, setup PROJECT_NAME = "Music Assistant" PROJECT_PACKAGE_NAME = "music_assistant" -PROJECT_VERSION = "1.0.5" +PROJECT_VERSION = "1.0.6" PROJECT_REQ_PYTHON_VERSION = "3.9" PROJECT_LICENSE = "Apache License 2.0" PROJECT_AUTHOR = "Marcel van der Veldt" -- 2.34.1