Add 1 second timeout for media search, and make it more efficient
This commit is contained in:
parent
8877514987
commit
f0f29653ce
@ -48,6 +48,8 @@ SERVER_STATE_INTERVAL = 1
|
|||||||
WARNING_OSD_MESSAGES_LOOP_INTERVAL = 1
|
WARNING_OSD_MESSAGES_LOOP_INTERVAL = 1
|
||||||
AUTOPLAY_DELAY = 3.0
|
AUTOPLAY_DELAY = 3.0
|
||||||
SYNC_ON_PAUSE = True # Client seek to global position - subtitles may disappear on some media players
|
SYNC_ON_PAUSE = True # Client seek to global position - subtitles may disappear on some media players
|
||||||
|
FOLDER_SEARCH_TIMEOUT = 1.0 # Secs
|
||||||
|
|
||||||
#Usually there's no need to adjust these
|
#Usually there's no need to adjust these
|
||||||
LAST_PAUSED_DIFF_THRESHOLD = 2
|
LAST_PAUSED_DIFF_THRESHOLD = 2
|
||||||
FILENAME_STRIP_REGEX = u"[-~_\.\[\](): ]"
|
FILENAME_STRIP_REGEX = u"[-~_\.\[\](): ]"
|
||||||
|
|||||||
@ -135,6 +135,7 @@ en = {
|
|||||||
"invalid-offset-value" : u"Invalid offset value",
|
"invalid-offset-value" : u"Invalid offset value",
|
||||||
|
|
||||||
"switch-file-not-found-error" : u"Could not switch to file '{0}'. Syncplay looks in the folder of the currently playing file and specified media directories.", # File not found
|
"switch-file-not-found-error" : u"Could not switch to file '{0}'. Syncplay looks in the folder of the currently playing file and specified media directories.", # File not found
|
||||||
|
"folder-search-timeout-error" : u"The search for media in '{}' was aborted as it took too long. This will occur if you select a folder with too many sub-folders in your list of media folders to search through. Until Syncplay is restarted only the directory of the currently open file will be checked.", #Folder
|
||||||
|
|
||||||
# Client arguments
|
# Client arguments
|
||||||
"argument-description" : 'Solution to synchronize playback of multiple MPlayer and MPC-HC instances over the network.',
|
"argument-description" : 'Solution to synchronize playback of multiple MPlayer and MPC-HC instances over the network.',
|
||||||
@ -497,6 +498,7 @@ ru = {
|
|||||||
"invalid-offset-value" : u"Некорректное смещение",
|
"invalid-offset-value" : u"Некорректное смещение",
|
||||||
|
|
||||||
"switch-file-not-found-error" : u"Невозможно переключиться на файл '{0}'. Syncplay looks in the folder of the currently playing file and specified media directories.", # File not found # TODO: Translate last part into Russian
|
"switch-file-not-found-error" : u"Невозможно переключиться на файл '{0}'. Syncplay looks in the folder of the currently playing file and specified media directories.", # File not found # TODO: Translate last part into Russian
|
||||||
|
"folder-search-timeout-error" : u"The search for media in '{}' was aborted as it took too long. This will occur if you select a folder with too many sub-folders in your list of media folders to search through. Until Syncplay is restarted only the directory of the currently open file will be checked.", #Folder # TODO: Translate into Russian
|
||||||
|
|
||||||
# Client arguments
|
# Client arguments
|
||||||
"argument-description" : u'Решение для синхронного воспроизведения в VLC, MPlayer или MPC-HC через Интернет.',
|
"argument-description" : u'Решение для синхронного воспроизведения в VLC, MPlayer или MPC-HC через Интернет.',
|
||||||
@ -859,6 +861,7 @@ de = {
|
|||||||
"invalid-offset-value" : u"Ungültiger Offset-Wert",
|
"invalid-offset-value" : u"Ungültiger Offset-Wert",
|
||||||
|
|
||||||
"switch-file-not-found-error" : u"Could not switch to file '{0}'. Syncplay looks in the folder of the currently playing file and specified media directories.", # File not found, folder it was not found in # TODO: Translate into German
|
"switch-file-not-found-error" : u"Could not switch to file '{0}'. Syncplay looks in the folder of the currently playing file and specified media directories.", # File not found, folder it was not found in # TODO: Translate into German
|
||||||
|
"folder-search-timeout-error" : u"The search for media in '{}' was aborted as it took too long. This will occur if you select a folder with too many sub-folders in your list of media folders to search through. Until Syncplay is restarted only the directory of the currently open file will be checked.", #Folder # TODO: Translate into German
|
||||||
|
|
||||||
# Client arguments
|
# Client arguments
|
||||||
"argument-description" : u'Syncplay ist eine Anwendung um mehrere MPlayer, MPC-HC und VLC-Instanzen über das Internet zu synchronisieren.',
|
"argument-description" : u'Syncplay ist eine Anwendung um mehrere MPlayer, MPC-HC und VLC-Instanzen über das Internet zu synchronisieren.',
|
||||||
|
|||||||
@ -152,7 +152,16 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
return constants.FILEITEM_SWITCH_STREAM_SWITCH
|
return constants.FILEITEM_SWITCH_STREAM_SWITCH
|
||||||
else:
|
else:
|
||||||
currentPath = self._syncplayClient.userlist.currentUser.file["path"] if self._syncplayClient.userlist.currentUser.file else None
|
currentPath = self._syncplayClient.userlist.currentUser.file["path"] if self._syncplayClient.userlist.currentUser.file else None
|
||||||
if utils.findFilenameInDirectories(filename, self.config["mediaSearchDirectories"]):
|
if self.folderSearchEnabled:
|
||||||
|
try:
|
||||||
|
filenamesInDirectories = utils.findFilenameInDirectories(filename, self.config["mediaSearchDirectories"])
|
||||||
|
except IOError as errorMessage:
|
||||||
|
self.showErrorMessage(errorMessage)
|
||||||
|
filenamesInDirectories = None
|
||||||
|
self.folderSearchEnabled = False
|
||||||
|
else:
|
||||||
|
filenamesInDirectories = None
|
||||||
|
if filenamesInDirectories:
|
||||||
return constants.FILEITEM_SWITCH_FILE_SWITCH
|
return constants.FILEITEM_SWITCH_FILE_SWITCH
|
||||||
elif currentPath:
|
elif currentPath:
|
||||||
currentDirectory = os.path.dirname(currentPath)
|
currentDirectory = os.path.dirname(currentPath)
|
||||||
@ -301,7 +310,15 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
self._syncplayClient._player.openFile(filename)
|
self._syncplayClient._player.openFile(filename)
|
||||||
else:
|
else:
|
||||||
currentPath = self._syncplayClient.userlist.currentUser.file["path"] if self._syncplayClient.userlist.currentUser.file else None
|
currentPath = self._syncplayClient.userlist.currentUser.file["path"] if self._syncplayClient.userlist.currentUser.file else None
|
||||||
pathFound = utils.findFilenameInDirectories(filename, self.config["mediaSearchDirectories"])
|
if self.folderSearchEnabled:
|
||||||
|
try:
|
||||||
|
pathFound = utils.findFilenameInDirectories(filename, self.config["mediaSearchDirectories"])
|
||||||
|
except IOError as errorMessage:
|
||||||
|
self.showErrorMessage(errorMessage)
|
||||||
|
pathFound = None
|
||||||
|
self.folderSearchEnabled = False
|
||||||
|
else:
|
||||||
|
pathFound = None
|
||||||
if pathFound:
|
if pathFound:
|
||||||
self._syncplayClient._player.openFile(pathFound)
|
self._syncplayClient._player.openFile(pathFound)
|
||||||
elif currentPath:
|
elif currentPath:
|
||||||
@ -907,6 +924,7 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(MainWindow, self).__init__()
|
super(MainWindow, self).__init__()
|
||||||
self._syncplayClient = None
|
self._syncplayClient = None
|
||||||
|
self.folderSearchEnabled = True
|
||||||
self.QtGui = QtGui
|
self.QtGui = QtGui
|
||||||
if sys.platform.startswith('win'):
|
if sys.platform.startswith('win'):
|
||||||
self.resourcespath = utils.findWorkingDir() + "\\resources\\"
|
self.resourcespath = utils.findWorkingDir() + "\\resources\\"
|
||||||
|
|||||||
@ -11,6 +11,8 @@ import random
|
|||||||
import string
|
import string
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
folderSearchEnabled = True
|
||||||
|
|
||||||
def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, logger=None):
|
def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, logger=None):
|
||||||
"""Retry calling the decorated function using an exponential backoff.
|
"""Retry calling the decorated function using an exponential backoff.
|
||||||
|
|
||||||
@ -249,11 +251,13 @@ def convertMultilineStringToList(multilineString):
|
|||||||
|
|
||||||
def findFilenameInDirectories(filename, directoryList):
|
def findFilenameInDirectories(filename, directoryList):
|
||||||
if filename and directoryList:
|
if filename and directoryList:
|
||||||
|
startTime = time.time()
|
||||||
for directory in directoryList:
|
for directory in directoryList:
|
||||||
for root, dirs, files in os.walk(directory):
|
for root, dirs, files in os.walk(directory):
|
||||||
candidatePath = os.path.join(root,filename)
|
if filename in files:
|
||||||
if os.path.isfile(candidatePath):
|
return os.path.join(root,filename)
|
||||||
return candidatePath
|
if time.time() - startTime > constants.FOLDER_SEARCH_TIMEOUT:
|
||||||
|
raise IOError(getMessage("folder-search-timeout-error").format(directory))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
class RoomPasswordProvider(object):
|
class RoomPasswordProvider(object):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user