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

script-opts seem to be ignored #16

Closed
iv4nhoe opened this issue Mar 30, 2023 · 11 comments
Closed

script-opts seem to be ignored #16

iv4nhoe opened this issue Mar 30, 2023 · 11 comments

Comments

@iv4nhoe
Copy link

iv4nhoe commented Mar 30, 2023

I'v got the chat working but it seems scipt-opts are ignored.

I cloned the repo to the mpv scripts dir so that the script is located at ~/.config/mpv/scripts/mpv-twitch-chat/main.lua and I have tried putting following script opts file at ~/.config/mpv/script-opts/twitch.conf:

twitch_client_id: 'clientid'
show_name: true
color: false
duration_multiplier: 20
max_duration: 60
max_message_length: 40
fetch_aot: 1

Although show_name is set to true names are not shown. I also tried passing a single option via --script-opts=show_name=true command line parameter, but same result.

My ~/.config/mpv/mpv.conf:

[twitch]
profile-cond=get("path", ""):find("^https://www.twitch.tv/") ~= nil
profile-restore=copy-equal
sub-font-size=30
sub-align-x=right
sub-align-y=top
slang=rechat

Also what's strange is if I remove my twitch.conf altogether, the chat subtitles still work, so it seems the twitch_client_id isn't even that necessary.

Here's the output of mpv during playback, there are no apparent errors:

[auto_profiles] Applying auto profile: twitch 
 (+) Video --vid=1 (h264 1280x720)
 (+) Audio --aid=1 (aac 2ch 48000Hz)
 (+) Subs  --sid=1 --slang=rechat 'json' (null) (external)
Track removed:
 (+) Video --vid=1 (h264 1280x720)
 (+) Audio --aid=1 (aac 2ch 48000Hz)
Using hardware decoding (vaapi).
AO: [pulse] 48000Hz stereo 2ch float
VO: [gpu] 1280x720 vaapi[nv12]
AV: 03:56:08 / 04:36:41 (85%) A-V:  0.011 ct:  0.058 Dropped: 2 Cache: 6.1s/2MB
Track added:
 (+) Video --vid=1 (h264 1280x720)
 (+) Audio --aid=1 (aac 2ch 48000Hz)
 (+) Subs  --sid=1 'Twitch Chat' (subrip) (external)
AV: 03:58:48 / 04:36:41 (86%) A-V:  0.000 ct:  0.069 Dropped: 2 Cache: 354s/126MB
@CrendKing
Copy link
Owner

Config files in mpv uses equal sign "=", not colon.

it seems the twitch_client_id isn't even that necessary.

Currently the script is able to retrieve a working client ID from the stream. But again this is all implementation detail from Twitch. This mechanism could fail anytime. In that case, the script will fallback to the configured ID. So I recommend always provide that ID for safety.

@iv4nhoe
Copy link
Author

iv4nhoe commented Mar 30, 2023

Config files in mpv uses equal sign "=", not colon.

Doesn't make a difference when I use equal signs instead.

show_name works when I hard code it to true in main.lua so it must be related to how the opts are read. Since it also does not work with passing --script-opts=show_name=true to mpv it leads me to believe that the script opts don't make it to the script. Maybe my mpv is too old? It's version 0.34.1.

@CrendKing
Copy link
Owner

Oh, just noticed your config filename is wrong. It should be mpv_twitch_chat.conf, not twitch.conf. Doc: https://mpv.io/manual/master/#script-location

@iv4nhoe
Copy link
Author

iv4nhoe commented Mar 30, 2023

Oh, just noticed your config filename is wrong. It should be mpv_twitch_chat.conf, not twitch.conf. Doc: https://mpv.io/manual/master/#script-location

This mostly did the trick. Another issue was that I was putting spaces around the equal signs which it does not like and that I used true/false instead of yes/no.

The only remaining issue is that it does not recognize the twitch_client_id option.

@CrendKing
Copy link
Owner

The only remaining issue is that it does not recognize the twitch_client_id option.

As I said, it is working as expected, that your provided option will be used when Twitch stop giving out a working ID from their API.

@iv4nhoe
Copy link
Author

iv4nhoe commented Mar 31, 2023

The only remaining issue is that it does not recognize the twitch_client_id option.

As I said, it is working as expected, that your provided option will be used when Twitch stop giving out a working ID from their API.

Sorry about the confusion, this is a new issue I'm talking about. When I put twitch_client_id in the config it tells me [mpv_twitch_chat] script-opts/mpv_twitch_chat.conf:1 unknown key 'twitch_client_id', ignoring when starting mpv.

@CrendKing
Copy link
Owner

Should be fixed now.

@iv4nhoe
Copy link
Author

iv4nhoe commented Mar 31, 2023

Should be fixed now.

I'm getting an error with this now:

[mpv_twitch_chat] 
[mpv_twitch_chat] stack traceback:
[mpv_twitch_chat]       [string "/home/ivanhoe/.config/mpv/scripts/mpv-twitch-chat..."]:134: in function 'load_twitch_chat'
[mpv_twitch_chat]       [string "/home/ivanhoe/.config/mpv/scripts/mpv-twitch-chat..."]:221: in function 'timer_callback'
[mpv_twitch_chat]       [string "/home/ivanhoe/.config/mpv/scripts/mpv-twitch-chat..."]:249: in function 'prop'
[mpv_twitch_chat]       mp.defaults:407: in function 'handler'
[mpv_twitch_chat]       mp.defaults:510: in function 'call_event_handlers'
[mpv_twitch_chat]       mp.defaults:555: in function 'dispatch_events'
[mpv_twitch_chat]       mp.defaults:503: in function <mp.defaults:502>
[mpv_twitch_chat]       [C]: in ?
[mpv_twitch_chat]       [C]: in ?
[mpv_twitch_chat] Lua error: [string "/home/ivanhoe/.config/mpv/scripts/mpv-twitch-chat..."]:134: attempt to index field 'data' (a nil value)

EDIT:
This seems to be unrelated to your change and to the twitch_client_id. No idea why I'm seeing this now, but not before.

EDIT 2:
Oh wait if I put back nil for the twitch_client_id option in main.lua the stack traceback goes away.

@CrendKing
Copy link
Owner

Sorry about that. Try now.

@iv4nhoe
Copy link
Author

iv4nhoe commented Apr 3, 2023

Sorry about that. Try now.

Ok thanks, it works now (as in it puts out an error message that indicates that something with my client id is wrong).

@Tallefer
Copy link

I have the same-ish issue: no matter what I do, parameters from the *.conf are ignored.
Not even sure it's this script's problem, but no other script had similar issues before, including older versions of it!
Normally I use the script as twitch-chat-vod.lua to differentiate from other twitch-related stuff (obviously, config is renamed accordingly in all cases), but even if I git clone this repo from scratch and make it work from its own subdir in ~/.config/mpv/scripts, there are no changes.
Tried switching true/yes and false/no (taking wild guesses from older issues here), even tried : instead of =, nope, nothing, not even any errors in console, so I assume the config is not even processed? And surely enough, hard-coding values into the script always work. No relevant files have different permissions from any others.

Some hopefully helpful hints: the script stopped working roughly about 1-2 years back when I switched to a newer MX-linux build and a newer mpv (probably 0.34), but I didn't pay much attention to that because of very little script's usage at the time. Then this year I switched to 0.35 and when I loaded a random vod ~last week - suddenly there were comments, placed as normal subs ofc. I added a twitch profile to mpv.conf so that's not a problem.
BTW, I suggest making a small change to the profile detection code to make it work in the mobile version:
profile-cond=get("path", ""):find("^https?://[wm]w?w?.twitch.tv/") ~= nil

And another small note: when any vod is loaded on pause or being played at faster speeds/seeked, the total number of subs counter in the lower right is incremented, is this the expected behavior? I think it wasn't before.

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

No branches or pull requests

3 participants