TITLE token is broken when using umpv
sun95n opened this issue · comments
Hi. I finally figured out how to integrate the umpv script into pipe-viewer. However, I ran into a problem: The special token *TITLE*
is broken. I suspect that it is the arg syntax because in --force-media-title=
there must be a container: ''
however this already exists in env MPV='...'
So there could be a conflict between the two. I forgot to mention that you need to set split_videos
to 0
to get audio.
video_player_selected => "mpv",
video_players => {
mpv => {
arg => "*VIDEO*",
audio => "--audio-file=*AUDIO*",
cmd => "env MPV='mpv --really-quiet --force-media-title=*TITLE* --no-ytdl' umpv",
fs => "--fullscreen",
srt => "--sub-file=*SUB*",
},
For now I decided to replace *TITLE*
with *ID*
(until I find a solution) This is because it will show \
and /
in spaces, periods or non-latin characters.
Try to use double quotes:
cmd => "env MPV=\"mpv --really-quiet --force-media-title=*TITLE* --no-ytdl\" umpv",
Thanks for your reply. I'm afraid to say I get the same behavior. Maybe this should work first when you load a local media file with umpv. Something like: env MPV="mpv --force-media-title='CUSTOM NAME'" umpv your_file
So the goal is to get CUSTOM NAME
displayed as title instead of just CUSTOM
and NAME
being recognized as just another file in the playlist.
After looking at the source code of umpv
, we can see where the issue is:
opts = (os.getenv("MPV") or "mpv").split()
umpv
simply splits the value of $MPV
by whitespace, without taking into account any quotation marks, which is wrong.
A workaround would be to replace whitespace characters in the *TITLE*
, with some other character, like -
:
cmd => "TITLE=\$(perl -E 'say\$ARGV[0]=~s/\\\s/-/gr' *TITLE*); env MPV=\"mpv --really-quiet --force-media-title=\$TITLE --no-ytdl\" umpv",
Thanks a lot. Now it works!
umpv
simply splits the value of$MPV
by whitespace, without taking into account any quotation marks, which is wrong.
Maybe I should mention this bug in mpv I hope they can fix it.
They helped me fix it! However, another problem arose: The title does not update. It works fine when you load local files or URLs but not when you use pipe-viewer. I tried the above methods but none worked.
Please don't take this the wrong way, I try to report or address these issues to find a solution that can help this community. To be honest I don't think this looks bad, but sometimes the little details are important.
I can reproduce the issue outside of pipe-viewer
as well:
env MPV="mpv --force-media-title=name1" umpv 1.mp4
env MPV="mpv --force-media-title=name2" umpv 2.mp4
The title will keep the name name1
while playing 2.mp4
as well.
That's because the $MPV
option is read by umpv only when creating the socket when it doesn't already exist.
My fault. I forgot to test it in the terminal. I asked how to fix it, however there are no plans to support that behavior. So maybe that's all for now anyway this is already merged to umpv master. Now I share the options that should work with it (remember to set split_videos
to 0
to get audio).
video_player_selected => "mpv",
video_players => {
mpv => {
arg => "*VIDEO*",
audio => "--audio-file=*AUDIO*",
cmd => "env MPV=\"mpv --really-quiet --force-media-title=*TITLE* --no-ytdl\" umpv",
fs => "--fullscreen",
srt => "--sub-file=*SUB*",
},
Thanks for your time and help. I should close this now.