codemirror-lang-liquidsoap 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/cli.js +13 -13
  2. package/dist/index.js +15 -13
  3. package/package.json +2 -2
  4. package/src/index.ts +2 -0
  5. package/src/liquidsoap.grammar +9 -1
  6. package/src/parser.js +8 -8
  7. package/src/parser.terms.js +6 -5
  8. package/tests/liquidsoap/.github/scripts/build-posix.sh +0 -3
  9. package/tests/liquidsoap/.github/workflows/ci.yml +35 -10
  10. package/tests/liquidsoap/.pre-commit-config.yaml +1 -1
  11. package/tests/liquidsoap/CHANGES.md +1 -0
  12. package/tests/liquidsoap/CITATION.cff +17 -0
  13. package/tests/liquidsoap/doc/Makefile +17 -0
  14. package/tests/liquidsoap/doc/content/beets.md +6 -47
  15. package/tests/liquidsoap/doc/content/blank.md +5 -17
  16. package/tests/liquidsoap/doc/content/complete_case.md +1 -53
  17. package/tests/liquidsoap/doc/content/cookbook.md +23 -170
  18. package/tests/liquidsoap/doc/content/crossfade.md +1 -73
  19. package/tests/liquidsoap/doc/content/dynamic_sources.md +1 -47
  20. package/tests/liquidsoap/doc/content/external_decoders.md +6 -118
  21. package/tests/liquidsoap/doc/content/external_encoders.md +2 -4
  22. package/tests/liquidsoap/doc/content/external_streams.md +6 -20
  23. package/tests/liquidsoap/doc/content/ffmpeg_cookbook.md +9 -147
  24. package/tests/liquidsoap/doc/content/ffmpeg_filters.md +6 -93
  25. package/tests/liquidsoap/doc/content/harbor.md +4 -40
  26. package/tests/liquidsoap/doc/content/harbor_http.md +10 -118
  27. package/tests/liquidsoap/doc/content/help.md +1 -9
  28. package/tests/liquidsoap/doc/content/hls_output.md +6 -102
  29. package/tests/liquidsoap/doc/content/http_input.md +2 -4
  30. package/tests/liquidsoap/doc/content/icy_metadata.md +2 -24
  31. package/tests/liquidsoap/doc/content/in_production.md +2 -7
  32. package/tests/liquidsoap/doc/content/json.md +10 -36
  33. package/tests/liquidsoap/doc/content/language.md +1 -1
  34. package/tests/liquidsoap/doc/content/liq/Makefile +8 -0
  35. package/tests/liquidsoap/doc/content/liq/append-silence.liq +46 -0
  36. package/tests/liquidsoap/doc/content/liq/beets-amplify.liq +29 -0
  37. package/tests/liquidsoap/doc/content/liq/beets-protocol.liq +26 -0
  38. package/tests/liquidsoap/doc/content/liq/beets-source.liq +21 -0
  39. package/tests/liquidsoap/doc/content/liq/blank-detect.liq +10 -0
  40. package/tests/liquidsoap/doc/content/liq/blank-sorry.liq +11 -0
  41. package/tests/liquidsoap/doc/content/liq/check +4 -0
  42. package/tests/liquidsoap/doc/content/liq/complete-case.liq +69 -0
  43. package/tests/liquidsoap/doc/content/liq/cross.smart.liq +37 -0
  44. package/tests/liquidsoap/doc/content/liq/crossfade.liq +120 -0
  45. package/tests/liquidsoap/doc/content/liq/decoder-faad.liq +122 -0
  46. package/tests/liquidsoap/doc/content/liq/decoder-flac.liq +19 -0
  47. package/tests/liquidsoap/doc/content/liq/decoder-metaflac.liq +24 -0
  48. package/tests/liquidsoap/doc/content/liq/dump-hourly.liq +7 -0
  49. package/tests/liquidsoap/doc/content/liq/dump-hourly2.liq +4 -0
  50. package/tests/liquidsoap/doc/content/liq/dynamic-source.liq +55 -0
  51. package/tests/liquidsoap/doc/content/liq/external-output.file.liq +7 -0
  52. package/tests/liquidsoap/doc/content/liq/fallback.liq +4 -0
  53. package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-dynamic-volume.liq +36 -0
  54. package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-flanger-highpass.liq +10 -0
  55. package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-hflip.liq +9 -0
  56. package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-hflip2.liq +23 -0
  57. package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-parallel-flanger-highpass.liq +36 -0
  58. package/tests/liquidsoap/doc/content/liq/ffmpeg-live-switch.liq +23 -0
  59. package/tests/liquidsoap/doc/content/liq/ffmpeg-relay-ondemand.liq +31 -0
  60. package/tests/liquidsoap/doc/content/liq/ffmpeg-relay.liq +19 -0
  61. package/tests/liquidsoap/doc/content/liq/ffmpeg-shared-encoding-rtmp.liq +43 -0
  62. package/tests/liquidsoap/doc/content/liq/ffmpeg-shared-encoding.liq +28 -0
  63. package/tests/liquidsoap/doc/content/liq/frame-size.liq +10 -0
  64. package/tests/liquidsoap/doc/content/liq/harbor-auth.liq +18 -0
  65. package/tests/liquidsoap/doc/content/liq/harbor-insert-metadata.liq +28 -0
  66. package/tests/liquidsoap/doc/content/liq/harbor-metadata.liq +14 -0
  67. package/tests/liquidsoap/doc/content/liq/harbor-redirect.liq +10 -0
  68. package/tests/liquidsoap/doc/content/liq/harbor-simple.liq +10 -0
  69. package/tests/liquidsoap/doc/content/liq/harbor-usage.liq +16 -0
  70. package/tests/liquidsoap/doc/content/liq/harbor.http.register.liq +48 -0
  71. package/tests/liquidsoap/doc/content/liq/harbor.http.response.liq +20 -0
  72. package/tests/liquidsoap/doc/content/liq/hls-metadata.liq +18 -0
  73. package/tests/liquidsoap/doc/content/liq/hls-mp4.liq +35 -0
  74. package/tests/liquidsoap/doc/content/liq/http-input.liq +6 -0
  75. package/tests/liquidsoap/doc/content/liq/icy-update.liq +31 -0
  76. package/tests/liquidsoap/doc/content/liq/input.mplayer.liq +26 -0
  77. package/tests/liquidsoap/doc/content/liq/json-ex.liq +29 -0
  78. package/tests/liquidsoap/doc/content/liq/json-stringify.liq +2 -0
  79. package/tests/liquidsoap/doc/content/liq/json1.liq +3 -0
  80. package/tests/liquidsoap/doc/content/liq/liquidsoap +4 -0
  81. package/tests/liquidsoap/doc/content/liq/live-switch.liq +23 -0
  82. package/tests/liquidsoap/doc/content/liq/medialib.liq +4 -0
  83. package/tests/liquidsoap/doc/content/liq/multitrack-add-video-track.liq +24 -0
  84. package/tests/liquidsoap/doc/content/liq/multitrack-add-video-track2.liq +10 -0
  85. package/tests/liquidsoap/doc/content/liq/multitrack-default-video-track.liq +14 -0
  86. package/tests/liquidsoap/doc/content/liq/multitrack.liq +11 -0
  87. package/tests/liquidsoap/doc/content/liq/multitrack2.liq +16 -0
  88. package/tests/liquidsoap/doc/content/liq/multitrack3.liq +10 -0
  89. package/tests/liquidsoap/doc/content/liq/output.file.hls.liq +44 -0
  90. package/tests/liquidsoap/doc/content/liq/prometheus-callback.liq +18 -0
  91. package/tests/liquidsoap/doc/content/liq/prometheus-settings.liq +3 -0
  92. package/tests/liquidsoap/doc/content/liq/radiopi.liq +467 -0
  93. package/tests/liquidsoap/doc/content/liq/re-encode.liq +14 -0
  94. package/tests/liquidsoap/doc/content/liq/regular.liq +8 -0
  95. package/tests/liquidsoap/doc/content/liq/replaygain-metadata.liq +6 -0
  96. package/tests/liquidsoap/doc/content/liq/replaygain-playlist.liq +6 -0
  97. package/tests/liquidsoap/doc/content/liq/rtmp.liq +10 -0
  98. package/tests/liquidsoap/doc/content/liq/samplerate3.liq +8 -0
  99. package/tests/liquidsoap/doc/content/liq/scheduling.liq +7 -0
  100. package/tests/liquidsoap/doc/content/liq/seek-telnet.liq +23 -0
  101. package/tests/liquidsoap/doc/content/liq/settings.liq +8 -0
  102. package/tests/liquidsoap/doc/content/liq/shoutcast.liq +5 -0
  103. package/tests/liquidsoap/doc/content/liq/space_overhead.liq +9 -0
  104. package/tests/liquidsoap/doc/content/liq/split-cue.liq +21 -0
  105. package/tests/liquidsoap/doc/content/liq/srt-receiver.liq +8 -0
  106. package/tests/liquidsoap/doc/content/liq/srt-sender.liq +4 -0
  107. package/tests/liquidsoap/doc/content/liq/transcoding.liq +18 -0
  108. package/tests/liquidsoap/doc/content/liq/video-anonymizer.liq +31 -0
  109. package/tests/liquidsoap/doc/content/liq/video-bluescreen.liq +14 -0
  110. package/tests/liquidsoap/doc/content/liq/video-in-video.liq +7 -0
  111. package/tests/liquidsoap/doc/content/liq/video-logo.liq +9 -0
  112. package/tests/liquidsoap/doc/content/liq/video-osc.liq +26 -0
  113. package/tests/liquidsoap/doc/content/liq/video-simple.liq +12 -0
  114. package/tests/liquidsoap/doc/content/liq/video-static.liq +20 -0
  115. package/tests/liquidsoap/doc/content/liq/video-text.liq +5 -0
  116. package/tests/liquidsoap/doc/content/liq/video-transition.liq +5 -0
  117. package/tests/liquidsoap/doc/content/liq/video-weather.liq +7 -0
  118. package/tests/liquidsoap/doc/content/liq/video-webcam.liq +1 -0
  119. package/tests/liquidsoap/doc/content/memory.md +2 -14
  120. package/tests/liquidsoap/doc/content/multitrack.md +6 -81
  121. package/tests/liquidsoap/doc/content/prometheus.md +8 -22
  122. package/tests/liquidsoap/doc/content/quick_start.md +1 -1
  123. package/tests/liquidsoap/doc/content/radiopi.md +1 -298
  124. package/tests/liquidsoap/doc/content/replay_gain.md +2 -7
  125. package/tests/liquidsoap/doc/content/seek.md +2 -18
  126. package/tests/liquidsoap/doc/content/shoutcast.md +1 -5
  127. package/tests/liquidsoap/doc/content/split-cue.md +1 -26
  128. package/tests/liquidsoap/doc/content/video-static.md +1 -20
  129. package/tests/liquidsoap/doc/content/video.md +23 -111
  130. package/tests/liquidsoap/doc/dune +6 -0
  131. package/tests/liquidsoap/doc/dune.inc +11350 -406
  132. package/tests/liquidsoap/doc/gen_dune.ml +81 -31
  133. package/tests/liquidsoap/doc/no-pandoc +1 -1
  134. package/tests/liquidsoap/liquidsoap +2 -1
  135. package/tests/liquidsoap/src/core/io/srt_io.ml +12 -3
  136. package/tests/liquidsoap/src/core/operators/video_effects.ml +3 -1
  137. package/tests/liquidsoap/src/core/outputs/output.ml +4 -2
  138. package/tests/liquidsoap/src/core/outputs/output.mli +2 -0
  139. package/tests/liquidsoap/src/core/visualization/video_volume.ml +7 -4
  140. package/tests/liquidsoap/src/js/index.html +2 -2
  141. package/tests/liquidsoap/src/lang/parser.mly +10 -10
  142. package/tests/liquidsoap/src/lang/term/parsed_term.ml +7 -11
  143. package/tests/liquidsoap/src/lang/term/term_reducer.ml +32 -32
  144. package/tests/liquidsoap/src/lang/utils.ml +3 -3
  145. package/tests/liquidsoap/src/libs/file.liq +15 -2
  146. package/tests/liquidsoap/src/libs/playlist.liq +3 -0
  147. package/tests/liquidsoap/src/runtime/main.ml +3 -0
  148. package/tests/liquidsoap/src/tooling/parsed_json.ml +9 -10
  149. package/tests/liquidsoap/tests/language/file.liq +4 -0
  150. package/tests/liquidsoap/tests/language/record.liq +33 -0
  151. package/tests/liquidsoap/tests/language/regexp.liq +2 -0
@@ -63,28 +63,8 @@ source clients should set their connection port to `n+1`.
63
63
  The `auth` function is a function, that takes a record `{user, password, address}` and returns a boolean representing whether the user
64
64
  should be granted access or not. Typical example can be:
65
65
 
66
- ```liquidsoap
67
- def auth(args) =
68
- # Call an external process to check
69
- # the credentials:
70
- # The script will return the string
71
- # "true" of "false"
72
- #
73
- # First call the script. Make sure to apply proper escaping
74
- # of the arguments to prevent command injection!
75
- ret = process.read.lines("/path/to/script \
76
- --user=#{args.user} --password=#{args.password}")
77
- # Then get the first line of its output
78
- ret = list.hd(default="",ret)
79
- # Finally returns the boolean represented
80
- # by the output (bool_of_string can also
81
- # be used)
82
- if ret == "true" then
83
- true
84
- else
85
- false
86
- end
87
- end
66
+ ```{.liquidsoap include="harbor-auth.liq"}
67
+
88
68
  ```
89
69
 
90
70
  In the case of the `ICY` (shoutcast) source protocol, there is no `user` parameter
@@ -101,26 +81,10 @@ When using harbor inputs, you first set the required settings, as described abov
101
81
  The unlabeled parameter is the mount point that the source client may connect
102
82
  to. It should be `"/"` for shoutcast source clients.
103
83
 
104
- The source client may use any of the recognized audio input codec. Hence, when using shoucast source clients, you need to have compiled liquidsoap with mp3 decoding support (`ocaml-mad`)
84
+ The source client may use any of the recognized audio input codec. Hence, when using shoucast source clients, you need to have compiled liquidsoap with mp3 decoding support (`ocaml-mad`).
105
85
 
106
86
  A sample code can be:
107
87
 
108
- ```liquidsoap
109
- settings.harbor.bind_addrs := ["0.0.0.0"]
110
-
111
- # Some code...
112
-
113
- # This defines a source waiting on mount point
114
- # /test-harbor
115
- live = input.harbor("test-harbor",port=8080,password="xxx")
88
+ ```{.liquidsoap include="harbor-usage.liq" to=-1}
116
89
 
117
- # This is the final stream.
118
- # Uses the live source as soon as available,
119
- # and don't wait for an end of track, since
120
- # we don't want to cut the beginning of the live
121
- # stream.
122
- #
123
- # You may insert a jingle transition here...
124
- radio = fallback(track_sensitive=false,
125
- [live,files])
126
90
  ```
@@ -18,21 +18,10 @@ to e.g. write the request data to a file using `file.write.stream`.
18
18
  The `body` method can be used to read all of the request's data and store it in
19
19
  memory. Make sure to only use it if you know that the response should be small enough!
20
20
 
21
- For convenience, a HTTP response builder is provided via `harbor.http.response`. Here's an example:
21
+ For convenience, a HTTP response builder is provided via `http.response`. Here's an example:
22
+
23
+ ```{.liquidsoap include="harbor.http.response.liq" from="BEGIN"}
22
24
 
23
- ```liquidsoap
24
- def handler(request) =
25
- log("Got a request on path #{request.path}, protocol version: #{request.http_version}, \
26
- method: #{request.method}, headers: #{request.headers}, query: #{request.query}, \
27
- body: #{request.body()}")
28
-
29
- harbor.http.response(
30
- content_type="text/html",
31
- data="<p>ok, this works!</p>"
32
- )
33
- end
34
-
35
- harbor.http.register.simple(port=8080, method="GET", path, handler)
36
25
  ```
37
26
 
38
27
  where:
@@ -46,47 +35,8 @@ where:
46
35
  The `harbor.http.register` function offers a higher-level API for advanced HTTP response implementation.
47
36
  Its API is very similar to the node/express API. Here's an example:
48
37
 
49
- ```liquidsoap
50
- def handler(request, response) =
51
- log("Got a request on path #{request.path}, protocol version: #{request.http_version}, \
52
- method: #{request.method}, headers: #{request.headers}, query: #{request.query}, \
53
- body: #{request.body()}")
54
-
55
- # Set response code. Defaults to 200
56
- response.status_code(201)
57
-
58
- # Set response status message. Uses `status_code` if not specified
59
- response.status_message("Created")
60
-
61
- # Replaces response headers
62
- response.headers(["X-Foo", "bar"])
63
-
64
- # Set a single header
65
- response.header("X-Foo", "bar")
66
-
67
- # Set http protocol version
68
- response.http_version("1.1")
69
-
70
- # Same as setting the "Content-Type" header
71
- response.content_type("application/liquidsoap")
72
-
73
- # Set response data. Can be a `string` or a function of type `()->string` returning an empty string
74
- # when done such as `file.read`
75
- response.data("foo")
76
-
77
- # Advanced wrappers:
78
-
79
- # Sets content-type to json and data to `json.stringify({foo = "bla"})`
80
- response.json({foo = "bla"})
38
+ ```{.liquidsoap include="harbor.http.register.liq" from="BEGIN"}
81
39
 
82
- # Sets `status_code` and `Location:` header for a HTTP redirect response. Takes an optional `status_code` argument.
83
- response.redirect("http://...")
84
-
85
- # Sets content-type to html and data to `"<p>It works!</p>"`
86
- response.html("<p>It works!</p>")
87
- end
88
-
89
- harbor.http.register(port=8080, method="GET", path, handler)
90
40
  ```
91
41
 
92
42
  where:
@@ -147,17 +97,8 @@ parameter.
147
97
 
148
98
  It is also possible to directly interact with the underlying socket using the `simple` API:
149
99
 
150
- ```liquidsoap
151
- # Custom response
152
- def handler(req) =
153
- req.socket.write("HTTP/1.0 201 YYR\r\nFoo: bar\r\n\r\n")
154
- req.socket.close()
155
-
156
- # Null indicates that we're using the socket directly.
157
- null()
158
- end
100
+ ```{.liquidsoap include="harbor-simple.liq"}
159
101
 
160
- harbor.http.register.simple("/custom", port=3456, handler)
161
102
  ```
162
103
 
163
104
  ## Examples
@@ -171,23 +112,8 @@ Some source clients using the harbor may also request pages that
171
112
  are served by an icecast server, for instance listeners statistics.
172
113
  In this case, you can register the following handler:
173
114
 
174
- ```liquidsoap
175
- # Redirect all files other
176
- # than /admin.* to icecast,
177
- # located at localhost:8000
178
- def redirect_icecast(request, response) =
179
- response.redirect("http://localhost:8000#{request.path}")
180
- end
181
-
182
- # Register this handler at port 8005
183
- # (provided harbor sources are also served
184
- # from this port).
185
- harbor.http.register.regexp(
186
- port=8005,
187
- method="GET",
188
- r/^\/(?!admin)/,
189
- redirect_icecast
190
- )
115
+ ```{.liquidsoap include="harbor-redirect.liq"}
116
+
191
117
  ```
192
118
 
193
119
  ## Get metadata
@@ -195,19 +121,8 @@ harbor.http.register.regexp(
195
121
  You can use harbor to register HTTP services to
196
122
  fecth/set the metadata of a source.
197
123
 
198
- ```liquidsoap
199
- meta = ref([])
200
-
201
- # s = some source
202
- s.on_metadata(fun (m) -> meta := m)
124
+ ```{.liquidsoap include="harbor-metadata.liq" from="BEGIN"}
203
125
 
204
- # Return the json content of meta
205
- def get_meta(_, response) =
206
- response.json(!meta)
207
- end
208
-
209
- # Register get_meta at port 700
210
- harbor.http.register(port=7000,method="GET","/getmeta",get_meta)
211
126
  ```
212
127
 
213
128
  Once the script is running,
@@ -231,31 +146,8 @@ Content-Type: application/json; charset=utf-8
231
146
  Using `insert_metadata`, you can register a GET handler that
232
147
  updates the metadata of a given source. For instance:
233
148
 
234
- ```liquidsoap
235
- # s = some source
236
-
237
- # Create a source equipped with a `insert_metadata` method:
238
- s = insert_metadata(s)
239
-
240
- # The handler
241
- def set_meta(request, response) =
242
- # Filter out unusual metadata
243
- meta = metadata.export(request.query)
244
-
245
- # Grab the returned message
246
- ret =
247
- if meta != [] then
248
- s.insert_metadata(meta)
249
- "OK!"
250
- else
251
- "No metadata to add!"
252
- end
253
-
254
- response.html("<html><body><b>#{ret}</b></body></html>")
255
- end
256
-
257
- # Register handler on port 700
258
- harbor.http.register(port=7000,method="GET","/setmeta",set_meta)
149
+ ```{.liquidsoap include="harbor-insert-metadata.liq" from="BEGIN"}
150
+
259
151
  ```
260
152
 
261
153
  Now, a request of the form `http://server:7000/setmeta?title=foo`
@@ -113,15 +113,7 @@ application.
113
113
 
114
114
  Some common settings have shortcut for convenience. These are all shortcuts to their respective `settings` values:
115
115
 
116
- ```liquidsoap
117
- log.level := 4
118
- log.file := true
119
- log.stdout := true
120
- init.daemon := true
121
- audio.samplerate := 48000
122
- audio.channels := 2
123
- video.frame.width := 720
124
- video.frame.height := 1280
116
+ ```{.liquidsoap include="settings.liq"}
125
117
 
126
118
  ```
127
119
 
@@ -4,49 +4,8 @@ Starting with liquidsoap `1.4.0`, it is possible to send your streams as [HLS ou
4
4
 
5
5
  The main operator is `output.file.hls`. Here's an example using it, courtesy of [srt2hls](https://github.com/mbugeia/srt2hls):
6
6
 
7
- ```liquidsoap
8
- aac_lofi = %ffmpeg(format="mpegts",
9
- %audio(
10
- codec="aac",
11
- channels=2,
12
- ar=44100
13
- ))
14
-
15
- aac_midfi = %ffmpeg(format="mpegts",
16
- %audio(
17
- codec="aac",
18
- channels=2,
19
- ar=44100,
20
- b="96k"
21
- ))
22
-
23
- aac_hifi = %ffmpeg(format="mpegts",
24
- %audio(
25
- codec="aac",
26
- channels=2,
27
- ar=44100,
28
- b="192k"
29
- ))
30
-
31
- streams = [("aac_lofi",aac_lofi),
32
- ("aac_midfi", aac_midfi),
33
- ("aac_hifi", aac_hifi)]
34
-
35
- def segment_name(~position,~extname,stream_name) =
36
- timestamp = int_of_float(time())
37
- duration = 2
38
- "#{stream_name}_#{duration}_#{timestamp}_#{position}.#{extname}"
39
- end
40
-
41
- output.file.hls(playlist="live.m3u8",
42
- segment_duration=2.0,
43
- segments=5,
44
- segments_overhead=5,
45
- segment_name=segment_name,
46
- persist_at="/path/to/state.config",
47
- "/path/to/hls/directory",
48
- streams,
49
- source)
7
+ ```{.liquidsoap include="output.file.hls.liq"}
8
+
50
9
  ```
51
10
 
52
11
  Let's see what's important here:
@@ -79,29 +38,8 @@ HLS outputs supports metadata in two ways:
79
38
 
80
39
  Metadata parameters are passed through the record methods of the streams' encoders. Here's an example
81
40
 
82
- ```liquidsoap
83
- output.file.hls(
84
- "/path/to/directory",
85
- [
86
- ("aac",
87
- %ffmpeg(format="adts", %audio(codec="aac")).{
88
- id3_version = 3
89
- }),
90
- ("ts-with-meta",
91
- %ffmpeg(format="mpegts", %audio(codec="aac")).{
92
- id3_version = 4
93
- }),
94
- ("ts",
95
- %ffmpeg(format="mpegts", %audio(codec="aac")).{
96
- id3 = false
97
- }),
98
- ("mp3",
99
- %ffmpeg(format="mp3", %audio(codec="libmp3lame")).{
100
- replay_id3 = false
101
- })
102
- ],
103
- source
104
- )
41
+ ```{.liquidsoap include="hls-metadata.liq"}
42
+
105
43
  ```
106
44
 
107
45
  Parameters are:
@@ -117,40 +55,6 @@ Metadata for these formats are activated by default. If you are experiencing any
117
55
  `mp4` container is supported by requires specific parameters. Here's an example that mixes `aac` and `flac` audio, The parameters
118
56
  required for `mp4` are `movflags` and `frag_duration`.
119
57
 
120
- ```liquidsoap
121
- radio = ...
122
-
123
- aac_lofi = %ffmpeg(format="mp4",
124
- %audio(
125
- codec="aac",
126
- channels=2,
127
- ar=44100,
128
- b="192k"
129
- ))
130
-
131
- flac_hifi = %ffmpeg(format="mp4",
132
- strict="-2",
133
- %audio(
134
- codec="flac",
135
- channels=2,
136
- ar=44100
137
- ))
138
-
139
- flac_hires = %ffmpeg(format="mp4",
140
- strict="-2",
141
- %audio(
142
- codec="flac",
143
- channels=2,
144
- ar=48000
145
- ))
146
-
147
- streams = [("aac_lofi", aac_lofi),
148
- ("flac_hifi", flac_hifi),
149
- ("flac_hires", flac_hires)]
150
-
151
-
152
- output.file.hls(playlist="live.m3u8",
153
- "/path/to/directory",
154
- streams,
155
- radio)
58
+ ```{.liquidsoap include="hls-mp4.liq"}
59
+
156
60
  ```
@@ -5,10 +5,8 @@ be a distant file or playlist, or an icecast or shoutcast stream.
5
5
 
6
6
  To use it in your script, simply create a source that way:
7
7
 
8
- ```liquidsoap
9
- # url is a HTTP location, like
10
- # http://radiopi.org:8080/reggae
11
- source = input.http(url)
8
+ ```{.liquidsoap include="http-input.liq" from="BEGIN" to="END"}
9
+
12
10
  ```
13
11
 
14
12
  This operator will pull regularly the given location for its data, so it should be used for
@@ -45,30 +45,8 @@ parameter described above, provided icecast supports ICY metadata for the intend
45
45
  For instance the following script registers a telnet command name `metadata.update`
46
46
  that can be used to manually update metadata:
47
47
 
48
- ```liquidsoap
49
- def icy_update(v) =
50
- # Parse the argument
51
- l = string.split(separator=",",v)
52
- def split(l,v) =
53
- v = string.split(separator="=",v)
54
- if list.length(v) >= 2 then
55
- list.append(l,[(list.nth(v,0,default=""),list.nth(v,1,default=""))])
56
- else
57
- l
58
- end
59
- end
60
- meta = list.fold(split,[],l)
61
-
62
- # Update metadata
63
- icy.update_metadata(mount="/mystream",password="hackme",
64
- host="myserver.net",meta)
65
- "Done !"
66
- end
67
-
68
- server.register("update",namespace="metadata",
69
- description="Update metadata",
70
- usage="update title=foo,album=bar,..",
71
- icy_update)
48
+ ```{.liquidsoap include="icy-update.liq"}
49
+
72
50
  ```
73
51
 
74
52
  As usual, `liquidsoap -h icy.update_metadata` lists all the arguments
@@ -16,10 +16,5 @@ logrotate configuration is also installed so that log files
16
16
  in the standard directory are truncated and compressed if they grow too big.
17
17
 
18
18
  It is not very convenient to detect errors when using the init script.
19
- We advise users to check their scripts after modification (use
20
-
21
- ````
22
- liquidsoap --check /etc/liquidsoap/script.liq```
23
- )
24
- before effectively restarting the daemon.
25
- ````
19
+ We advise users to check their scripts after modification
20
+ (use `liquidsoap --check /etc/liquidsoap/script.liq`) before effectively restarting the daemon.
@@ -8,10 +8,8 @@ Liquidsoap supports importing JSON values through a special `let` syntax. Using
8
8
  makes it relatively natural to parse JSON data in your script while keeping type-safety at runtime.
9
9
  Here's an example:
10
10
 
11
- ```liquidsoap
12
- let json.parse v = '{"foo": "abc"}'
11
+ ```{.liquidsoap include="json1.liq"}
13
12
 
14
- print("We parsed a JSON object and got value " ^ v.foo ^ " for attribute foo!")
15
13
  ```
16
14
 
17
15
  This prints:
@@ -250,36 +248,13 @@ end
250
248
 
251
249
  Here's a full example. Feel free to refer to `tests/language/json.liq` in the source code for more of them.
252
250
 
253
- ```liquidsoap
254
- data = '{
255
- "foo": 34.24,
256
- "gni gno": true,
257
- "nested": {
258
- "tuple": [123, 3.14, false],
259
- "list": [44.0, 55, 66.12],
260
- "nullable_list": [12.33, 23, "aabb"],
261
- "object_as_list": {
262
- "foo": 123,
263
- "gni": 456.0,
264
- "gno": 3.14
265
- },
266
- "arbitrary object key ✨": true
267
- },
268
- "extra": "ignored"
269
- }'
270
-
271
- let json.parse ( x : {
272
- foo: float,
273
- "gni gno" as gni_gno: bool,
274
- nested: {
275
- tuple: (_ * float),
276
- list: [float],
277
- nullable_list: [int?],
278
- object_as_list: [(string * float)] as json.object,
279
- "arbitrary object key ✨" as arbitrary_object_key: bool,
280
- not_present: bool?
281
- }
282
- }) = data
251
+ ```{.liquidsoap include="json-ex.liq"}
252
+
253
+ ```
254
+
255
+ It returns
256
+
257
+ ```
283
258
  - x : {
284
259
  foo = 34.24,
285
260
  gni_gno = true,
@@ -308,9 +283,8 @@ If a `json5` variable is in scope, you can also simply use `let json.parse[json5
308
283
 
309
284
  Exporting JSON values can be done using the `json.stringify` function:
310
285
 
311
- ```liquidsoap
312
- r = {artist = "Bla", title = "Blo"}
313
- print(json.stringify(r))
286
+ ```{.liquidsoap include="json-stringify.liq"}
287
+
314
288
  ```
315
289
 
316
290
  Please note that not all values are exportable as JSON, for instance function. In such cases the function will raise an `error.json` exception.
@@ -699,7 +699,7 @@ for such arguments, the default value will be used. For instance, if for some
699
699
  reason we tend to generally measure samples over a period of 2.5 seconds, we can
700
700
  make this become the value for the `duration` parameter:
701
701
 
702
- ```{.liquidsoap include="liq/samplerate3.liq" from=0 to=0}
702
+ ```{.liquidsoap include="samplerate3.liq" from="BEGIN" to="END"}
703
703
 
704
704
  ```
705
705
 
@@ -0,0 +1,8 @@
1
+ all:
2
+
3
+ check:
4
+ @for i in *.liq; do \
5
+ echo -n "Testing $$i... "; \
6
+ ./liquidsoap --check $$i; \
7
+ echo " done"; \
8
+ done
@@ -0,0 +1,46 @@
1
+ # The live source. We use a short buffer to switch more quickly to the source
2
+ # when reconnecting.
3
+ live_source = input.harbor("mount-point-name", buffer=3.)
4
+
5
+ # A playlist source.
6
+ playlist_source = playlist("/path/to/playlist")
7
+
8
+ # Set to `true` when we should be adding silence.
9
+ should_append = ref(false)
10
+
11
+ # Append 5. of silence when needed.
12
+ fallback_source = append(
13
+ playlist_source, fun (_) ->
14
+ if should_append() then
15
+ should_append := false
16
+ blank(duration=5.)
17
+ else
18
+ source.fail()
19
+ end
20
+ )
21
+
22
+ # Transition to live
23
+ def to_live(playlist, live) =
24
+ sequence([playlist,live])
25
+ end
26
+
27
+ # Transition back to playlist
28
+ def to_playlist(live, playlist) =
29
+ # Ask to insert a silent track.
30
+ should_append := true
31
+
32
+ # Cancel current track. This will also set the playlist to play a new
33
+ # track. If needed, `cancel_pending` can be used to for a new silent track
34
+ # without skipping the playlist current track.
35
+ fallback_source.skip()
36
+
37
+ sequence([live, playlist])
38
+ end
39
+
40
+ radio = fallback(
41
+ track_sensitive=false,
42
+ transitions=[to_live, to_playlist],
43
+ [live_source, fallback_source]
44
+ )
45
+ # END
46
+ output.dummy(fallible=true, radio)
@@ -0,0 +1,29 @@
1
+ BEET = "/usr/bin/beet"
2
+ # BEGIN
3
+ def beets(id, query) =
4
+ beets_src =
5
+ blank.eat(
6
+ id="#{id}_",
7
+ start_blank=true,
8
+ max_blank=1.0,
9
+ threshold=-45.0,
10
+ amplify(
11
+ override="replaygain_track_gain",
12
+ 1.0,
13
+ request.dynamic(
14
+ id=id,
15
+ retry_delay=1.,
16
+ {
17
+ request.create(
18
+ string.trim(
19
+ process.read(
20
+ "#{BEET} random -f '$path' #{query}"
21
+ )
22
+ )
23
+ )
24
+ }
25
+ )
26
+ )
27
+ )
28
+ (beets_src : source)
29
+ end
@@ -0,0 +1,26 @@
1
+ BEET = "/usr/bin/beets"
2
+
3
+ # BEGIN
4
+ def beets_protocol(~rlog, ~maxtime, arg) =
5
+ timeout = maxtime - time()
6
+ command =
7
+ "#{BEET} random -f '$path' #{arg}"
8
+ p = process.run(timeout=timeout, command)
9
+ if
10
+ p.status == "exit" and p.status.code == 0
11
+ then
12
+ [string.trim(p.stdout)]
13
+ else
14
+ rlog(
15
+ "Failed to execute #{command}: #{p.status} (#{p.status.code}) #{p.stderr}"
16
+ )
17
+ []
18
+ end
19
+ end
20
+ protocol.add(
21
+ "beets",
22
+ beets_protocol,
23
+ syntax=
24
+ "same arguments as beet's random module, see \
25
+ https://beets.readthedocs.io/en/stable/reference/query.html"
26
+ )
@@ -0,0 +1,21 @@
1
+ BEET = "/usr/bin/beet"
2
+ # BEGIN
3
+ def beets(id, query) =
4
+ beets_src =
5
+ request.dynamic(id=id, retry_delay=1., {
6
+ request.create(
7
+ string.trim(
8
+ process.read("#{BEET} random -f '$path' #{query}")
9
+ )
10
+ )
11
+ })
12
+ (beets_src:source)
13
+ end
14
+
15
+ all_music = beets("all_music", "")
16
+ recent_music = beets("recent_music", "added:-1m..")
17
+ rock_music = beets("rock_music", "genre:Rock")
18
+ # END
19
+ output.dummy(fallible=true,all_music)
20
+ output.dummy(fallible=true,recent_music)
21
+ output.dummy(fallible=true,rock_music)
@@ -0,0 +1,10 @@
1
+ s = playlist("my-playlist")
2
+ # BEGIN
3
+ def handler() =
4
+ process.run(
5
+ "/path/to/your/script to do whatever you want"
6
+ )
7
+ end
8
+ s = blank.detect(handler, s)
9
+ # END
10
+ output.dummy(fallible=true, s)
@@ -0,0 +1,11 @@
1
+ live = input.pulseaudio()
2
+ interlude = single("/path/to/sorryfortheblank.ogg")
3
+
4
+ # After 5 sec of blank the microphone stream is ignored, which causes the stream
5
+ # to fallback to interlude. As soon as noise comes back to the microphone the
6
+ # stream comes back to the live -- thanks to track_sensitive=false.
7
+ stream =
8
+ fallback(track_sensitive=false, [blank.strip(max_blank=5., live), interlude])
9
+
10
+ # Put that stream to a local file
11
+ output.file(%vorbis, "/tmp/hop.ogg", stream)
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ # shellcheck disable=SC2068
3
+
4
+ ../../../liquidsoap --check $@