VLC Unicode Support (prompted by nnamrrehdlopoel)

This commit is contained in:
Et0h 2014-05-19 01:05:33 +01:00
parent 3fc59d772a
commit 10089bb417
3 changed files with 20 additions and 8 deletions

View File

@ -538,7 +538,7 @@ info = dict(
options={'py2exe': { options={'py2exe': {
'dist_dir': OUT_DIR, 'dist_dir': OUT_DIR,
'packages': 'PySide.QtUiTools', 'packages': 'PySide.QtUiTools',
'includes': 'twisted, sys, encodings, datetime, os, time, math, PySide', 'includes': 'twisted, sys, encodings, datetime, os, time, math, PySide, liburl',
'excludes': 'venv, _ssl, doctest, pdb, unittest, win32clipboard, win32file, win32pdh, win32security, win32trace, win32ui, winxpgui, win32pipe, win32process, Tkinter', 'excludes': 'venv, _ssl, doctest, pdb, unittest, win32clipboard, win32file, win32pdh, win32security, win32trace, win32ui, winxpgui, win32pipe, win32process, Tkinter',
'dll_excludes': 'msvcr71.dll, MSVCP90.dll, POWRPROF.dll', 'dll_excludes': 'msvcr71.dll, MSVCP90.dll, POWRPROF.dll',
'optimize': 2, 'optimize': 2,

View File

@ -80,7 +80,6 @@ en = {
"hello-arguments-error" : "Not enough Hello arguments\n", "hello-arguments-error" : "Not enough Hello arguments\n",
"version-mismatch-error" : "Mismatch between versions of client and server\n", "version-mismatch-error" : "Mismatch between versions of client and server\n",
"vlc-error-echo": "VLC error: {}", # VLC error line "vlc-error-echo": "VLC error: {}", # VLC error line
"vlc-unicode-loadfile-error" : "Cannot load file through Syncplay because it contains non-ASCII characters. Please load the file through VLC.",
"vlc-failed-connection": "Failed to connect to VLC. If you have not installed syncplay.lua then please refer to http://syncplay.pl/LUA/ for instructions.", "vlc-failed-connection": "Failed to connect to VLC. If you have not installed syncplay.lua then please refer to http://syncplay.pl/LUA/ for instructions.",
"vlc-failed-noscript": "VLC has reported that the syncplay.lua interface script has not been installed. Please refer to http://syncplay.pl/LUA/ for instructions.", "vlc-failed-noscript": "VLC has reported that the syncplay.lua interface script has not been installed. Please refer to http://syncplay.pl/LUA/ for instructions.",
"vlc-failed-versioncheck": "This version of VLC is not supported by Syncplay. Please use VLC 2.", "vlc-failed-versioncheck": "This version of VLC is not supported by Syncplay. Please use VLC 2.",

View File

@ -8,6 +8,7 @@ import sys
import random import random
import socket import socket
import asynchat, asyncore import asynchat, asyncore
import urllib
from syncplay.messages import getMessage from syncplay.messages import getMessage
import time import time
@ -97,14 +98,26 @@ class VlcPlayer(BasePlayer):
self._paused = value self._paused = value
self._listener.sendLine('set-playstate: {}'.format("paused" if value else "playing")) self._listener.sendLine('set-playstate: {}'.format("paused" if value else "playing"))
def getMRL(self, fileURL):
fileURL = fileURL.replace(u'\\', u'/')
fileURL = fileURL.encode('utf8')
fileURL = urllib.quote_plus(fileURL)
if sys.platform.startswith('win'):
fileURL = "file:///" + fileURL
else:
fileURL = "file://" + fileURL
fileURL = fileURL.replace("+", "%20")
return fileURL
def _isASCII (self, s): def _isASCII (self, s):
return all(ord(c) < 256 for c in s) return all(ord(c) < 128 for c in s)
def openFile(self, filePath): def openFile(self, filePath):
if (self._isASCII(filePath) == True): if (self._isASCII(filePath) == True):
self._listener.sendLine('load-file: {}'.format(filePath.encode('ascii', 'ignore'))) #TODO: Proper Unicode support self._listener.sendLine('load-file: {}'.format(filePath.encode('ascii', 'ignore')))
else: else:
self._client.ui.showErrorMessage(getMessage("en", "vlc-unicode-loadfile-error"), True) fileURL = self.getMRL(filePath)
self._listener.sendLine('load-file: {}'.format(fileURL))
def _getFileInfo(self): def _getFileInfo(self):
self._listener.sendLine("get-duration") self._listener.sendLine("get-duration")
@ -212,9 +225,9 @@ class VlcPlayer(BasePlayer):
call = [playerPath] call = [playerPath]
if(filePath): if(filePath):
if (self.__playerController._isASCII(filePath) == True): if (self.__playerController._isASCII(filePath) == True):
call.append(filePath) #TODO: Proper Unicode support call.append(filePath)
else: else:
playerController._client.ui.showErrorMessage(getMessage("en", "vlc-unicode-loadfile-error"), True) call.append(self.__playerController.getMRL(filePath))
def _usevlcintf(vlcIntfPath, vlcIntfUserPath): def _usevlcintf(vlcIntfPath, vlcIntfUserPath):
vlcSyncplayInterfacePath = vlcIntfPath + "syncplay.lua" vlcSyncplayInterfacePath = vlcIntfPath + "syncplay.lua"
if not os.path.isfile(vlcSyncplayInterfacePath): if not os.path.isfile(vlcSyncplayInterfacePath):
@ -238,7 +251,7 @@ class VlcPlayer(BasePlayer):
playerController.vlcIntfPath = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/" playerController.vlcIntfPath = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/"
playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), "Library/Application Support/org.videolan.vlc/lua/intf/") playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), "Library/Application Support/org.videolan.vlc/lua/intf/")
else: else:
playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/lua/intf/" # TODO: Make Mac version use /Applications/VLC.app/Contents/MacOS/share/lua/intf/ playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/lua/intf/"
playerController.vlcIntfUserPath = os.path.join(os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\") playerController.vlcIntfUserPath = os.path.join(os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\")
playerController.vlcModulePath = playerController.vlcIntfPath + "modules/?.luac" playerController.vlcModulePath = playerController.vlcIntfPath + "modules/?.luac"
if _usevlcintf(playerController.vlcIntfPath, playerController.vlcIntfUserPath) == True: if _usevlcintf(playerController.vlcIntfPath, playerController.vlcIntfUserPath) == True: