mirror of
https://github.com/Syncplay/syncplay
synced 2025-02-15 10:27:09 +00:00
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
|
||||
AUTOPLAY_DELAY = 3.0
|
||||
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
|
||||
LAST_PAUSED_DIFF_THRESHOLD = 2
|
||||
FILENAME_STRIP_REGEX = u"[-~_\.\[\](): ]"
|
||||
|
@ -135,6 +135,7 @@ en = {
|
||||
"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
|
||||
"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
|
||||
"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"Некорректное смещение",
|
||||
|
||||
"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
|
||||
"argument-description" : u'Решение для синхронного воспроизведения в VLC, MPlayer или MPC-HC через Интернет.',
|
||||
@ -859,6 +861,7 @@ de = {
|
||||
"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
|
||||
"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
|
||||
"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
|
||||
else:
|
||||
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
|
||||
elif currentPath:
|
||||
currentDirectory = os.path.dirname(currentPath)
|
||||
@ -301,7 +310,15 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self._syncplayClient._player.openFile(filename)
|
||||
else:
|
||||
currentPath = self._syncplayClient.userlist.currentUser.file["path"] if self._syncplayClient.userlist.currentUser.file else None
|
||||
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:
|
||||
self._syncplayClient._player.openFile(pathFound)
|
||||
elif currentPath:
|
||||
@ -907,6 +924,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
def __init__(self):
|
||||
super(MainWindow, self).__init__()
|
||||
self._syncplayClient = None
|
||||
self.folderSearchEnabled = True
|
||||
self.QtGui = QtGui
|
||||
if sys.platform.startswith('win'):
|
||||
self.resourcespath = utils.findWorkingDir() + "\\resources\\"
|
||||
|
@ -11,6 +11,8 @@ import random
|
||||
import string
|
||||
import urllib
|
||||
|
||||
folderSearchEnabled = True
|
||||
|
||||
def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, logger=None):
|
||||
"""Retry calling the decorated function using an exponential backoff.
|
||||
|
||||
@ -249,11 +251,13 @@ def convertMultilineStringToList(multilineString):
|
||||
|
||||
def findFilenameInDirectories(filename, directoryList):
|
||||
if filename and directoryList:
|
||||
startTime = time.time()
|
||||
for directory in directoryList:
|
||||
for root, dirs, files in os.walk(directory):
|
||||
candidatePath = os.path.join(root,filename)
|
||||
if os.path.isfile(candidatePath):
|
||||
return candidatePath
|
||||
if filename in files:
|
||||
return os.path.join(root,filename)
|
||||
if time.time() - startTime > constants.FOLDER_SEARCH_TIMEOUT:
|
||||
raise IOError(getMessage("folder-search-timeout-error").format(directory))
|
||||
return None
|
||||
|
||||
class RoomPasswordProvider(object):
|
||||
|
Loading…
Reference in New Issue
Block a user