Skip to content

Commit

Permalink
Small fixes (#417)
Browse files Browse the repository at this point in the history
* no cover image for local HA files

* optimize image thumbs

* Fix audio preview

* contentFeatures DLNA header
  • Loading branch information
marcelveldt authored Jul 14, 2022
1 parent d247c92 commit a5a73a2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions music_assistant/controllers/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ async def serve_queue_stream(self, request: web.Request):
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",
}

Expand Down
16 changes: 11 additions & 5 deletions music_assistant/helpers/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -584,7 +589,8 @@ async def writer():
# 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():
Expand Down
2 changes: 1 addition & 1 deletion music_assistant/helpers/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _create_image():
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)
2 changes: 2 additions & 0 deletions music_assistant/music_providers/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ async def _get_media_info(
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)

Expand Down

0 comments on commit a5a73a2

Please sign in to comment.