Fix HTTP player path support

This commit is contained in:
Et0h 2014-11-30 17:28:50 +00:00
parent 74e723032f
commit 490537d228
2 changed files with 32 additions and 25 deletions

View File

@ -60,25 +60,25 @@ VLC_MIN_VERSION = "2.0.0"
VLC_INTERFACE_MIN_VERSION = "0.2.1" VLC_INTERFACE_MIN_VERSION = "0.2.1"
CONTROLLED_ROOMS_MIN_VERSION = "1.3.0" CONTROLLED_ROOMS_MIN_VERSION = "1.3.0"
MPC_PATHS = [ MPC_PATHS = [
r"C:\Program Files (x86)\MPC-HC\mpc-hc.exe", r"c:\program files (x86)\mpc-hc\mpc-hc.exe",
r"C:\Program Files\MPC-HC\mpc-hc.exe", r"c:\program files\mpc-hc\mpc-hc.exe",
r"C:\Program Files\MPC-HC\mpc-hc64.exe", r"c:\program files\mpc-hc\mpc-hc64.exe",
r"C:\Program Files\Media Player Classic - Home Cinema\mpc-hc.exe", r"c:\program files\media player classic - home cinema\mpc-hc.exe",
r"C:\Program Files\Media Player Classic - Home Cinema\mpc-hc64.exe", r"c:\program files\media player classic - home cinema\mpc-hc64.exe",
r"C:\Program Files (x86)\Media Player Classic - Home Cinema\mpc-hc.exe", r"c:\program files (x86)\media player classic - home cinema\mpc-hc.exe",
r"C:\Program Files (x86)\K-Lite Codec Pack\Media Player Classic\mpc-hc.exe", r"c:\program files (x86)\k-lite codec pack\media player classic\mpc-hc.exe",
r"C:\Program Files\K-Lite Codec Pack\Media Player Classic\mpc-hc.exe", r"c:\program files\k-lite codec pack\media Player classic\mpc-hc.exe",
r"C:\Program Files (x86)\Combined Community Codec Pack\MPC\mpc-hc.exe", r"c:\program files (x86)\combined community codec pack\mpc\mpc-hc.exe",
r"C:\Program Files\Combined Community Codec Pack\MPC\mpc-hc.exe", r"c:\program files\combined community codec pack\mpc\mpc-hc.exe",
r"C:\Program Files\MPC HomeCinema (x64)\mpc-hc64.exe", r"c:\program files\mpc homecinema (x64)\mpc-hc64.exe",
] ]
MPLAYER_PATHS = ["mplayer2", "mplayer"] MPLAYER_PATHS = ["mplayer2", "mplayer"]
MPV_PATHS = ["mpv", "/opt/mpv/mpv", r"C:\Program Files\mpv\mpv.exe", r"C:\Program Files\mpv-player\mpv.exe", 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", r"c:\program Files (x86)\mpv\mpv.exe", r"c:\program Files (x86)\mpv-player\mpv.exe",
"/Applications/mpv.app/Contents/MacOS/mpv"] "/Applications/mpv.app/Contents/MacOS/mpv"]
VLC_PATHS = [ VLC_PATHS = [
r"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe", r"c:\program files (x86)\videolan\vlc\vlc.exe",
r"C:\Program Files\VideoLAN\VLC\vlc.exe", r"c:\program files\videolan\vlc\vlc.exe",
"/usr/bin/vlc", "/usr/bin/vlc",
"/usr/bin/vlc-wrapper", "/usr/bin/vlc-wrapper",
"/Applications/VLC.app/Contents/MacOS/VLC", "/Applications/VLC.app/Contents/MacOS/VLC",

View File

@ -77,13 +77,22 @@ class ConfigDialog(QtGui.QDialog):
if "http://" in path: if "http://" in path:
return True return True
def safenormcaseandpath(self, path):
if self._isURL(path):
return path
else:
return os.path.normcase(os.path.normpath(path))
def _tryToFillPlayerPath(self, playerpath, playerpathlist): def _tryToFillPlayerPath(self, playerpath, playerpathlist):
settings = QSettings("Syncplay", "PlayerList") settings = QSettings("Syncplay", "PlayerList")
settings.beginGroup("PlayerList") settings.beginGroup("PlayerList")
savedPlayers = settings.value("PlayerList", []) savedPlayers = settings.value("PlayerList", [])
if not isinstance(savedPlayers, list): if not isinstance(savedPlayers, list):
savedPlayers = [] savedPlayers = []
playerpathlist = list(set(os.path.normcase(os.path.normpath(path)) for path in set(playerpathlist + savedPlayers))) else:
for i, savedPlayer in enumerate(savedPlayers):
savedPlayers[i] = self.safenormcaseandpath(savedPlayer)
playerpathlist = list(set(playerpathlist + savedPlayers))
settings.endGroup() settings.endGroup()
foundpath = "" foundpath = ""
@ -103,9 +112,11 @@ class ConfigDialog(QtGui.QDialog):
self.executablepathCombobox.addItem(foundpath) self.executablepathCombobox.addItem(foundpath)
for path in playerpathlist: for path in playerpathlist:
if self._isURL(playerpath): if self._isURL(path):
foundpath = path if foundpath == "":
self.executablepathCombobox.addItem(path) foundpath = path
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 os.path.isfile(path) and os.path.normcase(os.path.normpath(path)) != os.path.normcase(os.path.normpath(foundpath)):
self.executablepathCombobox.addItem(path) self.executablepathCombobox.addItem(path)
@ -114,12 +125,8 @@ class ConfigDialog(QtGui.QDialog):
if foundpath != "": if foundpath != "":
settings.beginGroup("PlayerList") settings.beginGroup("PlayerList")
if self._isURL(foundpath): playerpathlist.append(self.safenormcaseandpath(foundpath))
playerpathlist.append(foundpath) settings.setValue("PlayerList", list(set(playerpathlist)))
settings.setValue("PlayerList", list(set(path) for path in set(playerpathlist)))
else:
playerpathlist.append(os.path.normcase(os.path.normpath(foundpath)))
settings.setValue("PlayerList", list(set(os.path.normcase(os.path.normpath(path)) for path in set(playerpathlist))))
settings.endGroup() settings.endGroup()
return foundpath return foundpath