mirror of
https://github.com/Benexl/FastAnime.git
synced 2026-01-09 11:45:02 -08:00
feat(mpv): add experimental auto next keybinding
This commit is contained in:
@@ -75,12 +75,33 @@ def player_controls(config: "Config", anilist_config: QueryDict):
|
||||
anilist_config.selected_anime_anilist["idMal"], current_episode
|
||||
):
|
||||
custom_args = args
|
||||
stop_time, total_time = run_mpv(
|
||||
current_link,
|
||||
selected_server["episode_title"],
|
||||
start_time=start_time,
|
||||
custom_args=custom_args,
|
||||
)
|
||||
if config.use_mpv_mod:
|
||||
from ..utils.player import player
|
||||
|
||||
mpv = player.create_player(
|
||||
config.anime_provider,
|
||||
anilist_config,
|
||||
config,
|
||||
selected_server["episode_title"],
|
||||
anilist_config,
|
||||
config,
|
||||
selected_server["episode_title"],
|
||||
anilist_config,
|
||||
config,
|
||||
selected_server["episode_title"],
|
||||
)
|
||||
mpv.play(current_link)
|
||||
mpv.wait_for_shutdown()
|
||||
mpv.terminate()
|
||||
stop_time = player.last_stop_time
|
||||
total_time = player.last_total_time
|
||||
else:
|
||||
stop_time, total_time = run_mpv(
|
||||
current_link,
|
||||
selected_server["episode_title"],
|
||||
start_time=start_time,
|
||||
custom_args=custom_args,
|
||||
)
|
||||
if stop_time == "0":
|
||||
episode = str(int(current_episode) + 1)
|
||||
else:
|
||||
@@ -148,7 +169,7 @@ def player_controls(config: "Config", anilist_config: QueryDict):
|
||||
|
||||
def _episodes():
|
||||
# reset watch_history
|
||||
config.update_watch_history(anime_id, None)
|
||||
config.continue_from_history = False
|
||||
|
||||
# call interface
|
||||
fetch_episode(config, anilist_config)
|
||||
@@ -341,6 +362,11 @@ def fetch_streams(config: "Config", anilist_config: QueryDict):
|
||||
if start_time != "0":
|
||||
print("[green]Continuing from:[/] ", start_time)
|
||||
custom_args = []
|
||||
if config.skip:
|
||||
if args := aniskip(
|
||||
anilist_config.selected_anime_anilist["idMal"], episode_number
|
||||
):
|
||||
custom_args.extend(args)
|
||||
if config.use_mpv_mod:
|
||||
from ..utils.player import player
|
||||
|
||||
@@ -354,11 +380,6 @@ def fetch_streams(config: "Config", anilist_config: QueryDict):
|
||||
total_time = player.last_total_time
|
||||
|
||||
else:
|
||||
if config.skip:
|
||||
if args := aniskip(
|
||||
anilist_config.selected_anime_anilist["idMal"], episode_number
|
||||
):
|
||||
custom_args.extend(args)
|
||||
stop_time, total_time = run_mpv(
|
||||
stream_link,
|
||||
selected_server["episode_title"],
|
||||
|
||||
@@ -130,6 +130,10 @@ class MpvPlayer(object):
|
||||
mpv_player.loadfile(url, options=f"title={self.current_media_title}")
|
||||
mpv_player.title = self.current_media_title
|
||||
|
||||
@mpv_player.on_key_press("shift+a")
|
||||
def _toggle_auto_next():
|
||||
config.auto_next = not config.auto_next
|
||||
|
||||
@mpv_player.property_observer("time-pos")
|
||||
def handle_time_start_update(*args):
|
||||
if len(args) > 1:
|
||||
@@ -143,9 +147,16 @@ class MpvPlayer(object):
|
||||
if len(args) > 1:
|
||||
value = args[1]
|
||||
if value is not None:
|
||||
rem_time = value
|
||||
value += self.last_stop_time_secs
|
||||
self.last_total_time = format_time(value)
|
||||
print(self.last_total_time)
|
||||
if rem_time < 10 and config.auto_next:
|
||||
url = self.get_episode("next")
|
||||
if url:
|
||||
mpv_player.loadfile(
|
||||
url, options=f"title={self.current_media_title}"
|
||||
)
|
||||
mpv_player.title = self.current_media_title
|
||||
|
||||
# TODO: custom skip functionality based on chapterskip.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user