rsp4jack / now_playing

OBS Script to display now playing
18 stars 5 forks source link

Display error with NetEase Cloud Music #8

Closed GirlKiller512 closed 6 months ago

GirlKiller512 commented 6 months ago

The music title is displayed incorrectly if it includes 1 or more "-" with no spaces next to "-". Display text setting: %title - %artist Examples: image image image image image image

If the music title includes "-" with 1 space on both sides of "-" or only the music artist includes "-" then it is displayed with no errors. Display text setting: %title - %artist Examples: image image image image image image

rsp4jack commented 6 months ago

Sounds interesting. Could you give some examples with NCM window title presented?

GirlKiller512 commented 6 months ago

These are the window titles of the music above. image image image image image image

In other words, the music with a title including "-" may cause display errors.

GirlKiller512 commented 6 months ago

If I change the display text setting to %artist - %title, the text becomes mess. image image

rsp4jack commented 6 months ago

I do not think there is a simple way to fix this.

Using SMTC should work (not implemented so far 😭), but it needs extra setup (winrt requires Python 3.7 or above, but OBS supports only Python 3.6)

GirlKiller512 commented 6 months ago

Let's leave the issue open until a solution is found.

rsp4jack commented 6 months ago

Edit: I found the latest OBS supports Python 3.6 to 3.10. SMTC support is coming soon 🎉

GirlKiller512 commented 6 months ago

Yeah, I also found that OBS 30.1.0 supports Python 3.6-3.10 from its official website last night. image

rsp4jack commented 6 months ago

I think it works now. Just use SMTC capture only and everything will be fine 😺

This also breaks compatibility for older Windows versions (only Windows 10 and 11 support SMTC now)

rsp4jack commented 6 months ago

BTW, SMTC seems to be slow and sometimes it will time out. I think that is normal unless every SMTC query operation is timed out.

GirlKiller512 commented 6 months ago

winrt-Windows.Foundation and winrt-Windows.Media.Control seem to require Python 3.9+ so I only tested the script with 3.9 and 3.10. All dependencies have been installed on both versions.

On Python 3.10, the script can be loaded but it keeps showing errors every 1 second in the script log. Settings: image

[now_playing.py] [18:14:35] [MainThread/DEBUG]: [proactor_events]: Using proactor: IocpProactor
[now_playing.py] [18:14:35] [MainThread/DEBUG]: [now_playing]: script_defaults(<Swig Object of type 'obs_data_t *' at 0x0000029EBD878F00>)
[now_playing.py] [18:14:35] [MainThread/DEBUG]: [now_playing]: script_description()
[now_playing.py] [18:14:35] [MainThread/INFO]: [now_playing]: script_load()
[now_playing.py] [18:14:35] [MainThread/DEBUG]: [now_playing]: script_update(<Swig Object of type 'obs_data_t *' at 0x0000029EBD878F00>)
[now_playing.py] [18:14:37] [MainThread/DEBUG]: [now_playing]: script_properties()
[now_playing.py] [18:14:37] [MainThread/INFO]: [now_playing]: locale: zh-CN
[now_playing.py] [18:14:39] [MainThread/DEBUG]: [now_playing]: script_update(<Swig Object of type 'obs_data_t *' at 0x0000029EBEDC98F0>)
[now_playing.py] [18:14:39] [MainThread/DEBUG]: [now_playing]: Timer started
[Unknown Script] [18:14:40] [nowplaying_eventloop/DEBUG]: [now_playing]: smtcCaptureAsync takes 0.005567073822021484s
[Unknown Script] [18:14:40] [nowplaying_eventloop/DEBUG]: [now_playing]: doUpdate: []
[Unknown Script] [18:14:40] [nowplaying_eventloop/ERROR]: [now_playing]: onUpdate error
[Unknown Script] Traceback (most recent call last):
[Unknown Script]   File "D:\Documents/Downloads\now_playing.py", line 308, in doUpdate
[Unknown Script]     update_song(data[0])
[Unknown Script] IndexError: list index out of range
[Unknown Script] [18:14:41] [nowplaying_eventloop/DEBUG]: [now_playing]: smtcCaptureAsync takes 0.002000570297241211s
[Unknown Script] [18:14:41] [nowplaying_eventloop/DEBUG]: [now_playing]: doUpdate: []
[Unknown Script] [18:14:41] [nowplaying_eventloop/ERROR]: [now_playing]: onUpdate error
[Unknown Script] Traceback (most recent call last):
[Unknown Script]   File "D:\Documents/Downloads\now_playing.py", line 308, in doUpdate
[Unknown Script]     update_song(data[0])
[Unknown Script] IndexError: list index out of range
[Unknown Script] [18:14:42] [nowplaying_eventloop/DEBUG]: [now_playing]: smtcCaptureAsync takes 0.002012968063354492s
[Unknown Script] [18:14:42] [nowplaying_eventloop/DEBUG]: [now_playing]: doUpdate: []
[Unknown Script] [18:14:42] [nowplaying_eventloop/ERROR]: [now_playing]: onUpdate error
[Unknown Script] Traceback (most recent call last):
[Unknown Script]   File "D:\Documents/Downloads\now_playing.py", line 308, in doUpdate
[Unknown Script]     update_song(data[0])
[Unknown Script] IndexError: list index out of range
[now_playing.py] [18:14:43] [MainThread/DEBUG]: [now_playing]: script_update(<Swig Object of type 'obs_data_t *' at 0x0000029EBED07900>)
[now_playing.py] [18:14:43] [MainThread/DEBUG]: [now_playing]: Timer killed

On Python 3.9, the script can not be loaded.

[now_playing.py] [18:06:23] [MainThread/DEBUG]: [proactor_events]: Using proactor: IocpProactor
[now_playing.py] Traceback (most recent call last):
[now_playing.py]   File "D:\Documents/Downloads\now_playing.py", line 273, in <module>
[now_playing.py]     loopthread: threading.Thread | None = None
[now_playing.py] TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

NetEase Cloud Music is running and playing music in the background during testing.

GirlKiller512 commented 6 months ago

Forget to provide my environment: Windows 11 Pro 23H2 (10.0.22631.3296) OBS 30.1.0 NetEase Cloud Music 3.0.0

rsp4jack commented 6 months ago

I have no idea about fixing this issue rather than SMTC.

NCM does not have SMTC support. BetterNCM got a plugin called InfLink that adds SMTC support to NCM. But it seems not to work for NCM 3.0.0. Downgrading NCM to 2.x.x will work for InfLink.

You may use SMTC compatible players.

rsp4jack commented 6 months ago

IndexError: list index out of range error means there is no playing data that the script gets. And the script does not support Python 3.9 at all.

GirlKiller512 commented 6 months ago

I downgraded NetEase Cloud Music to 2.10.13 and installed BetterNCM and InfLink. Although the script has a slight delay, it displays the text correctly. image image Thanks for your work!

By the way, how to make the script log dialog not pop up on OBS startup with the script enabled? I don't want to see a dialog pop up every time I launch OBS. And, if I close NCM, the dialog will also pop up, showing IndexError: list index out of range.

rsp4jack commented 6 months ago

I replaced "debug logging" to "log level" so it is possible now to silence logging of the plugin at all, and the log dialog will not popup as there will be no log if logging level is set to "SILENT". The IndexError will be also handled gracefully now.

rsp4jack commented 6 months ago

BTW, you may use a 3rd-party NCM client like LyricEase which supports SMTC and has a nice UI.

GirlKiller512 commented 6 months ago

I'll temporarily use NetEase Cloud Music + BetterNCM combination for a period of time. The script now works great. Thanks again for your work.