Henrique Lengler wrote:

> Thank you guys, but I'm looking for something automatic. Looks like it 
> doesn't exist but would be cool to have something like this.
> Also I don't care about youtube videos or any other type of video system
> that doesn't provide their videos as video files, I think this is wrong 
> and sucks a lot.
> So my interest is in direct video links and pages with html5 video tag, that 
> also point to a video file.
> 
> Regards,

There was a script+patch somewhere that would grab an embedded video and
play it with mplayer/mpv/... by pressing a shortcut defined in your
config.def.h of surf, and as long as you disable javascript and plugins,
surf won't play the video by itself.
I can't remember where I found it, but here's the code:

#define WATCH {.v = (char *[]){ "/bin/sh", "-c", \
        "st -e \
        yt $(xprop -id $0 _SURF_URI | cut -d \\\" -f 2)", \
        winid, NULL } }

[...]

    { MODKEY,               GDK_w,      spawn,      WATCH },

with "yt" being something like the attached script.
#!/bin/mksh
# format="-f34" # leave empty for default
player="mpv --quiet --geometry=50%:50% --keep-open"
tmpdir="$HOME/yt"

url="$1"
filepath="$tmpdir/$(youtube-dl --id --get-filename $format $url)"

youtube-dl -c -o $filepath $format $url &
print "$!" > $filepath.$$.pid

while [ ! -r $filepath ] && [ ! -r $filepath.part ]; do 
    printf '%s' "Waiting for youtube-dl..."
    sleep 3
done

[ -r $filepath.part ] && $player $filepath.part || $player $filepath
kill $(<$filepath.$$.pid)
rm $filepath.$$.pid

Reply via email to