Added custom mpv options
This commit is contained in:
parent
73ab2896f9
commit
9279a6a5a2
4 changed files with 13 additions and 4 deletions
|
@ -66,6 +66,7 @@ def default_config() -> dict[str, Optional[int | str]]:
|
|||
"last_song": None,
|
||||
"waiting_room_policy": None,
|
||||
"key": None,
|
||||
"mpv_options": "",
|
||||
}
|
||||
|
||||
|
||||
|
@ -254,6 +255,7 @@ async def preview(entry: Entry) -> None:
|
|||
"--sub-pos=50",
|
||||
"--sub-file=-",
|
||||
"--fullscreen",
|
||||
state.config["mpv_options"],
|
||||
stdin=asyncio.subprocess.PIPE,
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
|
@ -290,7 +292,7 @@ async def handle_play(data: dict[str, Any]) -> None:
|
|||
state.current_source = sources[entry.source]
|
||||
if state.config["preview_duration"] > 0:
|
||||
await preview(entry)
|
||||
await sources[entry.source].play(entry)
|
||||
await sources[entry.source].play(entry, state.config["mpv_options"])
|
||||
except Exception: # pylint: disable=broad-except
|
||||
print_exc()
|
||||
state.current_source = None
|
||||
|
|
|
@ -298,6 +298,7 @@ class GeneralConfig(OptionFrame):
|
|||
self.add_string_option(
|
||||
"key", "Key for server (if necessary)", config["key"], is_password=True
|
||||
)
|
||||
self.add_string_option("mpv_options", "Additional MPV Arguments", config["mpv_options"])
|
||||
|
||||
def get_config(self) -> dict[str, Any]:
|
||||
config = super().get_config()
|
||||
|
|
|
@ -260,7 +260,7 @@ class Source(ABC):
|
|||
|
||||
self.downloaded_files[entry.ident].ready.set()
|
||||
|
||||
async def play(self, entry: Entry) -> None:
|
||||
async def play(self, entry: Entry, mpv_options: str) -> None:
|
||||
"""
|
||||
Play the entry.
|
||||
|
||||
|
@ -269,6 +269,8 @@ class Source(ABC):
|
|||
|
||||
:param entry: The entry to play
|
||||
:type entry: Entry
|
||||
:param mpv_options: Extra options for the mpv player
|
||||
:type mpv_options: str
|
||||
:rtype: None
|
||||
"""
|
||||
await self.ensure_playable(entry)
|
||||
|
@ -287,6 +289,7 @@ class Source(ABC):
|
|||
self.downloaded_files[entry.ident].video,
|
||||
self.downloaded_files[entry.ident].audio,
|
||||
*self.extra_mpv_arguments,
|
||||
mpv_options,
|
||||
)
|
||||
await self.player.wait()
|
||||
self.player = None
|
||||
|
|
|
@ -229,7 +229,7 @@ class YoutubeSource(Source):
|
|||
"""
|
||||
return {"channels": self.channels}
|
||||
|
||||
async def play(self, entry: Entry) -> None:
|
||||
async def play(self, entry: Entry, mpv_options: str) -> None:
|
||||
"""
|
||||
Play the given entry.
|
||||
|
||||
|
@ -240,6 +240,8 @@ class YoutubeSource(Source):
|
|||
|
||||
:param entry: The entry to play.
|
||||
:type entry: Entry
|
||||
:param mpv_options: The options to pass to ``mpv``.
|
||||
:type mpv_options: str
|
||||
:rtype: None
|
||||
"""
|
||||
if self.start_streaming and not self.downloaded_files[entry.ident].complete:
|
||||
|
@ -249,10 +251,11 @@ class YoutubeSource(Source):
|
|||
"--script-opts=ytdl_hook-ytdl_path=yt-dlp,ytdl_hook-exclude='%.pls$'",
|
||||
f"--ytdl-format={self.formatstring}",
|
||||
"--fullscreen",
|
||||
mpv_options,
|
||||
)
|
||||
await self.player.wait()
|
||||
else:
|
||||
await super().play(entry)
|
||||
await super().play(entry, mpv_options)
|
||||
|
||||
async def get_entry(self, performer: str, ident: str) -> Optional[Entry]:
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue