Skip to content

Commit

Permalink
Add Windows Store mpv.net path support (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
Et0h committed Jan 2, 2022
1 parent b760ee6 commit bed4986
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
8 changes: 6 additions & 2 deletions syncplay/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,12 @@ def getValueForOS(constantDict):
MPV_PATHS = ["mpv", "/opt/mpv/mpv", r"c:\program files\mpv\mpv.exe", r"c:\program files\mpv-player\mpv.exe",
r"c:\program Files (x86)\mpv\mpv.exe", r"c:\program Files (x86)\mpv-player\mpv.exe",
"/Applications/mpv.app/Contents/MacOS/mpv"]
MPVNET_PATHS = [r"c:\program files\mpv.net\mpvnet.exe", r"c:\program files\mpv.net\mpvnet.exe",
r"c:\program Files (x86)\mpv.net\mpvnet.exe", r"c:\program Files (x86)\mpv.net\mpvnet.exe"]
MPVNET_PATHS = [r"c:\program files\mpv.net\mpvnet.exe", r"c:\program Files (x86)\mpv.net\mpvnet.exe"]
try:
import os
MPVNET_PATHS.append(os.path.expandvars(r'%LOCALAPPDATA%\Microsoft\WindowsApps\mpvnet.exe'))
except:
pass
VLC_PATHS = [
r"c:\program files (x86)\videolan\vlc\vlc.exe",
r"c:\program files\videolan\vlc\vlc.exe",
Expand Down
7 changes: 4 additions & 3 deletions syncplay/players/mpvnet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from syncplay import constants
from syncplay.players.mpv import MpvPlayer
from syncplay.utils import playerPathExists

class MpvnetPlayer(MpvPlayer):

Expand Down Expand Up @@ -30,11 +31,11 @@ def isValidPlayerPath(path):

@staticmethod
def getExpandedPath(playerPath):
if not os.path.isfile(playerPath):
if os.path.isfile(playerPath + "mpvnet.exe"):
if not playerPathExists(playerPath):
if playerPathExists(playerPath + "mpvnet.exe"):
playerPath += "mpvnet.exe"
return playerPath
elif os.path.isfile(playerPath + "\\mpvnet.exe"):
elif playerPathExists(playerPath + "\\mpvnet.exe"):
playerPath += "\\mpvnet.exe"
return playerPath
if os.access(playerPath, os.X_OK):
Expand Down
12 changes: 7 additions & 5 deletions syncplay/ui/GuiConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from syncplay.messages import getMessage, getLanguages, setLanguage, getInitialLanguage
from syncplay.players.playerFactory import PlayerFactory
from syncplay.utils import isBSD, isLinux, isMacOS, isWindows
from syncplay.utils import resourcespath, posixresourcespath
from syncplay.utils import resourcespath, posixresourcespath, playerPathExists

from syncplay.vendor.Qt import QtCore, QtWidgets, QtGui, __binding__, IsPySide, IsPySide2
from syncplay.vendor.Qt.QtCore import Qt, QSettings, QCoreApplication, QSize, QPoint, QUrl, QLine, QEventLoop, Signal
Expand Down Expand Up @@ -210,12 +210,14 @@ def _tryToFillPlayerPath(self, playerpath, playerpathlist):
self.executablepathCombobox.addItem(foundpath)

else:
if not os.path.isfile(playerpath):
if not playerPathExists(playerpath):
expandedpath = PlayerFactory().getExpandedPlayerPathByPath(playerpath)
if expandedpath is not None and os.path.isfile(expandedpath):
if expandedpath is not None and playerPathExists(expandedpath):
playerpath = expandedpath
elif "mpvnet.exe" in playerpath and playerPathExists(playerpath.replace("mpvnet.exe","mpvnet.com")):
self.executablepathCombobox.addItem(playerpath)

if os.path.isfile(playerpath):
if playerPathExists(playerpath):
foundpath = playerpath
self.executablepathCombobox.addItem(foundpath)

Expand All @@ -226,7 +228,7 @@ def _tryToFillPlayerPath(self, playerpath, playerpathlist):
if path != playerpath:
self.executablepathCombobox.addItem(path)

elif os.path.isfile(path) and os.path.normcase(os.path.normpath(path)) != os.path.normcase(os.path.normpath(foundpath)):
elif playerPathExists(path) and os.path.normcase(os.path.normpath(path)) != os.path.normcase(os.path.normpath(foundpath)):
self.executablepathCombobox.addItem(path)
if foundpath == "":
foundpath = path
Expand Down
7 changes: 7 additions & 0 deletions syncplay/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,13 @@ def open_system_file_browser(path):
else:
subprocess.Popen(["xdg-open", path])

def playerPathExists(path):
if os.path.isfile(path):
return True
elif "mpvnet.exe" in path and os.path.isfile(path.replace("mpvnet.exe","mpvnet.com")):
return True
else:
return False

def getListOfPublicServers():
try:
Expand Down

0 comments on commit bed4986

Please sign in to comment.