Tweaks, refactoring and fixes for console improvements (#327)
This commit is contained in:
parent
24beaebbd1
commit
10981abb88
@ -1892,9 +1892,12 @@ class SyncplayPlaylist():
|
||||
|
||||
def deleteAtIndex(self, index):
|
||||
new_playlist = self._playlist.copy()
|
||||
if index < len(new_playlist):
|
||||
if index >= 0 and index < len(new_playlist):
|
||||
del new_playlist[index]
|
||||
self.changePlaylist(new_playlist)
|
||||
else:
|
||||
raise TypeError("Invalid index")
|
||||
|
||||
|
||||
@needsSharedPlaylistsEnabled
|
||||
def undoPlaylistChange(self):
|
||||
|
||||
@ -512,4 +512,7 @@ de = {
|
||||
|
||||
"playlist-instruction-item-message": "Zieh eine Datei hierher, um sie zur geteilten Playlist hinzuzufügen.",
|
||||
"sharedplaylistenabled-tooltip": "Raumleiter können Dateien zu einer geteilten Playlist hinzufügen und es so erleichtern, gemeinsam das Gleiche zu gucken. Konfiguriere Medienverzeichnisse unter „Diverse“",
|
||||
|
||||
"playlist-empty-error": "Playlist is currently empty.", # TO DO: Translate
|
||||
"playlist-invalid-index-error": "Invalid playlist index", # TO DO: Translate
|
||||
}
|
||||
|
||||
@ -180,6 +180,7 @@ en = {
|
||||
|
||||
"load-playlist-from-file-argument": "loads playlist from text file (one entry per line)",
|
||||
|
||||
|
||||
# Client labels
|
||||
"config-window-title": "Syncplay configuration",
|
||||
|
||||
@ -512,4 +513,7 @@ en = {
|
||||
|
||||
"playlist-instruction-item-message": "Drag file here to add it to the shared playlist.",
|
||||
"sharedplaylistenabled-tooltip": "Room operators can add files to a synced playlist to make it easy for everyone to watching the same thing. Configure media directories under 'Misc'.",
|
||||
|
||||
"playlist-empty-error": "Playlist is currently empty.",
|
||||
"playlist-invalid-index-error": "Invalid playlist index",
|
||||
}
|
||||
|
||||
@ -512,4 +512,7 @@ es = {
|
||||
|
||||
"playlist-instruction-item-message": "Desplazar aquí el archivo para agregarlo a la lista de reproducción compartida.",
|
||||
"sharedplaylistenabled-tooltip": "Los operadores de la sala pueden agregar archivos a una lista de reproducción sincronizada, para que visualizar la misma cosa sea más sencillo para todos. Configurar directorios multimedia en 'Misc'.",
|
||||
|
||||
"playlist-empty-error": "Playlist is currently empty.", # TO DO: Translate
|
||||
"playlist-invalid-index-error": "Invalid playlist index", # TO DO: Translate
|
||||
}
|
||||
|
||||
@ -512,4 +512,7 @@ it = {
|
||||
|
||||
"playlist-instruction-item-message": "Trascina qui i file per aggiungerli alla playlist condivisa.",
|
||||
"sharedplaylistenabled-tooltip": "Gli operatori della stanza possono aggiungere i file a una playlist sincronizzata per garantire che tutti i partecipanti stiano guardando la stessa cosa. Configura le cartelle multimediali alla voce 'Miscellanea'.",
|
||||
|
||||
"playlist-empty-error": "Playlist is currently empty.", # TO DO: Translate
|
||||
"playlist-invalid-index-error": "Invalid playlist index", # TO DO: Translate
|
||||
}
|
||||
|
||||
@ -512,4 +512,7 @@ pt_BR = {
|
||||
|
||||
"playlist-instruction-item-message": "Arraste um arquivo aqui para adicioná-lo à playlist compartilhada.",
|
||||
"sharedplaylistenabled-tooltip": "Operadores da sala podem adicionar arquivos para a playlist compartilhada para tornar mais fácil para todo mundo assistir a mesma coisa. Configure os diretórios de mídia em 'Miscelânea'.",
|
||||
|
||||
"playlist-empty-error": "Playlist is currently empty.", # TO DO: Translate
|
||||
"playlist-invalid-index-error": "Invalid playlist index", # TO DO: Translate
|
||||
}
|
||||
|
||||
@ -512,4 +512,7 @@ pt_PT = {
|
||||
|
||||
"playlist-instruction-item-message": "Arraste um ficheiro aqui para adicioná-lo à playlist compartilhada.",
|
||||
"sharedplaylistenabled-tooltip": "Operadores da sala podem adicionar ficheiros para a playlist compartilhada para tornar mais fácil para todo mundo assistir a mesma coisa. Configure os pastas de mídia em 'Miscelânea'.",
|
||||
|
||||
"playlist-empty-error": "Playlist is currently empty.", # TO DO: Translate
|
||||
"playlist-invalid-index-error": "Invalid playlist index", # TO DO: Translate
|
||||
}
|
||||
|
||||
@ -513,4 +513,7 @@ ru = {
|
||||
|
||||
"playlist-instruction-item-message": "Перетащите сюда файлы, чтобы добавить их в общий список.",
|
||||
"sharedplaylistenabled-tooltip": "Оператор комнаты может добавлять файлы в список общего воспроизведения для удобного совместного просмотра. Папки воспроизведения настраиваются во вкладке 'Файл'.",
|
||||
|
||||
"playlist-empty-error": "Playlist is currently empty.", # TO DO: Translate
|
||||
"playlist-invalid-index-error": "Invalid playlist index", # TO DO: Translate
|
||||
}
|
||||
|
||||
@ -24,11 +24,6 @@ class ConsoleUI(threading.Thread):
|
||||
self._syncplayClient = client
|
||||
|
||||
def addFileToPlaylist(self, file):
|
||||
if not isURL(file):
|
||||
if not self._syncplayClient.fileSwitch.findFilepath(file):
|
||||
print(f"{file} is not in any media directory")
|
||||
return
|
||||
|
||||
self._syncplayClient.playlist.addToPlaylist(file)
|
||||
|
||||
def drop(self):
|
||||
@ -206,24 +201,27 @@ class ConsoleUI(threading.Thread):
|
||||
if i is not None and i in range(len(playlist_elements)):
|
||||
playlist_elements[i] = " *" + playlist_elements[i]
|
||||
|
||||
print(*playlist_elements, sep='\n')
|
||||
self.showMessage("\n".join(playlist_elements), True)
|
||||
else:
|
||||
print("playlist is currently empty.")
|
||||
self.showMessage(getMessage("playlist-empty-error"), True)
|
||||
elif command.group('command') in constants.COMMANDS_SELECT:
|
||||
try:
|
||||
index = int(command.group('parameter').strip()) - 1
|
||||
|
||||
if index < 0 or index >= len(self._syncplayClient.playlist._playlist):
|
||||
raise TypeError("Invalid playlist index")
|
||||
self._syncplayClient.playlist.changeToPlaylistIndex(index, resetPosition=True)
|
||||
self._syncplayClient.rewindFile()
|
||||
|
||||
except TypeError:
|
||||
print("invalid index")
|
||||
except (TypeError, AttributeError):
|
||||
self.showErrorMessage(getMessage("playlist-invalid-index-error"))
|
||||
elif command.group('command') in constants.COMMANDS_DELETE:
|
||||
try:
|
||||
index = int(command.group('parameter').strip()) - 1
|
||||
self._syncplayClient.playlist.deleteAtIndex(index)
|
||||
|
||||
except TypeError:
|
||||
print("invalid index")
|
||||
except (TypeError, AttributeError):
|
||||
self.showErrorMessage(getMessage("playlist-invalid-index-error"))
|
||||
|
||||
else:
|
||||
if self._tryAdvancedCommands(data):
|
||||
|
||||
@ -1924,7 +1924,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self.playlist.setPlaylistIndexFilename(filename)
|
||||
|
||||
def addFileToPlaylist(self, filePath, index=-1):
|
||||
if not isURL:
|
||||
if not isURL(filePath):
|
||||
self.removePlaylistNote()
|
||||
filename = os.path.basename(filePath)
|
||||
if self.noPlaylistDuplicates(filename):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user