mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-13 00:00:01 -08:00
feat(config): pass custom mpv args
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from configparser import ConfigParser
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from rich import print
|
||||
|
||||
from ..constants import (
|
||||
ASSETS_DIR,
|
||||
S_PLATFORM,
|
||||
@@ -60,6 +64,7 @@ class Config(object):
|
||||
"normalize_titles": "True",
|
||||
"notification_duration": "120",
|
||||
"max_cache_lifetime": "03:00:00",
|
||||
"mpv_args": "",
|
||||
"per_page": "15",
|
||||
"player": "mpv",
|
||||
"preferred_history": "local",
|
||||
@@ -96,8 +101,16 @@ class Config(object):
|
||||
self.configparser.add_section("anilist")
|
||||
|
||||
# --- set config values from file or using defaults ---
|
||||
try:
|
||||
if os.path.exists(USER_CONFIG_PATH) and not no_config:
|
||||
self.configparser.read(USER_CONFIG_PATH, encoding="utf-8")
|
||||
except Exception as e:
|
||||
print(
|
||||
"[yellow]Warning[/]: Failed to read config file using default configuration",
|
||||
file=sys.stderr,
|
||||
)
|
||||
logger.error(f"Failed to read config file: {e}")
|
||||
time.sleep(5)
|
||||
|
||||
# get the configuration
|
||||
self.auto_next = self.configparser.getboolean("stream", "auto_next")
|
||||
@@ -149,6 +162,7 @@ class Config(object):
|
||||
+ max_cache_lifetime[1] * 3600
|
||||
+ max_cache_lifetime[2] * 60
|
||||
)
|
||||
self.mpv_args = self.configparser.get("general", "mpv_args")
|
||||
self.per_page = self.configparser.get("anilist", "per_page")
|
||||
self.player = self.configparser.get("stream", "player")
|
||||
self.preferred_history = self.configparser.get("stream", "preferred_history")
|
||||
@@ -448,6 +462,10 @@ recent = {self.recent}
|
||||
# https://discord.com/oauth2/authorize?client_id=1292070065583165512
|
||||
discord = {self.discord}
|
||||
|
||||
# comma separated list of args that will be passed to mpv
|
||||
# example: --vo=kitty,--fullscreen,--volume=50
|
||||
mpv_args = {self.mpv_args}
|
||||
|
||||
|
||||
[stream]
|
||||
# the quality of the stream [1080,720,480,360]
|
||||
|
||||
@@ -208,5 +208,9 @@ def run_mpv(
|
||||
mpv_args.append(f"--title={title}")
|
||||
if ytdl_format:
|
||||
mpv_args.append(f"--ytdl-format={ytdl_format}")
|
||||
|
||||
if user_args := os.environ.get("FASTANIME_MPV_ARGS"):
|
||||
mpv_args.extend(user_args.split(","))
|
||||
|
||||
stop_time, total_time = stream_video(MPV, link, mpv_args, custom_args)
|
||||
return stop_time, total_time
|
||||
|
||||
Reference in New Issue
Block a user