S
S
SOTVM2021-05-30 16:19:13
bash
SOTVM, 2021-05-30 16:19:13

Need to open youtube in VLC player, what's wrong?

To open youtube 1080p in VLC player
Run vlc '"VIDEO_DIRECT_LINK" --input-slave "AUDIO_DIRECT_LINK" in console.

I get video and audio links to the stream (each on a new line)

$ youtube-dl -g https://www.youtube.com/watch?v=yfHQCNPTios
https://r2---sn-ug5onuxaxjvh-v8cl.googlevideo.com/videoplayback?expire=1622400234&ei=ioizYKjRMZrS7QS8sKLwDQ&ip=46.241.70.3&id=o-APPOvIDYl5QL3mk3LYORVm91B1D31lwSEs3SYM3rGkiv&itag=248&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=hv&mm=31%2C29&mn=sn-ug5onuxaxjvh-v8cl%2Csn-ug5onuxaxjvh-n8vs&ms=au%2Crdu&mv=m&mvi=2&pl=23&initcwndbps=1360000&vprv=1&mime=video%2Fwebm&ns=UQQEn0SL4OGWVelKOQkzfpsF&gir=yes&clen=97044422&dur=824.240&lmt=1622314577614067&mt=1622378444&fvip=5&keepalive=yes&fexp=24001373%2C24007246&c=WEB&txp=5535432&n=_ewoMfTajbb4SH0p&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIgEJYR8IGcM637yLQR8l-WSXqE3ih4JQpib2JtKffQwOsCIQDMYhtgOAEZspdTjHeTboOjlHLFILY1HX9gpiszFrZByQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgQmIgT_6xX1JBcc-eCpo9l5ddOeeURQW2KA9lP0WiySACID78TmeQuuwj84HFPaTyyd-_XaCkvmmlkRBNFtIiubSf
https://r2---sn-ug5onuxaxjvh-v8cl.googlevideo.com/videoplayback?expire=1622400234&ei=ioizYKjRMZrS7QS8sKLwDQ&ip=46.241.70.3&id=o-APPOvIDYl5QL3mk3LYORVm91B1D31lwSEs3SYM3rGkiv&itag=251&source=youtube&requiressl=yes&mh=hv&mm=31%2C29&mn=sn-ug5onuxaxjvh-v8cl%2Csn-ug5onuxaxjvh-n8vs&ms=au%2Crdu&mv=m&mvi=2&pl=23&initcwndbps=1360000&vprv=1&mime=audio%2Fwebm&ns=UQQEn0SL4OGWVelKOQkzfpsF&gir=yes&clen=15272581&dur=824.281&lmt=1622308955458940&mt=1622378444&fvip=5&keepalive=yes&fexp=24001373%2C24007246&c=WEB&txp=5511222&n=_ewoMfTajbb4SH0p&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhAJYlyKFV5SOBSsOsjyPDw0I887XMeMSWH-JH5jU6jKf2AiEAv3A1jQJxt1tPgktzJCsA7E1CtwwWqblMAeLu7lH1JWI%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgQmIgT_6xX1JBcc-eCpo9l5ddOeeURQW2KA9lP0WiySACID78TmeQuuwj84HFPaTyyd-_XaCkvmmlkRBNFtIiubSf


| remove line break tr "\n"" "
| I substitute the --input-slave option and wrap the links in quotes
turns out as it should
youtube-dl -g https://www.youtube.com/watch?v=yfHQCNPTios | tr "\n" " " | awk '{print "\""$1"\"","--input-slave","\""$2"\""}'
"https://r2---sn-ug5onuxaxjvh-v8cl.googlevideo.com/videoplayback?expire=1622401022&ei=nouzYPrIKLHs7gSo54fACg&ip=46.241.70.3&id=o-AOn-IP6g2wl0Ar3PGcSvzQ8vnGVptRLqZzIur0Lvs3_P&itag=248&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=hv&mm=31%2C29&mn=sn-ug5onuxaxjvh-v8cl%2Csn-ug5onuxaxjvh-n8vs&ms=au%2Crdu&mv=m&mvi=2&pcm2cms=yes&pl=23&initcwndbps=1392500&vprv=1&mime=video%2Fwebm&ns=0CfBtSxY8DI7-0pO_X3f3WoF&gir=yes&clen=97044422&dur=824.240&lmt=1622314577614067&mt=1622379164&fvip=5&keepalive=yes&fexp=24001373%2C24007246&c=WEB&txp=5535432&n=0HA9HwXcIHau4Kpm&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIgWKERZ5dih10Uo6LW4xXVZQLtq3bhtV29zfEz333ynQwCIQC5g-zhiw4dSEokeYV9Vb5Xd03bN2rP2O9ZtwVY5HwDzA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIhALqV3zQDUGf8frCFeJkLnQ3ws50MvuVHM6dLWX_812poAiAkhP4eQon1oclX8T9RLZJ91lrm_d-XU3obX2eot1vSbg%3D%3D" --input-slave "https://r2---sn-ug5onuxaxjvh-v8cl.googlevideo.com/videoplayback?expire=1622401022&ei=nouzYPrIKLHs7gSo54fACg&ip=46.241.70.3&id=o-AOn-IP6g2wl0Ar3PGcSvzQ8vnGVptRLqZzIur0Lvs3_P&itag=251&source=youtube&requiressl=yes&mh=hv&mm=31%2C29&mn=sn-ug5onuxaxjvh-v8cl%2Csn-ug5onuxaxjvh-n8vs&ms=au%2Crdu&mv=m&mvi=2&pcm2cms=yes&pl=23&initcwndbps=1392500&vprv=1&mime=audio%2Fwebm&ns=0CfBtSxY8DI7-0pO_X3f3WoF&gir=yes&clen=15272581&dur=824.281&lmt=1622308955458940&mt=1622379164&fvip=5&keepalive=yes&fexp=24001373%2C24007246&c=WEB&txp=5511222&n=0HA9HwXcIHau4Kpm&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRAIgX0EGXZiWBeTxaxC_8ZPqFECEAhQNK2jHqRCs4qklVqECICaBTNaA5IgLht-3FM6z0qxKUyrZzONVc-cErbmbYESW&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIhALqV3zQDUGf8frCFeJkLnQ3ws50MvuVHM6dLWX_812poAiAkhP4eQon1oclX8T9RLZJ91lrm_d-XU3obX2eot1vSbg%3D%3D"


but when I pass this received string through | "pipe" as an argument to VLC,
$ youtube-dl -g https://www.youtube.com/watch?v=yfHQCNPTios | tr "\n" " " | awk '{print "\""$1"\"","--input-slave","\""$2"\""}' | vlc

does not work :(
if you copy and substitute with handles, the resulting string as a parameter
then it works fine
$ vlc "https://r2---sn-ug5onuxaxjvh-v8cl.googlevideo.com/videoplayback?expire=1622402068&ei=tI-zYPnxG53R7ASIqJe4CQ&ip=46.241.70.3&id=o-AFTaSBxc5BsKRww7mJ82sXcX2vxRFWmOvZpSHNASa7vt&itag=248&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=hv&mm=31%2C29&mn=sn-ug5onuxaxjvh-v8cl%2Csn-ug5onuxaxjvh-n8vs&ms=au%2Crdu&mv=m&mvi=2&pl=23&initcwndbps=1388750&vprv=1&mime=video%2Fwebm&ns=gTEesG6N7Bd5YYSfE8Wxy3kF&gir=yes&clen=97044422&dur=824.240&lmt=1622314577614067&mt=1622380131&fvip=5&keepalive=yes&fexp=24001373%2C24007246&c=WEB&txp=5535432&n=NY6Wud_S55zqRxWy&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhAIfQgL3RP4ys7CXiQyJ5T5Aof1LOYOgknbS-bmm9EWtlAiBdw-xwKTGepPzsmXHIbfo9zxIvmJbCj5u1NsMuBZjdfw%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgJ-TKRA5Wu1x_l7EzmFyntXXUrF2z5ga4cMlgCMB-W4MCIFTG16IiQn9GjF5NRhNLXEXC7aX_KBtq_c8pEZS9Rzol" --input-slave "https://r2---sn-ug5onuxaxjvh-v8cl.googlevideo.com/videoplayback?expire=1622402068&ei=tI-zYPnxG53R7ASIqJe4CQ&ip=46.241.70.3&id=o-AFTaSBxc5BsKRww7mJ82sXcX2vxRFWmOvZpSHNASa7vt&itag=251&source=youtube&requiressl=yes&mh=hv&mm=31%2C29&mn=sn-ug5onuxaxjvh-v8cl%2Csn-ug5onuxaxjvh-n8vs&ms=au%2Crdu&mv=m&mvi=2&pl=23&initcwndbps=1388750&vprv=1&mime=audio%2Fwebm&ns=gTEesG6N7Bd5YYSfE8Wxy3kF&gir=yes&clen=15272581&dur=824.281&lmt=1622308955458940&mt=1622380131&fvip=5&keepalive=yes&fexp=24001373%2C24007246&c=WEB&txp=5511222&n=NY6Wud_S55zqRxWy&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhALrMMvQdmuAmdwLpqhNaUqTKu1iz-1WqubXCSnrCryegAiEAxp-OfNLMXP5wlinnoM34dpwLvKZrpky4BTGT22Gk0h8%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgJ-TKRA5Wu1x_l7EzmFyntXXUrF2z5ga4cMlgCMB-W4MCIFTG16IiQn9GjF5NRhNLXEXC7aX_KBtq_c8pEZS9Rzol"
VLC media player 3.0.9.2 Vetinari (revision 3.0.9.2-0-gd4c1aefe4d)
[000055fdf5c18670] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
qt5ct: using qt5ct plugin
qt5ct: D-Bus global menu: no
qt5ct: D-Bus system tray: yes



ps
Thank you xotkot ,
SOLUTION:
the format is chosen by the method of scientific poke))
"bestvideo[height<=1080]+bestaudio/best" -eg $(echo "[email protected]" | cut -d'&' -f1) ))"

here is a working script, to which I pass the youtube link,
the viewed is written in yt.log (date_time, title, youtube video link)
#!/bin/bash
IFS=$'\n' x=($(youtube-dl -f "bestvideo[height<=1080]+bestaudio/best" -eg $(echo "[email protected]" | cut -d'&' -f1) ))" &&
echo -e "### $(date +%Y.%m.%d_%H:%M:%S)\n${x[0]}\[email protected]\n"  >> yt.log &&
vlc  --meta-title "${x[0]}" "${x[1]}" --input-slave "${x[2]}"

+ another version of the script
youtube-dl -f "bestvideo[height<=1080]+bestaudio/best" --get-filename -o '"%(title)s"' -g $(echo "[email protected]" | cut -d'&' -f1) | awk 'BEGIN{FS=RS;RS=""}{print $1" --input-slave "$2" --meta-title "$3}' | xargs vlc

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xotkot, 2021-05-30
@sotvm

I see people love difficulties

x=($(youtube-dl -g https://www.youtube.com/watch?v=yfHQCNPTios)) && vlc ${x[0]} --input-slave ${x[1]}

To open youtube 1080p in VLC player

to do this, you need to set the necessary parameters in the --format key
x=($(youtube-dl -g --format="bestvideo[height<=?1080]+bestaudio" https://www.youtube.com/watch?v=yfHQCNPTios)) && vlc ${x[0]} --input-slave ${x[1]}

I wrote more about this in your previous question
for mpv it will be easier:
mpv --ytdl-format="bestvideo[height<=?1080]+bestaudio" https://www.youtube.com/watch?v=yfHQCNPTios

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question