From e0ef5eb9b7ef3a264a005398484963a757897937 Mon Sep 17 00:00:00 2001 From: Felix Stupp Date: Mon, 25 Oct 2021 21:06:24 +0200 Subject: [PATCH] client: Add support for starting video at certain time --- desktop-client/app.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/desktop-client/app.py b/desktop-client/app.py index acad2e5..8753c6a 100755 --- a/desktop-client/app.py +++ b/desktop-client/app.py @@ -4,15 +4,22 @@ import argparse from pathlib import Path from string import Template import subprocess -from typing import Callable, Dict +from typing import Callable, Dict, Optional import urllib.parse as url -def cmd_player_play(video_uri: str): +def cmd_player_play(video_uri: str, start: Optional[str] = None): print(f"Play video {video_uri}") - subprocess.Popen([ - str(Path("~/bin/mpvadd").expanduser()), video_uri, - ], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocess.Popen( + args = [e for e in [ + str(Path("~/bin/mpvadd").expanduser()), + video_uri, + f"start={start}" if start is not None else None, + ] if e is not None], + stdin = subprocess.DEVNULL, + stdout = subprocess.DEVNULL, + stderr = subprocess.DEVNULL, + ) URI_SCHEME = "entertainment-decider" URI_COMMANDS = {