main_window: skip parallel httpx download for streamed videos
behavior change: when streaming=True (uncached video handed directly to mpv), _load now early-returns instead of running download_image in parallel. mpv's stream-record option (added in the previous commit) handles cache population, so the parallel httpx download was a second TCP+TLS connection to the same CDN URL contending with mpv for bandwidth. Single connection per uncached video after this commit.
This commit is contained in:
parent
a01ac34944
commit
d9830d0f68
@ -1248,24 +1248,18 @@ class BooruApp(QMainWindow):
|
|||||||
async def _load():
|
async def _load():
|
||||||
self._prefetch_pause.clear() # pause prefetch
|
self._prefetch_pause.clear() # pause prefetch
|
||||||
try:
|
try:
|
||||||
|
if streaming:
|
||||||
|
# mpv is streaming the URL directly and its
|
||||||
|
# stream-record option populates the cache as it
|
||||||
|
# plays. No parallel httpx download needed — that
|
||||||
|
# would open a second TCP+TLS connection to the
|
||||||
|
# same CDN URL, contending with mpv for bandwidth.
|
||||||
|
return
|
||||||
path = await download_image(post.file_url, progress_callback=_progress)
|
path = await download_image(post.file_url, progress_callback=_progress)
|
||||||
if not streaming:
|
self._signals.image_done.emit(str(path), info)
|
||||||
# Normal path: download finished, hand the local
|
|
||||||
# file to the preview/popout. For streaming, mpv
|
|
||||||
# is already playing the URL — calling set_media
|
|
||||||
# again with the local path would interrupt
|
|
||||||
# playback and reset position to 0, so we
|
|
||||||
# suppress image_done in that case and just let
|
|
||||||
# the cache write complete silently.
|
|
||||||
self._signals.image_done.emit(str(path), info)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error(f"Image download failed: {e}")
|
log.error(f"Image download failed: {e}")
|
||||||
if not streaming:
|
self._signals.image_error.emit(str(e))
|
||||||
# If we're streaming, mpv has the URL — don't
|
|
||||||
# surface a "download failed" error since the
|
|
||||||
# user is likely watching the video right now.
|
|
||||||
# The cache just won't get populated for next time.
|
|
||||||
self._signals.image_error.emit(str(e))
|
|
||||||
finally:
|
finally:
|
||||||
self._prefetch_pause.set() # resume prefetch
|
self._prefetch_pause.set() # resume prefetch
|
||||||
if preview_hidden:
|
if preview_hidden:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user