mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-12 15:50:01 -08:00
feat(config): mpv pre args
This commit is contained in:
@@ -65,6 +65,7 @@ class Config(object):
|
||||
"notification_duration": "120",
|
||||
"max_cache_lifetime": "03:00:00",
|
||||
"mpv_args": "",
|
||||
"mpv_pre_args": "",
|
||||
"per_page": "15",
|
||||
"player": "mpv",
|
||||
"preferred_history": "local",
|
||||
@@ -163,6 +164,7 @@ class Config(object):
|
||||
+ max_cache_lifetime[2] * 60
|
||||
)
|
||||
self.mpv_args = self.configparser.get("general", "mpv_args")
|
||||
self.mpv_pre_args = self.configparser.get("general", "mpv_pre_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")
|
||||
@@ -469,6 +471,10 @@ discord = {self.discord}
|
||||
# example: --vo=kitty,--fullscreen,--volume=50
|
||||
mpv_args = {self.mpv_args}
|
||||
|
||||
# command line options passed before the mpv command
|
||||
# example: kitty
|
||||
# useful incase of wanting to run sth like: kitty mpv --vo=kitty <url>
|
||||
mpv_pre_args = {self.mpv_pre_args}
|
||||
|
||||
[stream]
|
||||
# the quality of the stream [1080,720,480,360]
|
||||
|
||||
@@ -12,12 +12,13 @@ logger = logging.getLogger(__name__)
|
||||
mpv_av_time_pattern = re.compile(r"AV: ([0-9:]*) / ([0-9:]*) \(([0-9]*)%\)")
|
||||
|
||||
|
||||
def stream_video(MPV, url, mpv_args, custom_args):
|
||||
def stream_video(MPV, url, mpv_args, custom_args, pre_args=[]):
|
||||
last_time = "0"
|
||||
total_time = "0"
|
||||
if os.environ.get("FASTANIME_DISABLE_MPV_POPEN", "False") == "False":
|
||||
process = subprocess.Popen(
|
||||
[
|
||||
pre_args
|
||||
+ [
|
||||
MPV,
|
||||
url,
|
||||
*mpv_args,
|
||||
@@ -59,7 +60,7 @@ def stream_video(MPV, url, mpv_args, custom_args):
|
||||
process.wait()
|
||||
else:
|
||||
proc = subprocess.run(
|
||||
[MPV, url, *mpv_args, *custom_args],
|
||||
pre_args + [MPV, url, *mpv_args, *custom_args],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
@@ -212,5 +213,10 @@ def run_mpv(
|
||||
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)
|
||||
pre_args = []
|
||||
if user_args := os.environ.get("FASTANIME_MPV_PRE_ARGS"):
|
||||
pre_args = user_args.split(",")
|
||||
stop_time, total_time = stream_video(
|
||||
MPV, link, mpv_args, custom_args, pre_args
|
||||
)
|
||||
return stop_time, total_time
|
||||
|
||||
Reference in New Issue
Block a user