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.39k stars 126 forks source link

WARNING: "set" is deprecated and will be removed in future version. #3347

Closed juanamm closed 11 months ago

juanamm commented 1 year ago

Describe the bug Audio works fine and metadata is fetched fine too. But despite having changed all the 'set' to 'setting' I still get the warning: 2023/08/24 04:41:44 [lang:2] WARNING: "set" is deprecated and will be removed in future version. Please use settings.path.to.key.set(value)

To Reproduce

#!/usr/bin/liquidsoap

#Settings
#settings.server.telnet.set(true)
#settings.server.telnet.port.set(8595)
settings.log.level.set(3)

settings.harbor.bind_addrs.set(["0.0.0.0"])
settings.harbor.ssl.certificate.set("/etc/letsencrypt/live/osirisfm.org/fullchain.pem")
settings.harbor.ssl.private_key.set("/etc/letsencrypt/live/osirisfm.org/privkey.pem")

# Environment Variables
admin_icecast = getenv("ADMIN_ICECAST")
password_admin = getenv("PASSWORD_ADMIN")
password_dj = getenv("PASSWORD_DJ")
source_passw = getenv("SOURCE_PASSW")
host_https = getenv("HOST_HTTPS")
port_https = getenv("PORT_HTTPS")
port_live = getenv("PORT_LIVE")
host_https_no_prot = getenv("HOST_HTTPS_NO_PROT")

# Convert string to integer
port_live_int = int_of_string(port_live)
port_https_int = int_of_string(port_https)

# Music playlists
music = nrj(playlist("~/music/music1.pls"))
# Add crossfading
music = crossfade(fade_out=3., fade_in=3., duration=5., music)

# Metadata
settings.tag.encodings.set(["UTF-8", "ISO-8859-1"])
settings.encoder.metadata.export.set(["artist", "title"])
settings.decoder.file_extensions.taglib.set(["mp3", "ogg", "mkv", "wav", "flac", "mp4", "m4a"])

# Function to apply metadata to the stream
def apply_metadata(m) =
    log("calling apply_metadata")

    artist = url.encode(m["artist"])
    title  = url.encode(m["title"])

    if (artist == "" and title == "") then
        log("Artist and title all empty!")
    else
        icy = "#{artist}+-+#{title}"
        log("icy for icecast metadata: #{icy}")

        # Update mp3 stream metadata
        command = process.quote.command(
            args=["-m", "2", "-u", admin_icecast ^ ":" ^ password_admin,
                  "https://#{host_https}:#{port_https_int}/admin/metadata?mount=%2Fstream.mp3&mode=updinfo&charset=UTF-8&song=#{icy}"], "curl"
        )
        process.run(timeout = 4.0, command)
    end
end

# Run apply_metadata_thread on new metadata
def apply_metadata_thread(m) =
    thread.run({apply_metadata(m)})
end

# Security fallback
security = single("~/music_security/security.mp3")
music = fallback(track_sensitive = false, [music, security])

# Support for live streams
live = input.harbor(
    "live",
    port = port_live_int,
    password = password_dj,
    replay_metadata = true,
    icy_metadata_charset = "UTF-8"
)

# Run apply_metadata_thread on live metadata
live.on_metadata(apply_metadata_thread)

# Fallback for live and music playlists
radio = fallback(track_sensitive = false, [live, music])

# Stream it out MP3
output.icecast(%mp3(bitrate=192),
                protocol = "https",
                host = host_https_no_prot,
                port = port_https_int,
                password = source_passw,
                mount = "stream",
                encoding = "UTF-8",
                name = "DJ OsiriS Music Service",
                description = "DJ OsiriS FM, estamos las 24 horas online con una variada propuesta musical y DJs en vivo!",
                radio,
                fallible = true)

Expected behavior I was hoping this warning would no longer appear after I made the suggested changes to all setconfigurations.

Version details

Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy

opam version: 2.1.2 Icecast2 version: 2.4.4 liquidsoap version: Liquidsoap 2.1.4

Install method opam install taglib mad lame vorbis cry ssl samplerate liquidsoap I have installed it from my Ubuntu 22.04 distro

vitoyucepi commented 1 year ago

Hi @juanamm, I'm unable to find any legacy set instructions in your code snippet. Even after I launched the script, there were no deprecation warnings.

vitoyucepi commented 11 months ago

I've revisited this issue once more and tried to replicate the behavior. To do that I've created the ubuntu 22.04 virtual machine using the cloudimg disk image with the following config

Cloud config ```yaml #cloud-config # vim: ft=yaml system_info: default_user: name: ubuntu lock_passwd: false plain_text_passwd: ubuntu apt: primary: - arches: [default] uri: http://archive.ubuntu.com/ubuntu security: - arches: [default] uri: http://security.ubuntu.com/ubuntu sources_list: | deb $PRIMARY $RELEASE main universe restricted multiverse deb $PRIMARY $RELEASE-updates main universe restricted multiverse deb $PRIMARY $RELEASE-backports main universe restricted multiverse deb $SECURITY $RELEASE-security main universe restricted multiverse runcmd: - apt-get purge --auto-remove -y ubuntu-server ubuntu-standard ubuntu-advantage-tools - apt-get purge --auto-remove -y linux-headers* linux-kvm-headers* - apt-get purge --auto-remove -y dosfstools xfsprogs btrfs-progs squashfs-tools - apt-get purge --auto-remove -y open-iscsi cryptsetup* dmsetup dmeventd mdadm fuse3 gdisk sg3* - apt-get purge --auto-remove -y usb-modeswitch* bolt kbd - apt-get purge --auto-remove -y lxd* tcl* sosreport apport gir1.2* git apparmor xauth rsyslog motd-news-config htop - apt-get purge --auto-remove -y fonts-ubuntu-console fwupd-signed - apt-get install --no-install-recommends -y bash-completion less - apt-get install --no-install-recommends -y unattended-upgrades logrotate whiptail - apt-get clean package_update: true package_upgrade: true ```

After that, I use ssh to access the VM.

  1. sudo apt-get update;
    sudo apt-get dist-upgrade -y;
    sudo apt-get install --no-install-recommends -y curl ca-certificates patch unzip bubblewrap git bzip2 gcc make libc6-dev g++ ffmpeg;
    sudo curl -sS -L -o /usr/local/bin/opam https://github.com/ocaml/opam/releases/download/2.1.5/opam-2.1.5-x86_64-linux;
    sudo chmod +x /usr/local/bin/opam;
  2. opam init --bare -n;
    opam switch create 4.14.1;
    eval $(opam env --switch=4.14.1);
    opam install --confirm-level=unsafe-yes liquidsoap=2.1.4 taglib mad lame vorbis cry ssl samplerate;
    mkdir music_security music;
    ffmpeg -f lavfi -i "sine=frequency=3000:duration=10" -c:a libmp3lame -b:a 128k music_security/security.mp3;
    ffmpeg -f lavfi -i "sine=frequency=3000:duration=10" -c:a libmp3lame -b:a 128k -id3v2_version 4 -metadata title=1 -y music/1.mp3;
    ffmpeg -f lavfi -i "sine=frequency=3000:duration=10" -c:a libmp3lame -b:a 128k -id3v2_version 4 -metadata title=2 -y music/2.mp3;
    opam list ``` # Packages matching: installed # Name # Installed # Synopsis angstrom 0.15.0 Parser combinators built for speed and memory-efficiency base-bigarray base base-threads base base-unix base bigstringaf 0.9.1 Bigstring intrinsics and fast blits based on memcpy/memmove camomile 1.0.2 A Unicode library conf-lame 1 Virtual package relying on lame conf-libcurl 2 Virtual package relying on a libcurl system installation conf-libogg 1 Virtual package relying on libogg conf-libpcre 1 Virtual package relying on a libpcre system installation conf-libssl 4 Virtual package relying on an OpenSSL library system installation conf-libvorbis 1 Virtual package relying on libvorbis conf-mad 1 Virtual package relying on mad conf-pkg-config 3 Check if pkg-config is installed and create an opam switch local pkgconfig folder conf-samplerate 1 Virtual package relying on samplerate conf-taglib 1 Virtual package relying on taglib conf-which 1 Virtual package relying on which cry 0.6.7 OCaml client for the various icecast & shoutcast source protocols csexp 1.5.2 Parsing and printing of S-expressions in Canonical form dtools 0.4.5 Library providing various helper functions to make daemons dune 3.10.0 Fast, portable, and opinionated build system dune-configurator 3.10.0 Helper library for gathering system configuration duppy 0.9.2 Library providing monadic threads gen 1.1 Iterators for OCaml, both restartable and consumable lame 0.3.7 MP3 encoding library liquidsoap 2.1.4 Swiss-army knife for multimedia streaming mad 0.5.2 Mad decoding library menhir 20230608 An LR(1) parser generator menhirLib 20230608 Runtime support library for parsers generated by Menhir menhirSdk 20230608 Compile-time library for auxiliary tools related to Menhir mm 0.8.4 The mm library contains high-level APIs to create and manipulate multimedia streams (audio, video, MIDI) ocaml 4.14.1 The OCaml compiler (virtual package) ocaml-base-compiler 4.14.1 Official release 4.14.1 ocaml-compiler-libs v0.12.4 OCaml compiler libraries repackaged ocaml-config 2 OCaml Switch Configuration ocaml-options-vanilla 1 Ensure that OCaml is compiled with no special options enabled ocaml-syntax-shims 1.0.0 Backport new syntax to older OCaml versions ocamlfind 1.9.6 A library manager for OCaml ocurl 0.9.2 Bindings to libcurl ogg 0.7.4 Bindings to libogg pcre 7.5.0 Bindings to the Perl Compatibility Regular Expressions library ppx_derivers 1.2.1 Shared [@@deriving] plugin registry ppxlib 0.30.0 Standard infrastructure for ppx rewriters result 1.5 Compatibility Result module samplerate 0.1.6 Samplerate audio conversion library sedlex 3.2 An OCaml lexer generator for Unicode seq base Compatibility package for OCaml's standard iterator type starting from 4.07. sexplib0 v0.16.0 Library containing the definition of S-expressions and some base converters ssl 0.7.0 Bindings for OpenSSL stdlib-shims 0.3.0 Backport some of the new stdlib features to older compiler stringext 1.6.0 Extra string functions for OCaml taglib 0.3.10 Bindings for the taglib library uri 4.2.0 An RFC3986 URI/URL parsing library vorbis 0.8.0 Bindings to libvorbis ```
  3. music/music1.pls ``` [playlist] File1=music/1.mp3 File2=music/2.mp3 NumberOfEntries=2 ```
  4. main.liq ```ruby #!/usr/bin/liquidsoap #Settings #settings.server.telnet.set(true) #settings.server.telnet.port.set(8595) settings.log.level.set(3) settings.harbor.bind_addrs.set(["0.0.0.0"]) #settings.harbor.ssl.certificate.set("/etc/letsencrypt/live/osirisfm.org/fullchain.pem") #settings.harbor.ssl.private_key.set("/etc/letsencrypt/live/osirisfm.org/privkey.pem") # Environment Variables admin_icecast = getenv("ADMIN_ICECAST") password_admin = getenv("PASSWORD_ADMIN") password_dj = getenv("PASSWORD_DJ") source_passw = getenv("SOURCE_PASSW") host_https = getenv("HOST_HTTPS") port_https = getenv("PORT_HTTPS") port_live = getenv("PORT_LIVE") host_https_no_prot = getenv("HOST_HTTPS_NO_PROT") # Convert string to integer port_live_int = int_of_string(port_live) port_https_int = int_of_string(port_https) # Music playlists music = nrj(playlist("~/music/music1.pls")) # Add crossfading music = crossfade(fade_out=3., fade_in=3., duration=5., music) # Metadata settings.tag.encodings.set(["UTF-8", "ISO-8859-1"]) settings.encoder.metadata.export.set(["artist", "title"]) settings.decoder.file_extensions.taglib.set(["mp3", "ogg", "mkv", "wav", "flac", "mp4", "m4a"]) # Function to apply metadata to the stream def apply_metadata(m) = log("calling apply_metadata") artist = url.encode(m["artist"]) title = url.encode(m["title"]) if (artist == "" and title == "") then log("Artist and title all empty!") else icy = "#{artist}+-+#{title}" log("icy for icecast metadata: #{icy}") # Update mp3 stream metadata command = process.quote.command( args=["-m", "2", "-u", admin_icecast ^ ":" ^ password_admin, "http://#{host_https}:#{port_https_int}/admin/metadata?mount=%2Fstream.mp3&mode=updinfo&charset=UTF-8&song=#{icy}"], "curl" ) process.run(timeout = 4.0, command) end end # Run apply_metadata_thread on new metadata def apply_metadata_thread(m) = thread.run({apply_metadata(m)}) end # Security fallback security = single("~/music_security/security.mp3") music = fallback(track_sensitive = false, [music, security]) # Support for live streams live = input.harbor( "live", port = port_live_int, password = password_dj, replay_metadata = true, icy_metadata_charset = "UTF-8" ) # Run apply_metadata_thread on live metadata live.on_metadata(apply_metadata_thread) # Fallback for live and music playlists radio = fallback(track_sensitive = false, [live, music]) # Stream it out MP3 output.icecast(%mp3(bitrate=192), host = host_https_no_prot, port = port_https_int, password = source_passw, mount = "stream", encoding = "UTF-8", name = "DJ OsiriS Music Service", description = "DJ OsiriS FM, estamos las 24 horas online con una variada propuesta musical y DJs en vivo!", radio, fallible = true) ```
    The diff ```diff --- a/main.liq +++ b/main.liq @@ -6,8 +6,8 @@ settings.log.level.set(3) settings.harbor.bind_addrs.set(["0.0.0.0"]) -settings.harbor.ssl.certificate.set("/etc/letsencrypt/live/osirisfm.org/fullchain.pem") -settings.harbor.ssl.private_key.set("/etc/letsencrypt/live/osirisfm.org/privkey.pem") +#settings.harbor.ssl.certificate.set("/etc/letsencrypt/live/osirisfm.org/fullchain.pem") +#settings.harbor.ssl.private_key.set("/etc/letsencrypt/live/osirisfm.org/privkey.pem") # Environment Variables admin_icecast = getenv("ADMIN_ICECAST") @@ -49,7 +49,7 @@ def apply_metadata(m) = # Update mp3 stream metadata command = process.quote.command( args=["-m", "2", "-u", admin_icecast ^ ":" ^ password_admin, - "https://#{host_https}:#{port_https_int}/admin/metadata?mount=%2Fstream.mp3&mode=updinfo&charset=UTF-8&song=#{icy}"], "curl" + "http://#{host_https}:#{port_https_int}/admin/metadata?mount=%2Fstream.mp3&mode=updinfo&charset=UTF-8&song=#{icy}"], "curl" ) process.run(timeout = 4.0, command) end @@ -81,6 +81,7 @@ radio = fallback(track_sensitive = false, [live, music]) # Stream it out MP3 output.icecast(%mp3(bitrate=192), - protocol = "https", host = host_https_no_prot, port = port_https_int, password = source_passw, ```
  5. I configured the environment variables

    export ADMIN_ICECAST=admin
    export PASSWORD_ADMIN=hackme
    export PASSWORD_DJ=hackme
    export SOURCE_PASSW=hackme
    export HOST_HTTPS=192.168.1.1
    export PORT_HTTPS=8000
    export PORT_LIVE=8000
    export HOST_HTTPS_NO_PROT=192.168.1.1
  6. The liquidsoap log ``` 2023/09/14 12:14:45 >>> LOG START 2023/09/14 12:14:45 [main:3] Liquidsoap 2.1.4 2023/09/14 12:14:45 [main:3] Using: bytes=[distributed with OCaml 4.02 or above] pcre=7.5.0 sedlex=3.2 menhirLib=20230608 curl=0.9.2 uri=4.2.0 dtools=0.4.5 duppy=0.9.2 cry=0.6.7 mm=0.8.4 ogg=0.7.4 ogg.decoder=0.7.4 vorbis=0.8.0 vorbis.decoder=0.8.0 mad=0.5.2 dynlink=[distributed with Ocaml] lame=0.3.7 samplerate=0.1.6 taglib=0.3.10 ssl=0.7.0 camomile=1.0.2 2023/09/14 12:14:45 [dynamic.loader:3] Could not find dynamic module for fdkaac encoder. 2023/09/14 12:14:45 [clock:3] Using builtin (low-precision) implementation for latency control 2023/09/14 12:14:45 [frame:3] Using 44100Hz audio, 25Hz video, 44100Hz main. 2023/09/14 12:14:45 [frame:3] Video frame size set to: 1280x720 2023/09/14 12:14:45 [frame:3] Frame size must be a multiple of 1764 ticks = 1764 audio samples = 1 video samples. 2023/09/14 12:14:45 [frame:3] Targeting 'frame.duration': 0.04s = 1764 audio samples = 1764 ticks. 2023/09/14 12:14:45 [frame:3] Frames last 0.04s = 1764 audio samples = 1 video samples = 1764 ticks. 2023/09/14 12:14:45 [sandbox:3] Sandboxing disabled 2023/09/14 12:14:45 [video.converter:3] Couldn't find preferred video converter: ffmpeg. 2023/09/14 12:14:45 [audio.converter:3] Using samplerate converter: libsamplerate. 2023/09/14 12:14:45 [harbor:3] Adding mountpoint '/live' on port 8000 2023/09/14 12:14:45 [single_0:3] "~/music_security/security.mp3" is static, resolving once for all... 2023/09/14 12:14:45 [clock.main:3] Streaming loop starts in auto-sync mode 2023/09/14 12:14:45 [clock.main:3] Delegating synchronisation to CPU clock 2023/09/14 12:14:45 [video.text:3] Using native implementation 2023/09/14 12:14:45 [music1.pls:3] Prepared "music/2.mp3" (RID 2). 2023/09/14 12:14:45 [switch_1:3] Switch to switch_0. 2023/09/14 12:14:45 [switch_0:3] Switch to crossfade_0. 2023/09/14 12:14:45 [DJ_OsiriS_Music_Service:3] Connecting mount stream for source@192.168.1.1... 2023/09/14 12:14:45 [DJ_OsiriS_Music_Service:3] Connection setup was successful. 2023/09/14 12:14:50 [decoder:2] Decoding "music/2.mp3" ended: Mad.End_of_stream. 2023/09/14 12:14:50 [music1.pls:3] Prepared "music/1.mp3" (RID 3). 2023/09/14 12:14:50 [cross_0:3] Analysis: -13.630988dB / -17.508850dB (4.96s / 4.96s) 2023/09/14 12:14:50 [crossfade_0:3] Simple transition: crossed, fade-in, fade-out. ^C2023/09/14 12:14:53 [main:3] Shutdown started! 2023/09/14 12:14:53 [main:3] Waiting for main threads to terminate... 2023/09/14 12:14:53 [DJ_OsiriS_Music_Service:3] Closing connection... 2023/09/14 12:14:53 [harbor:3] Removing mountpoint '/live' on port 8000 2023/09/14 12:14:53 [harbor:3] Nothing more on port 8000: closing sockets. 2023/09/14 12:14:53 [clock.main:3] Streaming loop stopped. 2023/09/14 12:14:53 [main:3] Main threads terminated. 2023/09/14 12:14:53 [threads:3] Shutting down scheduler... 2023/09/14 12:14:53 [threads:3] Scheduler shut down. 2023/09/14 12:14:53 [main:3] Cleaning downloaded files... 2023/09/14 12:14:53 [main:3] Freeing memory... ```

As you can see in the log, there were no deprecation warnings. I could not find any invocations of legacy set options.

I'll close this issue because there will be no more releases for version 2.1.x. As a solution, I recommend upgrading to 2.2.x. If you need further assistance in removing these messages, please feel free to reopen this issue.