Prevent error "StopIteration interacts badly with generators"
except yt_dlp.utils.DownloadError as err:
raise UnplayableMediaError(err) from err
format_selector = ydl.build_format_selector("m4a/bestaudio")
- stream_format = next(format_selector({"formats": info["formats"]}))
+ if not (stream_format := next(format_selector({"formats": info["formats"]})), None):
+ raise UnplayableMediaError("No stream formats found")
return stream_format
return await asyncio.to_thread(_extract_best_stream_url_format)