mirror of
https://github.com/jellyfin/jellyfin-mpv-shim.git
synced 2025-02-23 08:00:34 +00:00
Add screenshot directory option. (#119)
This commit is contained in:
parent
d64b04b382
commit
255a51135f
@ -385,6 +385,8 @@ Other miscellaneous configuration options. You probably won't have to change the
|
||||
but if you have strange files this may not be the case.
|
||||
- `lang_filter_sub` - Apply the language filter to subtitle selection. Default: `False`
|
||||
- `lang_filter_audio` - Apply the language filter to audio selection. Default: `False`
|
||||
- `screenshot_dir` - Sets where screenshots go.
|
||||
- Default is the desktop on Windows and unset (current directory) on other platforms.
|
||||
|
||||
### MPV Configuration
|
||||
|
||||
|
@ -5,6 +5,7 @@ import socket
|
||||
import json
|
||||
import os.path
|
||||
import sys
|
||||
import getpass
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
|
||||
@ -12,6 +13,17 @@ log = logging.getLogger("conf")
|
||||
config_path = None
|
||||
|
||||
|
||||
def get_default_sdir():
|
||||
if sys.platform.startswith("win32"):
|
||||
if os.environ.get("USERPROFILE"):
|
||||
return os.path.join(os.environ["USERPROFILE"], "Desktop")
|
||||
else:
|
||||
username = getpass.getuser()
|
||||
return os.path.join(r"C:\Users", username, "Desktop")
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class Settings(BaseModel):
|
||||
player_name: str = socket.gethostname()
|
||||
audio_output: str = "hdmi"
|
||||
@ -106,6 +118,7 @@ class Settings(BaseModel):
|
||||
lang_filter: str = "und,eng,jpn,mis,mul,zxx"
|
||||
lang_filter_sub: bool = False
|
||||
lang_filter_audio: bool = False
|
||||
screenshot_dir: Optional[str] = get_default_sdir()
|
||||
|
||||
def __get_file(self, path: str, mode: str = "r", create: bool = True):
|
||||
created = False
|
||||
|
@ -176,6 +176,14 @@ class PlayerManager(object):
|
||||
else:
|
||||
log.warning("This mpv version doesn't support on-screen controller.")
|
||||
|
||||
if settings.screenshot_dir is not None:
|
||||
if hasattr(self._player, "screenshot_directory"):
|
||||
self._player.screenshot_directory = settings.screenshot_dir
|
||||
else:
|
||||
log.warning(
|
||||
"This mpv version doesn't support setting the screenshot directory."
|
||||
)
|
||||
|
||||
# Wrapper for on_key_press that ignores None.
|
||||
def keypress(key):
|
||||
def wrapper(func):
|
||||
|
Loading…
x
Reference in New Issue
Block a user