Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions anicli/cli/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,24 @@ def play(self, video: "Video", title: Optional[str] = None, player: Optional[str
subprocess.Popen(cmd, shell=True).wait()


def run_video(video: "Video", app_cfg: "Config", title: Optional[str] = None):
def run_video(thumbnail, name, episode, video: "Video", app_cfg: "Config", title: Optional[str] = None,):
if app_cfg.USE_FFMPEG_ROUTE:
if app_cfg.PLAYER == "mpv":
proc1 = subprocess.Popen(['python', 'anicli/rich_presence.py', "--name", name, "--episode", episode, "--episode_max", "255","--thumbnail", thumbnail])
FFMPEGRouter(app_cfg).play(video, title, player=app_cfg.PLAYER, title_arg='--title="{}"')
return proc1.kill()
elif app_cfg.PLAYER in ("vlc", "cvlc"):
proc1 = subprocess.Popen(['python', 'anicli/rich_presence.py', "--name", name, "--episode", episode, "--episode_max", "255","--thumbnail", thumbnail])
FFMPEGRouter(app_cfg).play(video, title, player=app_cfg.PLAYER, title_arg='--meta-title "{}"')
return
return proc1.kill()
elif app_cfg.PLAYER == "mpv":
return MpvPlayer(app_cfg).play(video, title)
proc1 = subprocess.Popen(['python', 'anicli/rich_presence.py', "--name", name, "--episode", episode, "--episode_max", "255", "--thumbnail", thumbnail])
MpvPlayer(app_cfg).play(video, title)
return proc1.kill()
elif app_cfg.PLAYER == "vlc":
return VLCPlayer(app_cfg).play(video, title)
proc1 = subprocess.Popen(['python', 'anicli/rich_presence.py', "--name", name, "--episode", episode, "--episode_max", "255","--thumbnail", thumbnail])
VLCPlayer(app_cfg).play(video, title)
return proc1.kill()


def run_m3u_playlist(videos: List["Video"], names: List[str], app_cfg: "Config"):
Expand Down
5 changes: 4 additions & 1 deletion anicli/cli/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SearchStates(IntStateGroup):
SOURCE_SLICE = 4
VIDEO_SLICE = 5

chosen_episode = None

app = AnicliApp("search")
app.register_states(SearchStates)
Expand Down Expand Up @@ -93,6 +94,8 @@ def choose_episode():
return app.fsm.set(SearchStates.SOURCE_SLICE)
else:
app.fsm["search"] = {"episode": choice_human_index(episodes, int(choose))}
global chosen_episode
chosen_episode = choose
app.fsm.set(SearchStates.SOURCE)


Expand Down Expand Up @@ -155,7 +158,7 @@ def choose_quality():
anime: BaseAnime = app.fsm["anime"]
title = create_title(anime, episode, source)

run_video(video, app.CFG, title)
run_video(str(app.CTX["result"].thumbnail), str(app.CTX["result"]), str(chosen_episode), video, app.CFG, title)
return app.fsm.set(SearchStates.EPISODE)


Expand Down
34 changes: 34 additions & 0 deletions anicli/rich_presence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import argparse
import pypresence.exceptions

def main():
parser = argparse.ArgumentParser(description="Rich Presence Script")

parser.add_argument("-n", "--name", type=str, help="", required=True)
parser.add_argument("-e", "--episode", type=str, help="", required=True)
parser.add_argument("-em", "--episode_max", type=str, help="", required=True)
parser.add_argument("-t", "--thumbnail", type=str, help="", required=True)

args = parser.parse_args()

from pypresence import Presence
import time
client_id = "1392818712511385652"
try:
RPC = Presence(client_id)
RPC.connect()

while True:
RPC.update(
state=str(args.name),
large_image=str(args.thumbnail),
details="Смотрит Аниме",
party_size=[int(args.episode), int(args.episode)],
buttons=[{"label": "Github Repository", "url": "https://github.com"}],
)
time.sleep(15) # minimum 15 seconds
except pypresence.exceptions.DiscordNotFound:
pass

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies = [
"anicli-api>=0.7.14",
"eggella>=0.1.7",
"tqdm>=4.67.1",
"pypresence>=4.3.0"
]

[project.optional-dependencies]
Expand Down