File: resolvers.liq

package info (click to toggle)
liquidsoap 2.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 12,924 kB
  • sloc: ml: 73,577; javascript: 24,836; sh: 3,440; makefile: 764; xml: 114; ansic: 96; lisp: 62; python: 35; perl: 8; ruby: 8
file content (41 lines) | stat: -rw-r--r-- 1,370 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Enable ReplayGain metadata resolver. This resolver will process any file
# decoded by Liquidsoap and add a `replaygain_track_gain` metadata when this
# value could be computed. For a finer-grained replay gain processing, use the
# `replaygain:` protocol.
# @category Liquidsoap
# @param ~delay Maximum delay for extracting metadata.
# @param ~extract_replaygain The extraction program.
def enable_replaygain_metadata(
       ~delay=(-1.),
       ~extract_replaygain="#{configure.bindir}/extract-replaygain")
  def replaygain_metadata(file)
    ret = exec_replaygain(delay=delay,extract_replaygain=extract_replaygain,file)
    if ret != "" then
      [("replaygain_track_gain",ret)]
    else
      []
    end
  end
  add_metadata_resolver("replaygain_track_gain", replaygain_metadata)
end

# @flag hidden
def youtube_playlist_parser(~pwd="",url) =
  ignore(pwd)
  binary = null.get(settings.protocol.youtube_dl.path())

  def parse_line(line) =
    let json.parse ( parsed  : {url : string}? ) = line
    parsed = parsed ?? {url = "foo"}
    url = parsed.url
    ([],"youtube-dl:#{url}")
  end

  if r/^youtube-pl/.test(url) then
    uri = list.nth(default="",r/:/.split(url), 1)
    list.map(parse_line, process.read.lines("#{binary} -j --flat-playlist #{uri}"))
  else
    []
  end
end
playlist.parse.register(format="youtube-dl",strict=true,youtube_playlist_parser)