Skip to content

Commit 016d07c

Browse files
authored
Added support for memento player (#716)
* Added support for memento player * removed useless print statement Signed-off-by: Eyal Mazuz <mazuzeyal@protonmail.com> --------- Signed-off-by: Eyal Mazuz <mazuzeyal@protonmail.com>
1 parent dfaaa9b commit 016d07c

File tree

4 files changed

+77
-1
lines changed

4 files changed

+77
-1
lines changed

syncplay/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ def getValueForOS(constantDict):
180180
r"c:\program Files (x86)\mpv\mpv.exe", r"c:\program Files (x86)\mpv-player\mpv.exe",
181181
"/Applications/mpv.app/Contents/MacOS/mpv"]
182182
MPVNET_PATHS = [r"c:\program files\mpv.net\mpvnet.exe", r"c:\program Files (x86)\mpv.net\mpvnet.exe"]
183+
MEMENTO_PATHS = ["memento", "/usr/bin/memento", "/usr/local/bin/memento"]
184+
183185
try:
184186
import os
185187
MPVNET_PATHS.append(os.path.expandvars(r'%LOCALAPPDATA%\Microsoft\WindowsApps\mpvnet.exe'))
@@ -203,6 +205,7 @@ def getValueForOS(constantDict):
203205
MPLAYER_ICONPATH = "mplayer.png"
204206
MPV_ICONPATH = "mpv.png"
205207
MPVNET_ICONPATH = "mpvnet.png"
208+
MEMENTO_ICONPATH = "memento.png"
206209
MPC_ICONPATH = "mpc-hc.png"
207210
MPC64_ICONPATH = "mpc-hc64.png"
208211
MPC_BE_ICONPATH = "mpc-be.png"

syncplay/players/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from syncplay.players.mplayer import MplayerPlayer
22
from syncplay.players.mpv import MpvPlayer
33
from syncplay.players.mpvnet import MpvnetPlayer
4+
from syncplay.players.memento import MementoPlayer
45
from syncplay.players.vlc import VlcPlayer
6+
57
try:
68
from syncplay.players.mpc import MPCHCAPIPlayer
79
except ImportError:
@@ -20,4 +22,4 @@
2022

2123

2224
def getAvailablePlayers():
23-
return [MPCHCAPIPlayer, MpvPlayer, MpvnetPlayer, VlcPlayer, MpcBePlayer, MplayerPlayer, IinaPlayer]
25+
return [MPCHCAPIPlayer, MpvPlayer, MpvnetPlayer, MementoPlayer, VlcPlayer, MpcBePlayer, MplayerPlayer, IinaPlayer]

syncplay/players/memento.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import os
2+
3+
from syncplay import constants
4+
5+
from syncplay.players.mpv import MpvPlayer
6+
from syncplay.utils import findResourcePath, playerPathExists
7+
8+
9+
class MementoPlayer(MpvPlayer):
10+
@staticmethod
11+
def run(client, playerPath, filePath, args):
12+
return MementoPlayer(
13+
client, MementoPlayer.getExpandedPath(playerPath), filePath, args
14+
)
15+
16+
@staticmethod
17+
def getDefaultPlayerPathsList():
18+
l = []
19+
for path in constants.MEMENTO_PATHS:
20+
p = MementoPlayer.getExpandedPath(path)
21+
if p:
22+
l.append(p)
23+
return l
24+
25+
@staticmethod
26+
def isValidPlayerPath(path):
27+
if "memento" in path and MementoPlayer.getExpandedPath(path):
28+
return True
29+
return False
30+
31+
@staticmethod
32+
def getExpandedPath(playerPath):
33+
if not playerPathExists(playerPath):
34+
if playerPathExists(playerPath + "memento.exe"):
35+
playerPath += "memento.exe"
36+
return playerPath
37+
elif playerPathExists(playerPath + "\\memento.exe"):
38+
playerPath += "\\memento.exe"
39+
return playerPath
40+
if os.access(playerPath, os.X_OK):
41+
return playerPath
42+
for path in os.environ["PATH"].split(":"):
43+
path = os.path.join(os.path.realpath(path), playerPath)
44+
if os.access(path, os.X_OK):
45+
return path
46+
47+
@staticmethod
48+
def getIconPath(path):
49+
return constants.MEMENTO_ICONPATH
50+
51+
@staticmethod
52+
def getStartupArgs(userArgs):
53+
args = constants.MPV_ARGS
54+
args["scripts"] = findResourcePath("syncplayintf.lua")
55+
if userArgs:
56+
for argToAdd in userArgs:
57+
if argToAdd.startswith("--"):
58+
argToAdd = argToAdd[2:]
59+
elif argToAdd.startswith("-"):
60+
argToAdd = argToAdd[1:]
61+
if argToAdd.strip() == "":
62+
continue
63+
if "=" in argToAdd:
64+
(argName, argValue) = argToAdd.split("=", 1)
65+
if argValue[0] == '"' and argValue[-1] == '"':
66+
argValue = argValue[1:-1]
67+
else:
68+
argName = argToAdd
69+
argValue = ""
70+
args[argName] = argValue
71+
return args

syncplay/resources/memento.png

3.16 KB
Loading

0 commit comments

Comments
 (0)