[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can't find file
From: |
David Niklas |
Subject: |
Re: Can't find file |
Date: |
Mon, 11 Nov 2019 20:24:58 -0500 |
On Sat, 9 Nov 2019 20:13:25 -0500,
Eli Schwartz <address@hidden> wrote:
...
> So basically it would really help if we understood what you were trying
> to do.
Ok, my mistake. I was trying to give a minimalist example of my problem
to make bug hunting easier. Someday I'll figure out how to do this
correctly...
I'm trying to automate the locating and playing of files with subtitles
that are separate from the video.
I've placed this into my .bashrc:
function mpv-subtitle()
{
# Have mpv play files with subtitles.
if [ $# -eq 0 ]; then
echo -e "mpv-subtitle FILES.FORMAT\n\n\tPlays files with their
subtitles.";
return 0;
fi
for i in "$@"; do
mpv --title="window title" --pause --profile opengl-hq
--scale=ewa_lanczossharp \
--deband-iterations=5 --cache=8192 --volume=100 --volume-max=200 \
--audio-device=alsa/dixy \
$(awk -v z="$i" 'BEGIN{ sub(/\.(avi|ogv|mpe?g|mkv|mp4|webm)/,
"", z); ret = system("test -f \"" z ".en.vtt\""); if(ret ==
0){ print "--sub-file " z ".en.vtt" } ret = system("test -f
\"" z ".srt\""); if(ret == 0){ print "--sub-file " z
".srt" } }' ) \ "$i"; done }
When I invoke it on a file without spaces it works like a charm:
% . ~/.bashrc && mpv-subtitle
'Amazon_s_playbook_for_crushing_startups-ojGveiE51Hk.mp4'
Playing: Amazon_s_playbook_for_crushing_startups-ojGveiE51Hk.mp4
When I add spaces I get:
% . ~/.bashrc && mpv-subtitle 'Amazon s playbook for crushing
startups-ojGveiE51Hk.mp4'
Playing: s
[file] Cannot open file 's': No such file or directory
Failed to open s.
Playing: playbook
[file] Cannot open file 'playbook': No such file or directory
Failed to open playbook.
Playing: for
[file] Cannot open file 'for': No such file or directory
Failed to open for.
Playing: crushing
[file] Cannot open file 'crushing': No such file or directory
Failed to open crushing.
Playing: startups-ojGveiE51Hk.en.vtt
[file] Cannot open file 'startups-ojGveiE51Hk.en.vtt': No such file or directory
Failed to open startups-ojGveiE51Hk.en.vtt.
Playing: Amazon s playbook for crushing startups-ojGveiE51Hk.mp4
[file] Cannot open file 'Amazon': No such file or directory
Failed to open Amazon.
Can not open external file Amazon.
I can't quote the $(...) because I need to pass the --sub-file FILE as
separate arguments.
I tried to quote the file name like this without effect:
... print "--sub-file \"" z "\".en.vtt" ...
Thanks,
David