Small fixes (#417)
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Thu, 14 Jul 2022 22:01:10 +0000 (00:01 +0200)
committerGitHub <noreply@github.com>
Thu, 14 Jul 2022 22:01:10 +0000 (00:01 +0200)
* no cover image for local HA files

* optimize image thumbs

* Fix audio preview

* contentFeatures DLNA header

music_assistant/controllers/streams.py
music_assistant/helpers/audio.py
music_assistant/helpers/images.py
music_assistant/music_providers/url.py

index 77fd25838314e29684ebfa556498930c410732db..7f235e13a49e68b6006f413a9982068a9d710f95 100644 (file)
@@ -188,6 +188,7 @@ class StreamsController:
         headers = {
             "Content-Type": f"audio/{queue_stream.output_format.value}",
             "transferMode.dlna.org": "Streaming",
+            "contentFeatures.dlna.org": "DLNA.ORG_OP=00;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=0d500000000000000000000000000000",
             "Cache-Control": "no-cache",
         }
 
index 23abd6419870d059aab7c7d5e2aec1c5b0b5fd17..b913c46103fe6a69ce1d7373e954fa7df9fb3f51 100644 (file)
@@ -567,11 +567,16 @@ async def get_preview_stream(
         "-hide_banner",
         "-loglevel",
         "quiet",
-        "-f",
-        streamdetails.content_type.value,
-        "-i",
-        "-",
+        "-ignore_unknown",
     ]
+    if streamdetails.direct:
+        input_args += ["-ss", "30", "-i", streamdetails.direct]
+    else:
+        # the input is received from pipe/stdin
+        if streamdetails.content_type != ContentType.UNKNOWN:
+            input_args += ["-f", streamdetails.content_type.value]
+        input_args += ["-i", "-"]
+
     output_args = ["-to", "30", "-f", "mp3", "-"]
     args = input_args + output_args
     async with AsyncProcess(args, True) as ffmpeg_proc:
@@ -584,7 +589,8 @@ async def get_preview_stream(
             # write eof when last packet is received
             ffmpeg_proc.write_eof()
 
-        ffmpeg_proc.attach_task(writer())
+        if not streamdetails.direct:
+            ffmpeg_proc.attach_task(writer())
 
         # yield chunks from stdout
         async for chunk in ffmpeg_proc.iter_any():
index 767c2f0b9be905664a258ae7b97f8a5a4394c849..a92082029ed84f285da9dc3e0500c6576d1e045b 100644 (file)
@@ -37,7 +37,7 @@ async def create_thumbnail(
         img = Image.open(data)
         if size:
             img.thumbnail((size, size), Image.ANTIALIAS)
-        img.save(data, format="png")
+        img.convert("RGB").save(data, "PNG", optimize=True)
         return data.getvalue()
 
     return await mass.loop.run_in_executor(None, _create_image)
index 049eadba99f3dc72e3dc5926d579c79035fe349b..90a138ca52c065e898cc8711beadcb4a3ace6a9a 100644 (file)
@@ -152,6 +152,8 @@ class URLProvider(MusicProvider):
         else:
             # parse info with ffprobe (and store in cache)
             media_info = await parse_tags(url)
+            if "authSig" in url:
+                media_info.has_cover_image = False
             await self.mass.cache.set(cache_key, media_info.raw)
         return (item_id, url, media_info)