trizen / pipe-viewer

A lightweight YouTube client for Linux, without requiring an API key.
Artistic License 2.0
398 stars 19 forks source link

How can I pass video ID as an argument? #13

Closed asakura42 closed 3 years ago

asakura42 commented 3 years ago

I write mpv addon to use sponsorblock with local database and I need to get video IDs. But I didn't found that option in code. So can I pass video ID as an argument?

trizen commented 3 years ago

Do you mean passing the YouTube URL directly to mpv?

This can be done by modifying the mpv section in the config-file, to:

 mpv => {
          arg => "--really-quiet *URL*",
          audio => "",
          cmd => "mpv",
          fs => "--fullscreen",
          novideo => "--no-video",
          srt => "--sub-file=*SUB*",
        },

Additionally, there is also the *ID* special token, if needed. For more tokens, see pipe-viewer -T.

asakura42 commented 3 years ago

Thank you.

trizen commented 2 years ago

A small hack to no longer pass the *URL* to mpv, but still having sponsorblock working:

  1. Place mpv_sponsorblock_minimal in ~/.config/mpv/scripts.
  2. Add the following entry in the list of urls: "&v=([%w-_]+)$" inside the function file_loaded()

And now in the configuration of pipe-viewer, change the mpv section to:

mpv => {
        arg     => "--really-quiet --force-media-title=*TITLE* --no-ytdl *VIDEO*\\&v=*ID*",
        audio   => "--audio-file=*AUDIO*",
        cmd     => "mpv",
        fs      => "--fullscreen",
        novideo => "--no-video",
        srt     => "--sub-file=*SUB*",
       },
sun95n commented 1 year ago

The first method worked for me with pipe-viewer 0.4.4 / mpv 0.32.0 / mpv_sponsorblock I replaced: "--really-quiet --force-media-title=*TITLE* --no-ytdl --no-terminal *VIDEO*", with: "--really-quiet --force-media-title=*TITLE* --no-terminal *URL*",

bipox commented 1 year ago

The fix works, but now everything plays at max resolution instead of 720p which I use.

trizen commented 1 year ago

The fix works, but now everything plays at max resolution instead of 720p which I use.

Try this workaround instead, which allows pipe-viewer to select the resolution.

Otherwise, add in ~/.config/mpv/config the following line:

ytdl-raw-options-append="format-sort=ext,res:720"
xsoalokinx commented 1 year ago

Does not appear to be working here for me with pipe-viewer, but works with mpv by itself.