This is how to do it, pretty simple.
First you need to install youtube-dl, it is used to get the real link of the stream.
#apt-get install youtube-dl
Then you need to check which number (resolution) that you prefer using:
#youtube-dl --list-formats
External Content
www.youtube.com
Content embedded from external sources will not be displayed without your consent.
Through the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.
For example, if you prefer to stream at number 91, then you do:
#youtube-dl -f 91
External Content
www.youtube.com
Content embedded from external sources will not be displayed without your consent.
Through the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.
This command will give you the real URL
After that, just put those command using pipe (I am using ffmpeg)
pipe:///usr/bin/ffmpeg -i index.m3u8 -vcodec copy -acodec copy -f mpegts -tune zerolatency pipe:1
Note, all in one line.
That's it.