diff --git a/syncplay/client.py b/syncplay/client.py index 22aa708..dcc13f0 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -389,7 +389,7 @@ class SyncplayClient(object): import random random.seed() random_number = random.randrange(1000, 9999) - self.userlist.currentUser.username = "Anonymous" + str(random_number) + self.userlist.currentUser.username = "Anonymous" + str(random_number) # Not localised as this would give away locale def getUsername(self): return self.userlist.currentUser.username @@ -555,8 +555,8 @@ class SyncplayClient(object): self._userlist = userlist self._ui = ui self._warnings = { - "room-files-not-same": { - "timer": task.LoopingCall(self.__displayMessageOnOSD, "room-files-not-same", + "room-file-differences": { + "timer": task.LoopingCall(self.__displayMessageOnOSD, "room-file-differences", lambda: self._checkRoomForSameFiles(OSDOnly=True),), "displayedFor": 0, }, @@ -582,12 +582,10 @@ class SyncplayClient(object): def _checkRoomForSameFiles(self, OSDOnly): if not self._userlist.areAllFilesInRoomSame(): self._displayReadySameWarning() - if not OSDOnly: - self._ui.showMessage(getMessage("room-files-not-same"), True) - if constants.SHOW_OSD_WARNINGS and not self._warnings["room-files-not-same"]['timer'].running: - self._warnings["room-files-not-same"]['timer'].start(constants.WARNING_OSD_MESSAGES_LOOP_INTERVAL, True) - elif self._warnings["room-files-not-same"]['timer'].running: - self._warnings["room-files-not-same"]['timer'].stop() + if not OSDOnly and constants.SHOW_OSD_WARNINGS and not self._warnings["room-file-differences"]['timer'].running: + self._warnings["room-file-differences"]['timer'].start(constants.WARNING_OSD_MESSAGES_LOOP_INTERVAL, True) + elif self._warnings["room-file-differences"]['timer'].running: + self._warnings["room-file-differences"]['timer'].stop() def _checkIfYouReAloneInTheRoom(self, OSDOnly): if self._userlist.areYouAloneInRoom(): @@ -622,13 +620,14 @@ class SyncplayClient(object): if not self._client._player: return if not self._userlist.areAllFilesInRoomSame(): + fileDifferencesMessage = getMessage("room-file-differences").format(self._userlist.getFileDifferencesForRoom()) if self._userlist.currentUser.canControl(): if self._userlist.areAllUsersInRoomReady(): - osdMessage = u"{}{}{}".format(getMessage("room-files-not-same"), self._client._player.osdMessageSeparator, getMessage("all-users-ready")) + osdMessage = u"{}{}{}".format(fileDifferencesMessage, self._client._player.osdMessageSeparator, getMessage("all-users-ready")) else: - osdMessage = u"{}{}{}".format(getMessage("room-files-not-same"), self._client._player.osdMessageSeparator, getMessage("not-all-ready").format(self._userlist.usersInRoomNotReady())) + osdMessage = u"{}{}{}".format(fileDifferencesMessage, self._client._player.osdMessageSeparator, getMessage("not-all-ready").format(self._userlist.usersInRoomNotReady())) else: - osdMessage = getMessage("room-files-not-same") + osdMessage = fileDifferencesMessage elif self._userlist.areAllUsersInRoomReady(): osdMessage = getMessage("all-users-ready") else: @@ -740,20 +739,36 @@ class SyncplayUserlist(object): message += getMessage("playing-notification/room-addendum").format(room) self.ui.showMessage(message, hideFromOSD) if self.currentUser.file and not self.currentUser.isFileSame(file_) and self.currentUser.room == room: - message = getMessage("file-different-notification").format(username) - self.ui.showMessage(message, hideFromOSD) - differences = [] - differentName = not utils.sameFilename(self.currentUser.file['name'], file_['name']) - differentSize = not utils.sameFilesize(self.currentUser.file['size'], file_['size']) - differentDuration = not utils.sameFileduration(self.currentUser.file['duration'], file_['duration']) - if differentName: - differences.append("filename") - if differentSize: - differences.append("size") - if differentDuration: - differences.append("duration") - message = getMessage("file-differences-notification") + ", ".join(differences) - self.ui.showMessage(message, hideFromOSD) + message = getMessage("file-differences-notification").format(self.getFileDifferencesForUser(self.currentUser.file, file_)) + self.ui.showMessage(message, True) + + def getFileDifferencesForUser(self, currentUserFile, otherUserFile): + differences = [] + differentName = not utils.sameFilename(currentUserFile['name'], otherUserFile['name']) + differentSize = not utils.sameFilesize(currentUserFile['size'], otherUserFile['size']) + differentDuration = not utils.sameFileduration(currentUserFile['duration'], otherUserFile['duration']) + if differentName: differences.append(getMessage("file-difference-filename")) + if differentSize: differences.append(getMessage("file-difference-filesize")) + if differentDuration: differences.append(getMessage("file-difference-duration")) + return ", ".join(differences) + + def getFileDifferencesForRoom(self): + differences = [] + differentName = False + differentSize = False + differentDuration = False + for otherUser in self._users.itervalues(): + if otherUser.room == self.currentUser.room: + if not utils.sameFilename(self.currentUser.file['name'], otherUser.file['name']): + differentName = True + if not utils.sameFilesize(self.currentUser.file['size'], otherUser.file['size']): + differentSize = True + if not utils.sameFileduration(self.currentUser.file['duration'], otherUser.file['duration']): + differentDuration = True + if differentName: differences.append(getMessage("file-difference-filename")) + if differentSize: differences.append(getMessage("file-difference-filesize")) + if differentDuration: differences.append(getMessage("file-difference-duration")) + return ", ".join(differences) def addUser(self, username, room, file_, noMessage=False, isController=None, isReady=None): if username == self.currentUser.username: diff --git a/syncplay/messages.py b/syncplay/messages.py index 58fd9cd..2dadd01 100755 --- a/syncplay/messages.py +++ b/syncplay/messages.py @@ -7,7 +7,7 @@ en = { # Client notifications "config-cleared-notification" : "Settings cleared. Changes will be saved when you store a valid configuration.", - "relative-config-notification" : "Loaded relative configuration file(s): {}", + "relative-config-notification" : u"Loaded relative configuration file(s): {}", "connection-attempt-notification" : "Attempting to connect to {}:{}", # Port, IP "reconnection-attempt-notification" : "Connection with server lost, attempting to reconnect", @@ -21,36 +21,39 @@ en = { "slowdown-notification" : "Slowing down due to time difference with <{}>", # User "revert-notification" : "Reverting speed back to normal", - "pause-notification" : "<{}> paused", # User - "unpause-notification" : "<{}> unpaused", # User - "seek-notification" : "<{}> jumped from {} to {}", # User, from time, to time + "pause-notification" : u"<{}> paused", # User + "unpause-notification" : u"<{}> unpaused", # User + "seek-notification" : u"<{}> jumped from {} to {}", # User, from time, to time "current-offset-notification" : "Current offset: {} seconds", # Offset - "room-join-notification" : "<{}> has joined the room: '{}'", # User - "left-notification" : "<{}> has left", # User - "left-paused-notification" : "<{}> left, <{}> paused", # User who left, User who paused - "playing-notification" : "<{}> is playing '{}' ({})", # User, file, duration - "playing-notification/room-addendum" : " in room: '{}'", # Room + "room-join-notification" : u"<{}> has joined the room: '{}'", # User + "left-notification" : u"<{}> has left", # User + "left-paused-notification" : u"<{}> left, <{}> paused", # User who left, User who paused + "playing-notification" : u"<{}> is playing '{}' ({})", # User, file, duration + "playing-notification/room-addendum" : u" in room: '{}'", # Room - "not-all-ready" : "Not ready: {}", # Usernames - "all-users-ready" : "Everyone is ready", + "not-all-ready" : u"Not ready: {}", # Usernames + "all-users-ready" : u"Everyone is ready", "identifying-as-controller-notification" : u"Identifying as room controller with password '{}'...", "failed-to-identify-as-controller-notification" : u"<{}> failed to identify as a room controller.", "authenticated-as-controller-notification" : u"<{}> authenticated as a room controller", "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): ", - "room-files-not-same" : "Not all files the same", - "alone-in-the-room": "You're alone in the room", + "file-differences-notification" : u"Your file differs in the following way(s): {}", # Differences + "room-file-differences" : u"File differences: {}", # File differences (filename, size, and/or duration) + "file-difference-filename" : u"name", + "file-difference-filesize" : u"size", + "file-difference-duration" : u"duration", + "alone-in-the-room": u"You're alone in the room", - "different-filesize-notification" : " (their file size is different from yours!)", - "userlist-playing-notification" : "{} is playing:", #Username - "file-played-by-notification" : "File: {} is being played by:", # File - "no-file-played-notification" : "{} is not playing a file", # Username + "different-filesize-notification" : u" (their file size is different from yours!)", + "userlist-playing-notification" : u"{} is playing:", #Username + "file-played-by-notification" : u"File: {} is being played by:", # File + "no-file-played-notification" : u"{} is not playing a file", # Username "notplaying-notification" : "People who are not playing any file:", - "userlist-room-notification" : "In room '{}':", # Room + "userlist-room-notification" : u"In room '{}':", # Room "userlist-file-notification" : "File", "controller-userlist-userflag" : "Controller", "ready-userlist-userflag" : "Ready", @@ -364,8 +367,11 @@ ru = { "authenticated-as-controller-notification" : u"<{}> authenticated as a room controller", # TODO: Translate into Russian "file-different-notification" : u"Вероятно, файл, который Вы смотрите, отличается от того, который смотрит <{}>.", # User - "file-differences-notification" : u"Ваш файл отличается: ", - "room-files-not-same" : u"Не все пользователи в этой комнате смотрят один и тот же файл.", # TODO: Make shorter if possible (to fit better on OSD), e.g. say "Not all files same" or "File mismatch" + "file-differences-notification" : u"Ваш файл отличается: {}", # Differences + "room-file-differences" : u"File differences: {}", # File differences (filename, size, and/or duration) + "file-difference-filename" : u"name", # TODO: Translate into Russian + "file-difference-filesize" : u"size", # TODO: Translate into Russian + "file-difference-duration" : u"duration", # TODO: Translate into Russian "alone-in-the-room" : u"В этой комнате кроме Вас никого нет.", "different-filesize-notification" : u" (размер Вашего файла не совпадает с размером их файла!)", @@ -686,8 +692,11 @@ de = { "authenticated-as-controller-notification" : u"<{}> authentifizierte sich als Raumleiter", "file-different-notification" : u"Deine Datei scheint sich von <{}>s zu unterscheiden", # User - "file-differences-notification" : u"Deine Datei unterscheidet sich auf folgende Art: ", - "room-files-not-same" : u"Nicht alle Dateien im Raum sind gleich", # TODO: Make shorter if possible (to fit better on OSD), e.g. say "Not all files same" or "File mismatch" + "file-differences-notification" : u"Deine Datei unterscheidet sich auf folgende Art: {}", + "room-file-differences" : u"File differences: {}", # File differences (filename, size, and/or duration) # TODO: Translate into German + "file-difference-filename" : u"name", # TODO: Translate into German + "file-difference-filesize" : u"size", # TODO: Translate into German + "file-difference-duration" : u"duration", # TODO: Translate into German "alone-in-the-room": u"Du bist alleine im Raum", "different-filesize-notification" : u" (ihre Dateigröße ist anders als deine!)",