Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed crashes when trying to open YouTube videos with emojis #328

Merged
merged 4 commits into from Aug 6, 2020

Conversation

borislav-draganov
Copy link
Contributor

@borislav-draganov borislav-draganov commented Jun 22, 2020

Noticed that when I try to sync YouTube videos on MPC with youtube-dl.

If the video title contains emojis it starts disconnecting and reconnecting infinetely.

Stacktrace:

Traceback (most recent call last):
  File "C:\Users\VIKTOR\AppData\Local\Programs\Python\Python38\lib\site-packages\twisted\python\log.py", line 103, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "C:\Users\VIKTOR\AppData\Local\Programs\Python\Python38\lib\site-packages\twisted\python\log.py", line 86, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "C:\Users\VIKTOR\AppData\Local\Programs\Python\Python38\lib\site-packages\twisted\python\context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "C:\Users\VIKTOR\AppData\Local\Programs\Python\Python38\lib\site-packages\twisted\python\context.py", line 85, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "D:\syncplayGit\syncplay\syncplay\vendor\qt5reactor.py", line 153, in _read
    why = w.doRead()
  File "C:\Users\VIKTOR\AppData\Local\Programs\Python\Python38\lib\site-packages\twisted\internet\tcp.py", line 243, in doRead
    return self._dataReceived(data)
  File "C:\Users\VIKTOR\AppData\Local\Programs\Python\Python38\lib\site-packages\twisted\internet\tcp.py", line 249, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "C:\Users\VIKTOR\AppData\Local\Programs\Python\Python38\lib\site-packages\twisted\internet\endpoints.py", line 132, in dataReceived
    return self._wrappedProtocol.dataReceived(data)
  File "C:\Users\VIKTOR\AppData\Local\Programs\Python\Python38\lib\site-packages\twisted\protocols\basic.py", line 572, in dataReceived
    why = self.lineReceived(line)
  File "D:\syncplayGit\syncplay\syncplay\protocols.py", line 55, in lineReceived
    self.handleMessages(messages)
  File "D:\syncplayGit\syncplay\syncplay\protocols.py", line 26, in handleMessages
    self.handleSet(message[1])
  File "D:\syncplayGit\syncplay\syncplay\protocols.py", line 175, in handleSet
    self._SetUser(values)
  File "D:\syncplayGit\syncplay\syncplay\protocols.py", line 167, in _SetUser
    self._client.userlist.modUser(username, room, file_)
  File "D:\syncplayGit\syncplay\syncplay\client.py", line 1372, in modUser
    self.__displayModUserMessage(username, room, file_, user, oldRoom)
  File "D:\syncplayGit\syncplay\syncplay\client.py", line 1362, in __displayModUserMessage
    self.__showUserChangeMessage(username, room, file_, oldRoom)
  File "D:\syncplayGit\syncplay\syncplay\client.py", line 1290, in __showUserChangeMessage
    self.ui.showMessage(message, hideFromOSD)
  File "D:\syncplayGit\syncplay\syncplay\client.py", line 1581, in showMessage
    self.showOSDMessage(message, duration=constants.OSD_DURATION, OSDType=OSDType, mood=mood)
  File "D:\syncplayGit\syncplay\syncplay\client.py", line 1611, in showOSDMessage
    self._client._player.displayMessage(message, int(duration * 1000), OSDType, mood)
  File "D:\syncplayGit\syncplay\syncplay\players\mpc.py", line 416, in displayMessage
    self._mpcApi.sendOsd(message, constants.MPC_OSD_POSITION, duration)
  File "D:\syncplayGit\syncplay\syncplay\players\mpc.py", line 94, in sendOsd
    cmessage.strMsg = message
builtins.ValueError: string too long (111, maximum length 109)

Added filter for non-ASCII characters to solve the issue.

@borislav-draganov
Copy link
Contributor Author

borislav-draganov commented Jun 23, 2020

I remembered a friend had the same issue with VLC (on Windows) so that's why I updated it to include all players.

Want me to have only for MPC-HC?

@Et0h
Copy link
Contributor

Et0h commented Jun 27, 2020

I've able to reproduce on MPC-HC (64-bit) 1.7.13 on Windows 10 by sending the following chat message: 😂😂😂😂😂😂 - It generates the error: builtins.ValueError: string too long (19, maximum length 14).

The change you proposed means it prints nothing at all when I send those emojis, but alternatively you can change ('strMsg', ctypes.c_wchar * (len(message) + 1)) in mpc.py to ('strMsg', ctypes.c_wchar * (len(message.encode('utf-8')) + 1)) to fix it. Does that solve the issue for you?

I've not been able to reproduce the issue on VLC Maybe your friend could provide specific reproduction instructiong, including which version of VLC and Syncplay they are using.

@Et0h Et0h merged commit be92ff8 into Syncplay:master Aug 6, 2020
2 checks passed
@Et0h
Copy link
Contributor

Et0h commented Aug 6, 2020

Seems like the issue is now resolved 👍

albertosottile pushed a commit to albertosottile/syncplay that referenced this pull request Sep 30, 2020
…cplay#328)

* Fixed crashes when trying to open YouTube videos with emojis
albertosottile pushed a commit to albertosottile/syncplay that referenced this pull request Sep 30, 2020
…cplay#328)

* Fixed crashes when trying to open YouTube videos with emojis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants