Closed GirlKiller512 closed 8 months ago
Sounds interesting. Could you give some examples with NCM window title presented?
These are the window titles of the music above.
In other words, the music with a title including "-" may cause display errors.
If I change the display text setting to %artist - %title
, the text becomes mess.
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)
Let's leave the issue open until a solution is found.
Edit: I found the latest OBS supports Python 3.6 to 3.10. SMTC support is coming soon 🎉
Yeah, I also found that OBS 30.1.0 supports Python 3.6-3.10 from its official website last night.
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)
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.
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:
[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.
Forget to provide my environment: Windows 11 Pro 23H2 (10.0.22631.3296) OBS 30.1.0 NetEase Cloud Music 3.0.0
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.
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.
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. 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
.
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.
BTW, you may use a 3rd-party NCM client like LyricEase which supports SMTC and has a nice UI.
I'll temporarily use NetEase Cloud Music + BetterNCM combination for a period of time. The script now works great. Thanks again for your work.
The music title is displayed incorrectly if it includes 1 or more "-" with no spaces next to "-". Display text setting:
%title - %artist
Examples: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: