Issues with string interpolation #2220
-
Liquidsoap v2.0.2 via Docker I have a script where I'm trying to run a simple archiver, which will create files for 30 minute chunks of audio. The intended format of the output file would be I'm using Here's a simplified version of my script below:
In the script, I've also prepended However, when This results in filenames like:
Is there a better way to go about this? Thanks for giving this a look, I appreciate any pointers. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Thanks for your question. String interpolation is outdated and should be replaced by proper string getters now. I have added a ticket to fully remove it from the code base here: #2221 To answer your question here, the issues comes from the fact that this: output.file(%mp3,
output_base_path ^ output_filename % [("day",output_day()),("min",output_min())],
input,
reopen_when={0m or 30m}) Means that the line The solution is to make the whole thing a string getter, i.e. a function of type output_base_path = "/archive/test/"
day_mappings = [
(0, "Sun"),
(1, "Mon"),
(2, "Tue"),
(3, "Wed"),
(4, "Thu"),
(5, "Fri"),
(6, "Sat")
]
def output_file() =
# With 2.1.x: let {hour, min, sec, week_day} = time.local()
current_time = time.local()
hour = current_time.hour
min = current_time.min
sec = current_time.sec
week_day = current_time.week_day
output_min = min < 30 ? "00" : "30"
output_day = list.assoc(week_day, day_mappings)
"#{output_base_path}#{output_day}#{hour}#{output_min}_#{hour}#{min}#{sec}.mp3"
end
output.file(%mp3,
output_file,
input,
reopen_when={0m or 30m}) This is based off the ongoing |
Beta Was this translation helpful? Give feedback.
-
Thank you for the detailed reply |
Beta Was this translation helpful? Give feedback.
-
@toots Is there a version of this that works with 2.0.2? When I use current_time = time.local() it doesn't appear to return a callback. I get an error that current_time has no method for year, month, day, hour, etc. I should also note that the 2.1.x solution throws a syntax error. |
Beta Was this translation helpful? Give feedback.
Thanks for your question. String interpolation is outdated and should be replaced by proper string getters now. I have added a ticket to fully remove it from the code base here: #2221
To answer your question here, the issues comes from the fact that this:
Means that the line
output_base_path ^ output_filename % [("day",output_day()),("min",output_min())]
is executed only once, when the script is initially called. It is never executed again and, so, the suffix remains the same.The solution is to make the whole thing a string getter, i.…