some small fixes
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Tue, 5 Apr 2022 12:44:52 +0000 (14:44 +0200)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Tue, 5 Apr 2022 12:44:52 +0000 (14:44 +0200)
.pre-commit-config.yaml
music_assistant/controllers/stream.py
music_assistant/helpers/audio.py
music_assistant/providers/spotify/__init__.py
pylintrc
setup.py

index 34a6d198d87c853afdcba276ae72fac8409e5385..7fd5f193303e4d92633f12365cf43b9088caa48d 100644 (file)
@@ -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:
index 5cff6f9f4d817431a7e800fb5ecb7b0a8cbf13a8..832ec8eaf2121cc533a17ddfc96d8b67683e9dcb 100644 (file)
@@ -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
index a908fbdcc32fb8e28d14ffa2728290dc48d4e989..be26e707a10ed0ff068fcff41f632d9aa7201702 100644 (file)
@@ -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
index 1c343f028fa1047b2ecf7012d4fce69169c77f50..47ee29ece3de9d3f48fa1c4006009fe9f13c3a4a 100644 (file)
@@ -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:
index 0b60c4524592e8a987aaaf2c9a2ab1db3ff458a8..ebb70526c282f35dda9ccf8320a313899cfab87a 100644 (file)
--- 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
index 43d739770bf468a9a2c9c75c655c31cda473e07d..90f4a62df40f8cbcb0f570243e8e099b4f61c2a5 100644 (file)
--- 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"