pystardust / ytfzf

A posix script to find and watch youtube videos from the terminal. (Without API)
GNU General Public License v3.0
3.79k stars 343 forks source link

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

Open Bogdan107 opened 2 years ago

Bogdan107 commented 2 years ago

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.

Euro20179 commented 2 years ago

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.

Bogdan107 commented 2 years ago

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?

Euro20179 commented 2 years ago

Move the video player function inside handle_keypress_alt_y