diff --git a/syng/client.py b/syng/client.py index c31f06d..e2018c5 100644 --- a/syng/client.py +++ b/syng/client.py @@ -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 diff --git a/syng/gui.py b/syng/gui.py index 7b2a814..d83f61c 100644 --- a/syng/gui.py +++ b/syng/gui.py @@ -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() diff --git a/syng/sources/source.py b/syng/sources/source.py index 979f491..ad73f13 100644 --- a/syng/sources/source.py +++ b/syng/sources/source.py @@ -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 diff --git a/syng/sources/youtube.py b/syng/sources/youtube.py index 1e3b86b..9375a8c 100644 --- a/syng/sources/youtube.py +++ b/syng/sources/youtube.py @@ -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]: """