Initial code to find files for playlists
This commit is contained in:
parent
d742b04fed
commit
f9c1ad0764
@ -419,23 +419,45 @@ class SyncplayClient(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def findFilenameInDirectories(self, filename):
|
||||||
|
# TODO: Replace this with the code in gui.py
|
||||||
|
directoryList = self._config["mediaSearchDirectories"]
|
||||||
|
if filename and directoryList:
|
||||||
|
for directory in directoryList:
|
||||||
|
for root, dirs, files in os.walk(directory):
|
||||||
|
if filename in files:
|
||||||
|
return os.path.join(root,filename)
|
||||||
|
return None
|
||||||
|
|
||||||
def changeToPlaylistIndex(self, index, username = None):
|
def changeToPlaylistIndex(self, index, username = None):
|
||||||
|
path = None
|
||||||
if self._playlistIndex == index:
|
if self._playlistIndex == index:
|
||||||
return
|
return
|
||||||
|
if self._player is None:
|
||||||
|
return
|
||||||
self._playlistIndex = index
|
self._playlistIndex = index
|
||||||
if username is None and self._protocol and self._protocol.logged:
|
if username is None and self._protocol and self._protocol.logged:
|
||||||
self._protocol.setPlaylistIndex(index)
|
self._protocol.setPlaylistIndex(index)
|
||||||
elif username != self.getUsername():
|
elif username != self.getUsername():
|
||||||
|
self.ui.showMessage(u"{} changed the playlist selection".format(username))
|
||||||
# TODO: Display info about playlist file change
|
# TODO: Display info about playlist file change
|
||||||
try:
|
try:
|
||||||
filename = self._playlist[index]
|
filename = self._playlist[index]
|
||||||
# TODO: Find Path
|
if utils.isURL(filename):
|
||||||
path = 'https://www.youtube.com/watch?v=0iXX5h6Hxxs'
|
for URI in constants.SAFE_URIS:
|
||||||
|
if filename.startswith(URI):
|
||||||
|
self._player.openFile(filename)
|
||||||
|
return
|
||||||
|
self.ui.showErrorMessage(u"Could not load {} because it is not known as a safe path.".format(filename))
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
path = self.findFilenameInDirectories(filename)
|
||||||
|
# TODO: Find Path properly
|
||||||
if path:
|
if path:
|
||||||
self._player.openFile(path)
|
self._player.openFile(path)
|
||||||
else:
|
else:
|
||||||
# TODO: Notify user about file not found
|
self.ui.showErrorMessage(u"Could not find file {} for playlist switch!".format(filename))
|
||||||
pass
|
return
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@ -181,4 +181,5 @@ SYNCPLAY_UPDATE_URL = u"http://syncplay.pl/checkforupdate?{}" # Params
|
|||||||
SYNCPLAY_DOWNLOAD_URL = "http://syncplay.pl/download/"
|
SYNCPLAY_DOWNLOAD_URL = "http://syncplay.pl/download/"
|
||||||
SYNCPLAY_PUBLIC_SERVER_LIST_URL = u"http://syncplay.pl/listpublicservers?{}" # Params
|
SYNCPLAY_PUBLIC_SERVER_LIST_URL = u"http://syncplay.pl/listpublicservers?{}" # Params
|
||||||
|
|
||||||
PRIVATE_FILE_FIELDS = ["path"]
|
PRIVATE_FILE_FIELDS = ["path"]
|
||||||
|
SAFE_URIS = [u"http://www.youtube.com/", u"https://www.youtube.com/"] # TODO: Move into config
|
||||||
Loading…
x
Reference in New Issue
Block a user