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
@@ -16,7 +16,7 @@ jobs:
16
16
  pre-commit:
17
17
  runs-on: ubuntu-latest
18
18
  steps:
19
- - uses: actions/checkout@v3
19
+ - uses: actions/checkout@v4
20
20
  - uses: actions/setup-python@v4
21
21
  with:
22
22
  python-version: "3.x"
@@ -73,17 +73,22 @@ jobs:
73
73
  git remote set-url origin https://github.com/savonet/liquidsoap.git
74
74
  git fetch origin ${{ github.sha }}
75
75
  git checkout ${{ github.sha }}
76
+ - name: Install pandoc
77
+ run: |
78
+ cd /tmp
79
+ git clone https://github.com/smimram/ocaml-pandoc.git
80
+ opam pin -y add ocaml-pandoc
76
81
  - name: Build
77
82
  run: |
78
83
  echo "::group::Preparing build"
79
84
  cd /tmp/liquidsoap-full
80
85
  git remote set-url origin https://github.com/savonet/liquidsoap-full.git
81
- git fetch --recurse-submodules=no && git checkout origin/master -- Makefile.git
86
+ git fetch --recurse-submodules=no
87
+ git checkout origin/master -- Makefile.git
82
88
  make public
83
89
  git reset --hard
84
90
  git pull
85
91
  cp PACKAGES.minimal PACKAGES
86
- eval $(opam env)
87
92
  opam pin -yn .
88
93
  opam info -f "depopts:" liquidsoap-core | grep -v osx-secure-transport | xargs opam remove --force -y ffmpeg-avutil cohttp-lwt-unix prometheus-app ${{ needs.build_details.outputs.minimal_exclude_deps }}
89
94
  echo "::endgroup::"
@@ -118,8 +123,6 @@ jobs:
118
123
  run: |
119
124
  cd /tmp/liquidsoap-full/liquidsoap
120
125
  eval "$(opam config env)"
121
- opam update
122
- opam install -y re.1.11.0
123
126
  dune build --profile release ./src/js/interactive_js.bc.js
124
127
 
125
128
  tree_sitter_parse:
@@ -182,6 +185,11 @@ jobs:
182
185
  run: |
183
186
  apt-get update
184
187
  apt-get install -y npm
188
+ - name: Install pandoc
189
+ run: |
190
+ cd /tmp
191
+ sudo -u opam -E git clone https://github.com/smimram/ocaml-pandoc.git
192
+ sudo -u opam -E opam pin -y add ocaml-pandoc
185
193
  - name: Build doc
186
194
  env:
187
195
  CPU_CORES: ${{ steps.cpu_cores.outputs.count }}
@@ -189,7 +197,6 @@ jobs:
189
197
  cd /tmp/liquidsoap-full/liquidsoap
190
198
  # TMP
191
199
  sudo -u opam -E ./.github/scripts/add-local-opam-packages.sh
192
- sudo -u opam -E opam install -y ssl.0.7.0
193
200
  sudo -u opam -E ./.github/scripts/build-posix.sh "${{ steps.cpu_cores.outputs.count }}"
194
201
  cd /tmp/liquidsoap-full/liquidsoap/
195
202
  eval $(opam config env)
@@ -218,7 +225,7 @@ jobs:
218
225
  strategy:
219
226
  fail-fast: false
220
227
  matrix:
221
- target: ["@citest", "@mediatest"]
228
+ target: ["@citest", "@doctest", "@mediatest"]
222
229
  env:
223
230
  HOME: /home/opam
224
231
  steps:
@@ -238,6 +245,15 @@ jobs:
238
245
  sudo -u opam -E git remote set-url origin https://github.com/savonet/liquidsoap.git
239
246
  sudo -u opam -E git fetch origin ${{ github.sha }}
240
247
  sudo -u opam -E git checkout ${{ github.sha }}
248
+ - name: Install pandoc
249
+ run: |
250
+ cd /tmp
251
+ if [ ! -d ocaml-pandoc ]; then
252
+ mkdir -p ocaml-pandoc;
253
+ chown -R opam ocaml-pandoc;
254
+ sudo -u opam -E git clone https://github.com/smimram/ocaml-pandoc.git ocaml-pandoc
255
+ fi
256
+ sudo -u opam -E opam pin -y add ocaml-pandoc
241
257
  - name: Build
242
258
  env:
243
259
  CPU_CORES: ${{ steps.cpu_cores.outputs.count }}
@@ -245,13 +261,18 @@ jobs:
245
261
  cd /tmp/liquidsoap-full/liquidsoap
246
262
  # TMP
247
263
  sudo -u opam -E ./.github/scripts/add-local-opam-packages.sh
248
- sudo -u opam -E opam install -y ssl.0.7.0
249
264
  sudo -u opam -E ./.github/scripts/build-posix.sh "${{ steps.cpu_cores.outputs.count }}"
250
265
  cp /tmp/liquidsoap-full/liquidsoap/_build/default/src/bin/liquidsoap.exe /tmp/${{ github.run_number }}/core/liquidsoap
251
266
  - name: Compute stats
252
267
  run: |
253
268
  cd /tmp/liquidsoap-full/liquidsoap
254
269
  sudo -u opam -E ./.github/scripts/stats-posix.sh
270
+ - name: Install additional packages
271
+ if: matrix.target == '@doctest'
272
+ run: |
273
+ apt-get -y update
274
+ apt-get -y install frei0r-plugins
275
+ sudo -u opam -E opam install -y prometheus-liquidsoap
255
276
  - name: Run tests
256
277
  env:
257
278
  CPU_CORES: ${{ steps.cpu_cores.outputs.count }}
@@ -270,7 +291,7 @@ jobs:
270
291
  name: metrics
271
292
  path: ${{ github.workspace }}/${{ github.run_number }}/metrics
272
293
  - name: Upload metrics
273
- if: needs.build_details.outputs.is_fork != 'true' && matrix.target != '@mediatest'
294
+ if: needs.build_details.outputs.is_fork != 'true' && matrix.target == '@citest'
274
295
  uses: peaceiris/actions-gh-pages@v3
275
296
  with:
276
297
  github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -378,13 +399,17 @@ jobs:
378
399
  if: matrix.os == 'alpine'
379
400
  run: |
380
401
  apk -U --force-overwrite upgrade
402
+ - name: Install pandoc
403
+ run: |
404
+ cd /tmp
405
+ sudo -u opam -E git clone https://github.com/smimram/ocaml-pandoc.git ocaml-pandoc
406
+ sudo -u opam -E opam pin -y add ocaml-pandoc
381
407
  - name: Build
382
408
  run: |
383
409
  cd /tmp/liquidsoap-full/liquidsoap
384
410
  export CPU_CORES=${{ steps.cpu_cores.outputs.count }}
385
411
  # TMP
386
412
  sudo -u opam -E ./.github/scripts/add-local-opam-packages.sh
387
- sudo -u opam -E opam install -y ssl.0.7.0
388
413
  sudo -u opam -E ./.github/scripts/build-posix.sh "${{ steps.cpu_cores.outputs.count }}" ${{ matrix.platform }}
389
414
  - name: Build doc
390
415
  if: contains(matrix.os, 'debian') || contains(matrix.os, 'ubuntu')
@@ -28,7 +28,7 @@ repos:
28
28
  - id: ocamlformat
29
29
 
30
30
  - repo: https://github.com/savonet/pre-commit-liquidsoap
31
- rev: a0fd8e7
31
+ rev: 754afa5
32
32
  hooks:
33
33
  - id: liquidsoap-prettier
34
34
 
@@ -14,6 +14,7 @@ New:
14
14
  - Add `compute` parameter to `file.replaygain` to control gain calculation (#3438).
15
15
  - Add `compute` parameter to `enable_replaygain_metadata` to control replay gain calculation (#3438).
16
16
  - Add `copy:` protocol (##3506)
17
+ - Add `file.touch`.
17
18
 
18
19
  Changed:
19
20
 
@@ -0,0 +1,17 @@
1
+ cff-version: 1.2.0
2
+ message: "In order to reference this software, please cite it as below."
3
+ abstract: "Liquidsoap is a powerful and flexible language for describing your streams. It offers a rich collection of operators that you can combine at will, giving you more power than you need for creating or transforming streams. But liquidsoap is still very light and easy to use, in the Unix tradition of simple strong components working together."
4
+ authors:
5
+ - family-names: "Beauxis"
6
+ given-names: "Romain"
7
+ - family-names: "Mimram"
8
+ given-names: "Samuel"
9
+ orcid: "https://orcid.org/0000-0002-0767-2569"
10
+ title: "Liquidsoap"
11
+ version: 2.2.2
12
+ doi: 10.5281/zenodo.1234
13
+ date-released: 2023-11-04
14
+ url: "https://www.liquidsoap.info/"
15
+ repository-code: "https://github.com/savonet/liquidsoap"
16
+ license: GPL-2.0
17
+ type: software
@@ -0,0 +1,17 @@
1
+ MD = $(wildcard content/*.md)
2
+
3
+ all: dune
4
+ @dune build @doc
5
+
6
+ test: dune
7
+ @for i in $(MD); do \
8
+ echo -n "Compiling $$i... "; \
9
+ pandoc $$i -t json | pandoc-include --directory "content/liq" | pandoc -f json --metadata title="bla" --template=template.html -o /tmp/`basename $$i .md`.html; \
10
+ echo "done"; \
11
+ done
12
+ @dune build @doctest
13
+
14
+ dune:
15
+ @dune build @gendune --auto-promote
16
+
17
+ .PHONY: dune
@@ -75,22 +75,8 @@ We rely on `request.dynamic` to call `beet random`
75
75
  (with `-f '$path'` option so beets only returns the matching track's path)
76
76
  every time the source must prepare a new track:
77
77
 
78
- ```liquidsoap
79
- def beets(id, query) =
80
- beets_src =
81
- request.dynamic(id=id, retry_delay=1., {
82
- request.create(
83
- string.trim(
84
- process.read("#{BEET} random -f '$path' #{query}")
85
- )
86
- )
87
- })
88
- (beets_src:source)
89
- end
90
-
91
- all_music = beets("all_music", "")
92
- recent_music = beets("recent_music", "added:-1m..")
93
- rock_music = beets("rock_music", "genre:Rock")
78
+ ```{.liquidsoap include="beets-source.liq" from="BEGIN" to="END"}
79
+
94
80
  ```
95
81
 
96
82
  Note that
@@ -115,22 +101,8 @@ import:
115
101
 
116
102
  Then we only need to add `amplify` to our source creation function. In the example below we also add `blank.eat`, to automatically cut silence at the beginning or end of tracks.
117
103
 
118
- ```liquidsoap
119
- def beets(id, query) =
120
- beets_src =
121
- blank.eat(id="#{id}_", start_blank=true, max_blank=1.0, threshold=-45.0,
122
- amplify(override="replaygain_track_gain", 1.0,
123
- request.dynamic(id=id, retry_delay=1., {
124
- request.create(
125
- string.trim(
126
- process.read("#{BEET} random -f '$path' #{query}")
127
- )
128
- )
129
- })
130
- )
131
- )
132
- (beets_src:source)
133
- end
104
+ ```{.liquidsoap include="beets-amplify.liq" from="BEGIN"}
105
+
134
106
  ```
135
107
 
136
108
  This is the recommended Beets integration ;
@@ -145,21 +117,8 @@ In that case,
145
117
  the list of paths returned by `beet random -f '$path'` fits directly
146
118
  what's needed by protocol resolution:
147
119
 
148
- ```liquidsoap
149
- def beets_protocol(~rlog,~maxtime,arg) =
150
- timeout = maxtime - time()
151
- command = "#{BEET} random -f '$path' #{arg}"
152
- p = process.run(timeout=timeout, command)
153
- if p.status == "exit" and p.status.code == 0 then
154
- [string.trim(p.stdout)]
155
- else
156
- rlog("Failed to execute #{command}: #{p.status} (#{p.status.code}) #{p.stderr}")
157
- []
158
- end
159
- end
160
- protocol.add("beets", beets_protocol,
161
- syntax = "same arguments as beet's random module, see https://beets.readthedocs.io/en/stable/reference/query.html"
162
- )
120
+ ```{.liquidsoap include="beets-protocol.liq" from="BEGIN"}
121
+
163
122
  ```
164
123
 
165
124
  Once this is done,
@@ -10,7 +10,7 @@ usage is simple:
10
10
 
11
11
  ```liquidsoap
12
12
  # Wrap it with a blank skipper
13
- source = blank.skip(source)
13
+ s = blank.skip(s)
14
14
  ```
15
15
 
16
16
  At [RadioPi](http://www.radiopi.org/) they have another problem: sometimes they
@@ -23,17 +23,8 @@ listeners get some silence again. To avoid that problem we made the
23
23
  (i.e. declare it as unavailable), which perfectly suits the typical setup used
24
24
  for live shows:
25
25
 
26
- ```liquidsoap
27
- interlude = single("/path/to/sorryfortheblank.ogg")
28
- # After 5 sec of blank the microphone stream is ignored,
29
- # which causes the stream to fallback to interlude.
30
- # As soon as noise comes back to the microphone the stream comes
31
- # back to the live -- thanks to track_sensitive=false.
32
- stream = fallback(track_sensitive=false,
33
- [ blank.strip(max_blank=5.,live) , interlude ])
34
-
35
- # Put that stream to a local file
36
- output.file(%vorbis, "/tmp/hop.ogg", stream)
26
+ ```{.liquidsoap include="blank-sorry.liq"}
27
+
37
28
  ```
38
29
 
39
30
  If you don't get the difference between these two operators, you should learn
@@ -42,9 +33,6 @@ more about liquidsoap's notion of [source](sources.html).
42
33
  Finally, if you need to do some custom action when there's too much blank, we
43
34
  have `blank.detect`:
44
35
 
45
- ```liquidsoap
46
- def handler()
47
- system("/path/to/your/script to do whatever you want")
48
- end
49
- source = blank.detect(handler,source)
36
+ ```{.liquidsoap include="blank-detect.liq" from="BEGIN" to="END"}
37
+
50
38
  ```
@@ -15,60 +15,8 @@ Once you've managed to describe what you want in such a modular way, you're half
15
15
 
16
16
  Now here is how to write that in [Liquidsoap](index.html).
17
17
 
18
- ```liquidsoap
19
- #!/usr/bin/liquidsoap
20
-
21
- # Lines starting with # are comments, they are ignored.
22
-
23
- # Put the log file in some directory where
24
- # you have permission to write.
25
- log.file.path := "/tmp/<script>.log"
26
- # Print log messages to the console,
27
- # can also be done by passing the -v option to liquidsoap.
28
- log.stdout := true
29
- # Use the telnet server for requests
30
- settings.server.telnet := true
31
-
32
- # A bunch of files and playlists,
33
- # supposedly all located in the same base dir.
34
-
35
- default = single("~/radio/default.ogg")
36
-
37
- day = playlist("~/radio/day.pls")
38
- night = playlist("~/radio/night.pls")
39
- jingles = playlist("~/radio/jingles.pls")
40
- clock = single("~/radio/clock.ogg")
41
-
42
- # Play user requests if there are any,
43
- # otherwise one of our playlists,
44
- # and the default file if anything goes wrong.
45
- radio = fallback([ request.queue(id="request"),
46
- switch([({ 6h-22h }, day),
47
- ({ 22h-6h }, night)]),
48
- default])
49
- # Add the normal jingles
50
- radio = random(weights=[1,5],[ jingles, radio ])
51
- # And the clock jingle
52
- radio = add([radio, switch([({0m0s},clock)])])
53
-
54
- # Add the ability to relay live shows
55
- full =
56
- fallback(track_sensitive=false,
57
- [input.http("http://localhost:8000/live.ogg"),
58
- radio])
59
-
60
- # Output the full stream in OGG and MP3
61
- output.icecast(%mp3,
62
- host="localhost",port=8000,password="hackme",
63
- mount="radio",full)
64
- output.icecast(%vorbis,
65
- host="localhost",port=8000,password="hackme",
66
- mount="radio.ogg",full)
18
+ ```{.liquidsoap include="complete-case.liq"}
67
19
 
68
- # Output the stream without live in OGG
69
- output.icecast(%vorbis,
70
- host="localhost",port=8000,password="hackme",
71
- mount="radio_nolive.ogg",radio)
72
20
  ```
73
21
 
74
22
  To try this example you need to edit the file names. In order to witness the switch from one playlist to another you can change the time intervals. If it is 16:42, try the intervals `0h-16h45` and `16h45-24h` instead of `6h-22h` and `22h-6h`. To witness the clock jingle, you can ask for it to be played every minute by using the `0s` interval instead of `0m0s`.
@@ -48,27 +48,8 @@ When building your stream, you'll often need to make it unfallible. Usually, you
48
48
 
49
49
  [Liquidsoap](index.html) can achieve basic streaming tasks like transcoding with ease. You input any number of "source" streams using `input.http`, and then transcode them to any number of formats / bitrates / etc. The only limitation is your hardware: encoding and decoding are both heavy on CPU. If you want to get the best use of CPUs (multicore, memory footprint etc.) when encoding media with Liquidsoap, we recommend using the `%ffmpeg` encoders.
50
50
 
51
- ```liquidsoap
52
- # Input the stream,
53
- # from an Icecast server or any other source
54
- url = "https://icecast.radiofrance.fr/fip-hifi.aac"
55
- input = mksafe(input.http(url))
56
-
57
- # First transcoder: MP3 32 kbps
58
- # We also degrade the samplerate, and encode in mono
59
- # Accordingly, a mono conversion is performed on the input stream
60
- output.icecast(
61
- %mp3(bitrate=32, samplerate=22050, stereo=false),
62
- mount="/your-stream-32.mp3",
63
- host="streaming.example.com", port=8000, password="xxx",
64
- mean(input))
51
+ ```{.liquidsoap include="transcoding.liq"}
65
52
 
66
- # Second transcoder : MP3 128 kbps using %ffmpeg
67
- output.icecast(
68
- %ffmpeg(format="mp3", %audio(codec="libmp3lame", b="128k")),
69
- mount="/your-stream-128.mp3",
70
- host="streaming.example.com", port=8000, password="xxx",
71
- input)
72
53
  ```
73
54
 
74
55
  ## Re-encoding a file
@@ -83,41 +64,16 @@ to encode the file as quickly as possible.
83
64
  Finally, we use the `on_stop` handler to shutdown
84
65
  liquidsoap when streaming is finished.
85
66
 
86
- ```liquidsoap
87
- # The input file,
88
- # any format supported by liquidsoap
89
- input = "/tmp/input.mp3"
90
-
91
- # The output file
92
- output = "/tmp/output.ogg"
93
-
94
- # A source that plays the file once
95
- source = once(single(input))
67
+ ```{.liquidsoap include="re-encode.liq"}
96
68
 
97
- # We use a clock with disabled synchronization
98
- clock.assign_new(sync="none",[source])
99
-
100
- # Finally, we output the source to an
101
- # ogg/vorbis file
102
- output.file(%vorbis, output,fallible=true,
103
- on_stop=shutdown,source)
104
69
  ```
105
70
 
106
71
  ## RTMP server
107
72
 
108
73
  With our [FFmpeg support](ffmpeg.html), it is possible to create a simple RTMP server with no re-encoding:
109
74
 
110
- ```liquidsoap
111
- s = playlist("...")
75
+ ```{.liquidsoap include="rtmp.liq"}
112
76
 
113
- enc = %ffmpeg(
114
- format="flv",
115
- listen=1,
116
- %audio.copy,
117
- %video.copy
118
- )
119
-
120
- output.url(url="rtmp://host/app/instance", enc, s)
121
77
  ```
122
78
 
123
79
  ## Transmitting signal
@@ -127,36 +83,24 @@ the SRT transport protocol:
127
83
 
128
84
  Sender:
129
85
 
130
- ```liquidsoap
131
- enc = %ffmpeg(
132
- format="s16le",
133
- %audio(
134
- codec="pcm_s16le",
135
- ac=2,
136
- ar=48000
137
- )
138
- )
139
- output.srt(enc, s)
86
+ ```{.liquidsoap include="srt-sender.liq" from="BEGIN"}
87
+
140
88
  ```
141
89
 
142
90
  Receiver:
143
91
 
144
- ```liquidsoap
145
- s = input.srt(
146
- content_type="application/ffmpeg;format=s16le,ch_layout=stereo,sample_rate=48000"
147
- )
92
+ ```{.liquidsoap include="srt-receiver.liq" to="END"}
93
+
148
94
  ```
149
95
 
150
96
  ## Scheduling
151
97
 
152
- ```liquidsoap
153
- # A fallback switch
154
- fallback([playlist("http://my/playlist"),
155
- single("/my/jingle.ogg")])
98
+ ```{.liquidsoap include="fallback.liq" to="END"}
99
+
100
+ ```
101
+
102
+ ```{.liquidsoap include="scheduling.liq" from="BEGIN" to="END"}
156
103
 
157
- # A scheduler,
158
- # assuming you have defined the night and day sources
159
- switch([ ({0h-7h}, night), ({7h-24h}, day) ])
160
104
  ```
161
105
 
162
106
  ## Generating playlists from a media library
@@ -170,11 +114,8 @@ stored to avoid reindexing at each run). The resulting object can then
170
114
  be queried with the `find` method in order to return all files matching the given
171
115
  conditions and thus generate a playlist:
172
116
 
173
- ```liquidsoap
174
- m = medialib(persistency="/tmp/medialib.json", "~/Music/")
175
- l = m.find(artist_contains="Brassens")
176
- l = list.shuffle(l)
177
- output(playlist.list(l))
117
+ ```{.liquidsoap include="medialib.liq"}
118
+
178
119
  ```
179
120
 
180
121
  The parameter of the `find` method follow the following convention:
@@ -219,10 +160,8 @@ It can be useful to have a special playlist that is played at least every 20 min
219
160
  You may think of a promotional playlist for instance.
220
161
  Here is the recipe:
221
162
 
222
- ```liquidsoap
223
- # (1200 sec = 20 min)
224
- timed_promotions = delay(1200.,promotions)
225
- main_source = fallback([timed_promotions,other_source])
163
+ ```{.liquidsoap include="regular.liq" from="BEGIN" to="END"}
164
+
226
165
  ```
227
166
 
228
167
  Where promotions is a source selecting the file to be promoted.
@@ -338,53 +277,8 @@ to add an extra `5s` of silence when transitioning out of a live `input.harbor`
338
277
 
339
278
  This can be done with the `append` operator:
340
279
 
341
- ```liquidsoap
342
- # The live source. We use a short buffer to switch
343
- # more quickly to the source when reconnecting
344
- live_source = input.harbor("mount-point-name", buffer=3.)
345
-
346
- # A playlist source.
347
- playlist_source = playlist("/path/to/playlist")
348
-
349
- # Set to `true` when we should be adding
350
- # silence
351
- should_append = ref(false)
352
-
353
- # Append 5. of silence when needed.
354
- fallback_source = append(
355
- playlist_source, fun (_) ->
356
- if should_append() then
357
- should_append := false
358
- blank(duration=5.)
359
- else
360
- source.fail()
361
- end
362
- )
363
-
364
- # Transition to live
365
- def to_live(playlist, live) =
366
- sequence([playlist,live])
367
- end
368
-
369
- # Transition back to playlist
370
- def to_playlist(live, playlist) =
371
- # Ask to insert a silent track.
372
- should_append := true
373
-
374
- # Cancel current track. This will also set the playlist
375
- # to play a new track. If needed, `cancel_pending` can
376
- # be used to for a new silent track without skipping the
377
- # playlist current track.
378
- fallback_source.skip()
379
-
380
- sequence([live, playlist])
381
- end
280
+ ```{.liquidsoap include="append-silence.liq" to="END"}
382
281
 
383
- radio = fallback(
384
- track_sensitive=false,
385
- transitions=[to_live, to_playlist],
386
- [live_source, fallback_source]
387
- )
388
282
  ```
389
283
 
390
284
  ## Dump a stream into segmented files
@@ -393,20 +287,15 @@ It is sometimes useful (or even legally necessary) to keep a backup of an audio
393
287
  stream. Storing all the stream in one file can be very impractical. In order to
394
288
  save a file per hour in wav format, the following script can be used:
395
289
 
396
- ```liquidsoap
397
- # A source to dump
398
- # s = ...
290
+ ```{.liquidsoap include="dump-hourly.liq" from="BEGIN"}
399
291
 
400
- # Dump the stream
401
- output.file(%wav, {time.string("/archive/%Y-%m-%d/%Y-%m-%d-%H_%M_%S.mp3")}, s, reopen_when={0m})
402
292
  ```
403
293
 
404
294
  In the following variant we write a new mp3 file each time new metadata is
405
295
  coming from `s`:
406
296
 
407
- ```liquidsoap
408
- filename = {time.string('/archive/$(if $(title),"$(title)","Unknown archive")-%Y-%m-%d/%Y-%m-%d-%H_%M_%S.mp3')}
409
- output.file(%mp3, filename, s, reopen_on_metadata=true)
297
+ ```{.liquidsoap include="dump-hourly2.liq" from="BEGIN"}
298
+
410
299
  ```
411
300
 
412
301
  In the two examples we use [string interpolation](language.html) and time
@@ -441,37 +330,10 @@ One limitation of these transitions, however, is that if the transition happen r
441
330
 
442
331
  Crossfade-based transitions are more complex and involve buffering source data in advance to be able to compute a transition where ending and starting track potentially overlap. This does not work with all type of sources since some of them, such as `input.http` may only receive data at real-time rate and cannot be accelerated to buffer their data or else we risk running out of data.
443
332
 
444
- We provide a default operator named `smart_cross` which may be suitable for most usage. But you can also create your own customized crossfade transitions. This is in particular true if you are expecting crossfade transitions between tracks of your `music` source but not between a `music` track and e.g. some jingles. Here's how to do it in this case:
445
-
446
- ```liquidsoap
447
- # A function to add a source_tag metadata to a source:
448
- def source_tag(s,tag) =
449
- def f(_)
450
- [("source_tag",(tag:string))]
451
- end
452
- metadata.map(id=tag,insert_missing=true,f,s)
453
- end
333
+ We provide a default operator named `cross.smart` which may be suitable for most usage. But you can also create your own customized crossfade transitions. This is in particular true if you are expecting crossfade transitions between tracks of your `music` source but not between a `music` track and e.g. some jingles. Here's how to do it in this case:
454
334
 
455
- # Tag our sources
456
- music = source_tag(..., "music")
457
- jingles = source_tag(..., "jingles")
458
-
459
- # Combine them with one jingle every 3 music tracks
460
- radio = rotate(weights = [1,3],[jingles,music])
461
-
462
- # Now a custom crossfade transition:
463
- def transition(a,b)
464
- # If old or new source is not music, no fade
465
- if a.metadata["source_tag"] != "music" or a.metadata["source_tag"] != "music" then
466
- sequence([a.source, b.source])
467
- else
468
- # Else, apply the standard smart transition
469
- cross.smart(a, b)
470
- end
471
- end
335
+ ```{.liquidsoap include="cross.smart.liq" from="BEGIN" to="END"}
472
336
 
473
- # Apply it!
474
- radio = cross(duration=5., transition, radio)
475
337
  ```
476
338
 
477
339
  ## Alsa unbuffered output
@@ -494,17 +356,8 @@ Could not set buffer size to 'frame.size' (1920 samples), got 2048.
494
356
 
495
357
  The solution is then to set liquidsoap's internal frame size to this value, which is most likely specific to your hardware. Let's try this script:
496
358
 
497
- ```liquidsoap
498
- # Set correct frame size:
499
- # This makes it possible to set any audio frame size.
500
- # Make sure that you do NOT use video in this case!
501
- video.frame.rate := 0
502
-
503
- # Now set the audio frame size exactly as required:
504
- settings.frame.audio.size := 2048
359
+ ```{.liquidsoap include="frame-size.liq"}
505
360
 
506
- input = input.alsa(bufferize=false)
507
- output.alsa(bufferize=false,input)
508
361
  ```
509
362
 
510
363
  The setting will be acknowledged in the log as follows: