On Tue, Jul 07, 2015 at 08:31:37AM -0700, Daniel Roesler wrote:
> Howdy all,
> 
> I'm trying to stream a video from a local website using elinks, but
> elinks is trying to download the entire video before opening it using
> mplayer. Is there a way I can pass the url of the link into the
> download command instead of the downloaded file?
> 
> What I'm trying to open:
> <a href="vid.mp4">Vid</a>
> 
> What I currently do:
> I highlight that link and hit Enter. The dialog pops up and asks if I
> want to open with "/usr/bin/mplayer %". I select Open. Then it starts
> downloading the full video file. I have to wait for the entire file to
> download before it opens in mplayer :(
> 
> What I'd like to happen:
> When I hit Enter, I'd like to run "/usr/bin/mplayer %url%". That way,
> mplayer will just stream the video without waiting for the whole thing
> to download :)
> 
> How do I do this in elinks?

AFAIK links has such a feature, but if you want to do it in elinks
the follow_url_hook in browser scripting is good enough for it.

Here is Python version:

import os
def follow_url_hook(url):
    """Rewrite a URL for a link that's about to be followed.

    This function should return a string containing a URL for ELinks to
    follow, or an empty string if no URL should be followed, or None if
    ELinks should follow the original URL.

    Arguments:

    url -- The URL of the link.

    """
    for k in ['.mp4', '.avi', '.webm']:
        if not url.endswith(k):
            continue
        pid = os.fork()
        if pid:
            return ""
        else:
            os.closerange(1, 2048)
            os.execl("/usr/bin/mplayer", "-noconsolecontrols", url)
-- 
http://lists.linuxfromscratch.org/listinfo/elinks-users
Unsubscribe: See the above information page

Reply via email to