Skip to content

Commit

Permalink
Readiness override (initial implementation)
Browse files Browse the repository at this point in the history
  • Loading branch information
Et0h committed Feb 2, 2024
1 parent 793804e commit 686de33
Show file tree
Hide file tree
Showing 19 changed files with 244 additions and 26 deletions.
16 changes: 13 additions & 3 deletions syncplay/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,9 @@ def checkForFeatureSupport(self, featureList):
"maxChatMessageLength": constants.FALLBACK_MAX_CHAT_MESSAGE_LENGTH,
"maxUsernameLength": constants.FALLBACK_MAX_USERNAME_LENGTH,
"maxRoomNameLength": constants.FALLBACK_MAX_ROOM_NAME_LENGTH,
"maxFilenameLength": constants.FALLBACK_MAX_FILENAME_LENGTH
"maxFilenameLength": constants.FALLBACK_MAX_FILENAME_LENGTH,
"setOthersReadiness": utils.meetsMinVersion(self.serverVersion, constants.SET_OTHERS_READINESS_MIN_VERSION)
}

if featureList:
self.serverFeatures.update(featureList)
if not utils.meetsMinVersion(self.serverVersion, constants.SHARED_PLAYLIST_MIN_VERSION):
Expand Down Expand Up @@ -730,6 +730,7 @@ def getFeatures(self):
features["readiness"] = True
features["managedRooms"] = True
features["persistentRooms"] = True
features["setOthersReadiness"] = True

return features

Expand Down Expand Up @@ -932,6 +933,10 @@ def sendChat(self, message):
message = utils.truncateText(message, constants.MAX_CHAT_MESSAGE_LENGTH)
self._protocol.sendChatMessage(message)

@requireServerFeature("setOthersReadiness")
def setOthersReadiness(self, username, newReadyStatus):
self._protocol.setReady(newReadyStatus, True, username)

def sendFeaturesUpdate(self, features):
self._protocol.sendFeaturesUpdate(features)

Expand Down Expand Up @@ -1032,14 +1037,19 @@ def changeReadyState(self, newState, manuallyInitiated=True):
if newState != oldState:
self.toggleReady(manuallyInitiated)

def setReady(self, username, isReady, manuallyInitiated=True):
def setReady(self, username, isReady, manuallyInitiated=True, setBy=None):
oldReadyState = self.userlist.isReady(username)
if oldReadyState is None:
oldReadyState = False
self.userlist.setReady(username, isReady)
self.ui.userListChange()
if oldReadyState != isReady:
self._warnings.checkReadyStates()
if setBy:
if isReady:
self.ui.showMessage(getMessage("other-set-as-ready-notification").format(username, setBy))
else:
self.ui.showMessage(getMessage("other-set-as-not-ready-notification").format(username, setBy))

@requireServerFeature("managedRooms")
def setUserFeatures(self, username, features):
Expand Down
3 changes: 3 additions & 0 deletions syncplay/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def getValueForOS(constantDict):
COMMANDS_SELECT = ['select', 'qs']
COMMANDS_DELETE = ['delete', 'd', 'qd']
COMMANDS_NEXT = ["next", "qn"]
COMMANDS_SETREADY = ['setready', 'sr']
COMMANDS_SETNOTREADY = ['setready', 'snr']
MPC_MIN_VER = "1.6.4"
MPC_BE_MIN_VER = "1.5.2.3123"
VLC_MIN_VERSION = "2.2.1"
Expand All @@ -142,6 +144,7 @@ def getValueForOS(constantDict):
SHARED_PLAYLIST_MIN_VERSION = "1.4.0"
CHAT_MIN_VERSION = "1.5.0"
FEATURE_LIST_MIN_VERSION = "1.5.0"
SET_OTHERS_READINESS_MIN_VERSION = "1.7.2"

IINA_PATHS = ['/Applications/IINA.app/Contents/MacOS/IINA']
MPC_PATHS = [
Expand Down
11 changes: 11 additions & 0 deletions syncplay/messages_de.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
"authenticated-as-controller-notification": "{} authentifizierte sich als Raumleiter",
"created-controlled-room-notification": "Gesteuerten Raum „{}“ mit Passwort „{}“ erstellt. Bitte diese Informationen für die Zukunft aufheben! \n\nIn managed rooms everyone is kept in sync with the room operator(s) who are the only ones who can pause, unpause, seek, and change the playlist.\n\nYou should ask regular viewers to join the room '{}' but the room operators can join the room '{}' to automatically authenticate themselves.", # RoomName, operatorPassword, roomName, roomName:operatorPassword # TODO: Translate

"other-set-as-ready-notification": "{} was set as ready by {}", # User set as ready, user who set them as ready # TODO: Translate
"other-set-as-not-ready-notification": "{} was set as not ready by {}", # User set as not ready, user who set them as not ready # TODO: Translate

"file-different-notification": "Deine Datei scheint sich von {}s zu unterscheiden", # User
"file-differences-notification": "Deine Datei unterscheidet sich auf folgende Art: {}",
"room-file-differences": "Unterschiedlich in: {}", # File differences (filename, size, and/or duration)
Expand Down Expand Up @@ -98,6 +101,8 @@
"commandlist-notification/offset": "\to[+-]duration - offset local playback by the given duration (in seconds or min:sec) from the server seek position - this is a deprecated feature",
"commandlist-notification/help": "\th - Diese Hilfe",
"commandlist-notification/toggle": "\tt - Bereitschaftsanzeige umschalten",
"commandlist-notification/setready": "\tsr [name] - sets user as ready", # TODO: Translate
"commandlist-notification/setnotready": "\tsn [name] - sets user as not ready", # TODO: Translate
"commandlist-notification/create": "\tc [name] - erstelle zentral gesteuerten Raum mit dem aktuellen Raumnamen",
"commandlist-notification/auth": "\ta [password] - authentifiziere als Raumleiter mit Passwort",
"commandlist-notification/chat": "\tch [message] - Chatnachricht an einem Raum senden",
Expand Down Expand Up @@ -158,6 +163,7 @@
"feature-chat": "Chat", # used for not-supported-by-server-error
"feature-readiness": "Bereitschaftsstatus", # used for not-supported-by-server-error
"feature-managedRooms": "Zentral gesteuerte Räume", # used for not-supported-by-server-error
"feature-setOthersReadiness": "readiness override", # used for not-supported-by-server-error # TODO: Translate

"not-supported-by-server-error": "Diese Funktion wird vom Server nicht unterstützt. Es wird ein Server mit Syncplay Version {}+ benötigt, aktuell verwendet wird jedoch Version {}.", # minVersion, serverVersion
"shared-playlists-not-supported-by-server-error": "Die Geteilte-Playlists-Funktion wird von diesem Server eventuell nicht unterstützt. Um ein korrektes Funktionieren sicherzustellen wird ein Server mit Syncplay Version {}+ benötigt, aktuell verwendet wird jedoch Version {}.", # minVersion, serverVersion
Expand Down Expand Up @@ -474,6 +480,8 @@
# Server messages to client
"new-syncplay-available-motd-message": "Du nutzt Syncplay Version {}, aber es gibt eine neuere Version auf https://syncplay.pl", # ClientVersion
"persistent-rooms-notice": "NOTICE: This server uses persistent rooms, which means that the playlist information is stored between playback sessions. If you want to create a room where information is not saved then put -temp at the end of the room name.", # TO DO: Translate - NOTE: Do not translate the word -temp
"ready-chat-message": "I have set {} as ready.", # User # TODO: Translate
"not-ready-chat-message": "I have set {} as not ready.", # User # TODO: Translate

# Server notifications
"welcome-server-notification": "Willkommen zum Syncplay-Server, v. {0}", # version
Expand Down Expand Up @@ -537,6 +545,9 @@
"openusersstream-menu-label": "{}s Stream öffnen", # [username]'s
"openusersfile-menu-label": "{}s Datei öffnen", # [username]'s

"setasready-menu-label": "Set {} as ready", # [Username] # TODO: Translate
"setasnotready-menu-label": "Set {} as not ready", # [Username] # TODO: Translate

"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“",

Expand Down
11 changes: 11 additions & 0 deletions syncplay/messages_en.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
"authenticated-as-controller-notification": "{} authenticated as a room operator",
"created-controlled-room-notification": "Created managed room '{}' with password '{}'. Please save this information for future reference!\n\nIn managed rooms everyone is kept in sync with the room operator(s) who are the only ones who can pause, unpause, seek, and change the playlist.\n\nYou should ask regular viewers to join the room '{}' but the room operators can join the room '{}' to automatically authenticate themselves.", # RoomName, operatorPassword, roomName, roomName:operatorPassword

"other-set-as-ready-notification": "{} was set as ready by {}", # User set as ready, user who set them as ready
"other-set-as-not-ready-notification": "{} was set as not ready by {}", # User set as not ready, user who set them as not ready

"file-different-notification": "File you are playing appears to be different from {}'s", # User
"file-differences-notification": "Your file differs in the following way(s): {}", # Differences
"room-file-differences": "File differences: {}", # File differences (filename, size, and/or duration)
Expand Down Expand Up @@ -98,6 +101,8 @@
"commandlist-notification/offset": "\to[+-]duration - offset local playback by the given duration (in seconds or min:sec) from the server seek position - this is a deprecated feature",
"commandlist-notification/help": "\th - this help",
"commandlist-notification/toggle": "\tt - toggles whether you are ready to watch or not",
"commandlist-notification/setready": "\tsr [name] - sets user as ready",
"commandlist-notification/setnotready": "\tsn [name] - sets user as not ready",
"commandlist-notification/create": "\tc [name] - create managed room using name of current room",
"commandlist-notification/auth": "\ta [password] - authenticate as room operator with operator password",
"commandlist-notification/chat": "\tch [message] - send a chat message in a room",
Expand Down Expand Up @@ -158,6 +163,7 @@
"feature-chat": "chat", # used for not-supported-by-server-error
"feature-readiness": "readiness", # used for not-supported-by-server-error
"feature-managedRooms": "managed rooms", # used for not-supported-by-server-error
"feature-setOthersReadiness": "readiness override", # used for not-supported-by-server-error

"not-supported-by-server-error": "The {} feature is not supported by this server..", # feature
"shared-playlists-not-supported-by-server-error": "The shared playlists feature may not be supported by the server. To ensure that it works correctly requires a server running Syncplay {}+, but the server is running Syncplay {}.", # minVersion, serverVersion
Expand Down Expand Up @@ -474,6 +480,8 @@
# Server messages to client
"new-syncplay-available-motd-message": "You are using Syncplay {} but a newer version is available from https://syncplay.pl", # ClientVersion
"persistent-rooms-notice": "NOTICE: This server uses persistent rooms, which means that the playlist information is stored between playback sessions. If you want to create a room where information is not saved then put -temp at the end of the room name.", # NOTE: Do not translate the word -temp
"ready-chat-message": "I have set {} as ready.", # User
"not-ready-chat-message": "I have set {} as not ready.", # User

# Server notifications
"welcome-server-notification": "Welcome to Syncplay server, ver. {0}", # version
Expand Down Expand Up @@ -538,6 +546,9 @@
"openusersstream-menu-label": "Open {}'s stream", # [username]'s
"openusersfile-menu-label": "Open {}'s file", # [username]'s

"setasready-menu-label": "Set {} as ready", # [Username]
"setasnotready-menu-label": "Set {} as not ready", # [Username]

"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'.",

Expand Down
11 changes: 11 additions & 0 deletions syncplay/messages_eo.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
"authenticated-as-controller-notification": "{} identiĝis ĉambrestro",
"created-controlled-room-notification": "Kreis estratan ĉambron «{}» kun pasvorto «{}». Bonvolu konservi tiujn informojn osen!\n\nEn estrataj ĉambroj, ĉiu spegulas la ĉambrestrojn, kiuj estas la solaj, kiuj povas paŭzigi, malpaŭzigi, iri, kaj ŝanĝi la ludliston.\n\nVi petu ordinarajn spektantojn aliĝi la ĉambron «{}», sed ĉambrestroj povas aliĝi la ĉambron «{}» por memage aŭtentikiĝi.", # RoomName, operatorPassword, roomName, roomName:operatorPassword

"other-set-as-ready-notification": "{} was set as ready by {}", # User set as ready, user who set them as ready # TODO: Translate
"other-set-as-not-ready-notification": "{} was set as not ready by {}", # User set as not ready, user who set them as not ready # TODO: Translate

"file-different-notification": "La dosiero, kiun vi ludas, ŝajnas malsama de tiu de {}", # User
"file-differences-notification": "Via dosiero malsamas per ĉi tiuj manieroj: {}", # Differences
"room-file-differences": "Malsamoj inter dosieroj: {}", # File differences (filename, size, and/or duration)
Expand Down Expand Up @@ -100,6 +103,8 @@
"commandlist-notification/offset": "\to[+-]daŭro - fruigi lokan ludadon je la donita daŭro (en sekundoj aŭ minutoj:sekundoj), kompare al la servila pozicio – ĉi tiu kapablo ne plu estos subtenata",
"commandlist-notification/help": "\th – tiu ĉi helpilo",
"commandlist-notification/toggle": "\tt – ŝanĝas ĉu vi pretas spekti aŭ ne",
"commandlist-notification/setready": "\tsr [name] - sets user as ready", # TODO: Translate
"commandlist-notification/setnotready": "\tsn [name] - sets user as not ready", # TODO: Translate
"commandlist-notification/create": "\tc [nomo] – krei estratan ĉambron kun nomo de la nuna ĉambro",
"commandlist-notification/auth": "\ta [pasvorto] – aŭtentikiĝi ĉambrestro per ĉambrestra pasvorto",
"commandlist-notification/chat": "\tch [mesaĝo] – sendi babilan mesaĝon al ĉambro",
Expand Down Expand Up @@ -161,6 +166,7 @@
"feature-chat": "babilado", # used for not-supported-by-server-error
"feature-readiness": "preteco", # used for not-supported-by-server-error
"feature-managedRooms": "estrataj ĉambroj", # used for not-supported-by-server-error
"feature-setOthersReadiness": "readiness override", # used for not-supported-by-server-error # TODO: Translate

"not-supported-by-server-error": "La kapablo «{}» ne estas subtenata de ĉi tiu servilo.", # feature
"shared-playlists-not-supported-by-server-error": "La servilo eble ne subtenas komunajn ludlistojn. Ĝusta funkciado postulas servilon kun Syncplay {}+, sed la servilo havas nur version {}.", # minVersion, serverVersion
Expand Down Expand Up @@ -477,6 +483,8 @@
# Server messages to client
"new-syncplay-available-motd-message": "Vi uzas version {} de Syncplay, sed pli nova versio estas disponebla per https://syncplay.pl", # ClientVersion
"persistent-rooms-notice": "AVIZO: Ĉi tiu servilo uzas persistajn ĉámbrojn, kio signifas, ke la informoj pri ludlistoj konserviĝas por venontaj kunspektoj. Se vi volas krei ĉambron kie la informoj ne konserviĝas, finu la nomon de la ĉambro per «-temp».", # NOTE: Do not translate the word -temp
"ready-chat-message": "I have set {} as ready.", # User # TODO: Translate
"not-ready-chat-message": "I have set {} as not ready.", # User # TODO: Translate

# Server notifications
"welcome-server-notification": "Bonvenu al servilo de Syncplay, versio {0}", # version
Expand Down Expand Up @@ -541,6 +549,9 @@
"openusersstream-menu-label": "Malfermi elsendon de {}", # [username]'s
"openusersfile-menu-label": "Malfermi dosieron de {}", # [username]'s

"setasready-menu-label": "Set {} as ready", # [Username] # TODO: Translate
"setasnotready-menu-label": "Set {} as not ready", # [Username] # TODO: Translate

"playlist-instruction-item-message": "Metu dosieron ĉi tien por aldoni ĝin al la komuna ludlisto.",
"sharedplaylistenabled-tooltip": "Ĉambrestroj povas aldoni dosierojn al spegulata ludlisto, por ke ĉiuj povu facile spekti la saman filmon. Agordu vidaŭdaĵajn dosierojn sub «Diversaj».",

Expand Down
9 changes: 9 additions & 0 deletions syncplay/messages_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
"authenticated-as-controller-notification": "{} autentificado como operador de la sala",
"created-controlled-room-notification": "Sala administrada '{}' creada con contraseña '{}'. Por favor guarda esta información para referencias futuras!\n\nIn managed rooms everyone is kept in sync with the room operator(s) who are the only ones who can pause, unpause, seek, and change the playlist.\n\nYou should ask regular viewers to join the room '{}' but the room operators can join the room '{}' to automatically authenticate themselves.", # RoomName, operatorPassword, roomName, roomName:operatorPassword # TODO: Translate

"other-set-as-ready-notification": "{} was set as ready by {}", # User set as ready, user who set them as ready # TODO: Translate
"other-set-as-not-ready-notification": "{} was set as not ready by {}", # User set as not ready, user who set them as not ready # TODO: Translate

"file-different-notification": "El archivo que reproduces parece ser diferente al archivo de {}", # User
"file-differences-notification": "Tu archivo difiere de la(s) siguiente(s) forma(s): {}", # Differences
"room-file-differences": "Diferencias de archivo: {}", # File differences (filename, size, and/or duration)
Expand Down Expand Up @@ -98,6 +101,8 @@
"commandlist-notification/offset": "\to[+-]duration - offset local playback by the given duration (in seconds or min:sec) from the server seek position - this is a deprecated feature", # TODO: Translate
"commandlist-notification/help": "\th - esta ayuda",
"commandlist-notification/toggle": "\tt - activa/inactiva señal que estás listo para ver",
"commandlist-notification/setready": "\tsr [name] - sets user as ready", # TODO: Translate
"commandlist-notification/setnotready": "\tsn [name] - sets user as not ready", # TODO: Translate
"commandlist-notification/create": "\tc [nombre] - crear sala administrada usando el nombre de la sala actual",
"commandlist-notification/auth": "\ta [contraseña] - autentificar como operador de la sala con la contraseña de operador",
"commandlist-notification/chat": "\tch [mensaje] - enviar un mensaje en la sala",
Expand Down Expand Up @@ -158,6 +163,7 @@
"feature-chat": "chat", # used for not-supported-by-server-error
"feature-readiness": "preparación", # used for not-supported-by-server-error
"feature-managedRooms": "salas administradas", # used for not-supported-by-server-error
"feature-setOthersReadiness": "readiness override", # used for not-supported-by-server-error # TODO: Translate

"not-supported-by-server-error": "La característica {} no está soportada por este servidor..", # feature
"shared-playlists-not-supported-by-server-error": "El servidor no admite la función de listas de reproducción compartidas. Para asegurarse de que funciona correctamente, se requiere un servidor que ejecute Syncplay {}+, pero el servidor está ejecutando Syncplay {}.", # minVersion, serverVersion
Expand Down Expand Up @@ -537,6 +543,9 @@
"openusersstream-menu-label": "Abrir el flujo de {}", # [username]'s
"openusersfile-menu-label": "Abrir el archivo de {}", # [username]'s

"setasready-menu-label": "Set {} as ready", # [Username] # TODO: Translate
"setasnotready-menu-label": "Set {} as not ready", # [Username] # TODO: Translate

"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'.",

Expand Down
Loading

0 comments on commit 686de33

Please sign in to comment.