### Description If the title or artist metadata in libretime has a newline, that file is not played as telnet takes the newline as a command enter in the middle of the command. **This is a new feature**: No **I have updated the documentation to reflect these changes**: No ### Testing Notes **What I did:** I spun up a fresh local LibreTime instance, uploaded a track with a newline in the creator field. I then created a show and added the track to the show and verified that the track did not play with error: ``` playout-1 | 2025-06-06 17:41:49,888 | ERROR | libretime_playout.liquidsoap.client._client:_set_var:50 - ERROR: unknown command, type "help" to get a list of commands. ``` I then added my fix and verified that the track did play as it was supposed to. **How you can replicate my testing:** See the above section --------- Co-authored-by: jo <ljonas@riseup.net>
68 lines
1.9 KiB
Python
68 lines
1.9 KiB
Python
from datetime import datetime
|
|
from pathlib import Path
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from dateutil.tz import tzutc
|
|
|
|
from libretime_playout.player.events import EventKind, FileEvent
|
|
from libretime_playout.player.liquidsoap import Liquidsoap, create_liquidsoap_annotation
|
|
|
|
|
|
@patch("libretime_playout.player.events.CACHE_DIR", Path("/fake"))
|
|
def test_create_liquidsoap_annotation():
|
|
file_event = FileEvent(
|
|
type=EventKind.FILE,
|
|
row_id=1,
|
|
start=datetime(2022, 9, 5, 11, tzinfo=tzutc()),
|
|
end=datetime(2022, 9, 5, 11, 5, 2, tzinfo=tzutc()),
|
|
uri=None,
|
|
id=2,
|
|
show_name="Show 1",
|
|
fade_in=500.0,
|
|
fade_out=500.0,
|
|
cue_in=13.7008,
|
|
cue_out=315.845,
|
|
track_title='My Friend the "Forest"',
|
|
artist_name="Nils Frahm",
|
|
mime="audio/flac",
|
|
replay_gain=11.46,
|
|
filesize=10000,
|
|
)
|
|
|
|
assert create_liquidsoap_annotation(file_event) == (
|
|
"annotate:"
|
|
'media_id="2",'
|
|
'schedule_table_id="1",'
|
|
'liq_start_next="0",'
|
|
'liq_fade_in="0.5",'
|
|
'liq_fade_out="0.5",'
|
|
'liq_cue_in="13.7008",'
|
|
'liq_cue_out="315.845",'
|
|
'replay_gain="11.46 dB",'
|
|
'artist="Nils Frahm",'
|
|
'title="My Friend the \\"Forest\\""'
|
|
":/fake/2.flac"
|
|
)
|
|
|
|
file_event.artist_name = "New\nline to space"
|
|
file_event.track_title = "Trailing\nnewline\n"
|
|
|
|
assert create_liquidsoap_annotation(file_event) == (
|
|
"annotate:"
|
|
'media_id="2",'
|
|
'schedule_table_id="1",'
|
|
'liq_start_next="0",'
|
|
'liq_fade_in="0.5",'
|
|
'liq_fade_out="0.5",'
|
|
'liq_cue_in="13.7008",'
|
|
'liq_cue_out="315.845",'
|
|
'replay_gain="11.46 dB",'
|
|
'artist="New line to space",'
|
|
'title="Trailing newline"'
|
|
":/fake/2.flac"
|
|
)
|
|
|
|
|
|
def test_liquidsoap():
|
|
Liquidsoap(MagicMock())
|