ytfzf icon indicating copy to clipboard operation
ytfzf copied to clipboard

[Feature request]: Add option to add prefix into <mpv_call_command>

Open Bogdan107 opened this issue 2 years ago • 3 comments

Background

[ yes ] I have checked ytfzf(1) and ytfzf(5) or the wiki before creating this.

Problem

Why do we need this feature? I want to use tor to play some videos. Tor - is a proxy with type socks. I use handle_keypress_alt_y () command for this.

But MPV supports only proxy with type http/https. MPV does not support proxy with type socks. Details - https://github.com/mpv-player/mpv/issues/3373.

So, to use socks proxy, I need to use additional http/https proxy-server.

Start of this problem - #547. But my problem was been resolved only partly.

With this feature, I can use socks-proxy to play the video in MPV, which called from ytfzf. This do by usage of the proxyficator program, like torify, proxychains4, tsocks or any other.

Feature

Description of your proposed feature.

Add an option, like mpv_cmd_prefix into conf.sh:

mpv_cmd_prefix
        Prefix for the command, which call MPV player.
        default= <empty line>

Example of usage:

mpv_cmd_prefix="http_proxy= https_proxy= torsocks -q"

With this prefix, the command, which generated inside the ytfzf, which call MPV player, will be prepended with value of $mpv_cmd_prefix variable. The result line must be like this:

${mpv_cmd_prefix} ${mpv_cmd} ${url_handler_opts} ${url}

or in expanded version:

http_proxy= https_proxy= torsocks -q mpv <some_options_from_ytfzf> https://youtube.com/watch?s=<video_id>

Alternative solutions to problem?

Neither mpv, no ytfzf have an options, which allow to use socks-type proxy-server in MPV without usage of external proxy chains http_proxy -> socks_proxy.

Bogdan107 avatar Jun 30 '22 20:06 Bogdan107

In the way that you are proposing, this will not work simply due to how shell uses variables. (although I do think this would be a nice feature)

you could just add

video_player () {
    http_proxy= https_proxy= torsocks -q mpv --ytdl-format="$ytdl_pref" $url_handler_opts "$@"
}

to your ytfzf config.

So whenever you play a video it uses your function instead of the default one.

Euro20179 avatar Jun 30 '22 23:06 Euro20179

I configure function video() as in your example. Then, normally unavialabled videos are played with ytfzf over tor.

But in this case, ALL VIDEOS are played over the socks-proxy...

I need to play only some videos with proxy, not all videos.

How to join video_player () with handle_keypress_alt_y () to allow to play only selected videos over the socks proxy?

Bogdan107 avatar Jul 01 '22 22:07 Bogdan107

Move the video player function inside handle_keypress_alt_y

Euro20179 avatar Jul 02 '22 00:07 Euro20179