savonet / liquidsoap

Liquidsoap is a statically typed scripting general-purpose language with dedicated operators and backend for all thing media, streaming, file generation, automation, HTTP backend and more.
http://liquidsoap.info
GNU General Public License v2.0
1.4k stars 128 forks source link

request.dynamic and http source - Unknown protocol "http" in URI #2451

Closed danbo closed 2 years ago

danbo commented 2 years ago

What am I doing wrong?

2022/06/13 00:48:40 [main:3] Liquidsoap 2.0.5
2022/06/13 00:48:40 [main:3] Using: bytes=[distributed with OCaml 4.02 or above] pcre=7.5.0 sedlex=3.0 menhirLib=20211128 dtools=0.4.4 duppy=0.9.2 cry=0.6.7 mm=0.8.1 ogg=0.7.1 ogg.decoder=0.7.1 vorbis=0.8.0 vorbis.decoder=0.8.0 opus=0.2.1 opus.decoder=0.2.1 mad=0.5.2 flac=0.3.0 flac.ogg=0.3.0 flac.decoder=0.3.0 dynlink=[distributed with Ocaml] lame=0.3.6 fdkaac=0.3.2 ffmpeg=1.1.3 samplerate=0.1.6 taglib=0.3.9 camomile=1.0.2 faad=0.5.1
...
def get_request() =
  command = "curl -s http://web.api/next"
  log("Command: #{command}", label="app")
  response = list.hd(default="", process.read.lines(command))
  log("Response: #{response}", label="app")
  data = json.parse(default=[("key","value")], response)
  url = data["url"]
  request.create(url)
end

requests = request.dynamic(id="requests", get_request)

source = fallback(track_sensitive=false, [requests, mksafe(blank(duration=60.0))])
...
...
2022/06/13 00:48:43 [app:3] Command: curl -s http://web.api/next
2022/06/13 00:48:43 [app:3] Response: {...,"url":"http://web.api/track.mp4"}
2022/06/13 00:48:43 [app:3] Getting url http://web.api/track.mp4
2022/06/13 00:48:43 [request:3] Unknown protocol "http" in URI "http://web.api/track.mp4"!
....

PS: #354

toots commented 2 years ago

Hi,

Have you installed ocurl?

caf2022 commented 2 years ago

URI(/path/to/file.mp4) is a path, not a URL(http) maybe is this the problem, you need to specify a path of the file and not URL.

Sorry if I said nonsense.

toots commented 2 years ago

I believe that you need to install the ocurl module that is used to implement http.* operators. Without this module, we have no support for HTTP requests.