I use youtube-dl to obtain the URL of the binary stream of a YouTube video, that for whatever reason i'd like to download, i do it like this:
youtube-dl -f bestaudio -g --skip-download https://www.youtube.com/watch?v=nk5YtLYcH74
After i have the URL, I curl it, somehow like this:
https://r6---sn-gqn-vhgl.googlevideo.com/videoplayback\?id\=afe82f21e356....
or i could forward the output into a file of course, but this is just to explain. I'd like to download it, but not with curl, but with a Scala HTTP client, for now akka-http. But that way i get:
IllegalResponseException: Response Content-Length 195022703 exceeds the configured limit of 8388608
I know this is a large stream, but how does curl do it automatically? How does it request chunks, or how does it work, how should i write it in Scala/Java?
Some code and more:
val connectionFlow = Http().outgoingConnectionTls(hostname)
val responseFuture =
Source.single(HttpRequest(uri = path, method = GET))
.via(connectionFlow)
.runWith(Sink.foreach[HttpResponse] { r =>
logger.info(s"${r.status}")
})