Skip to content
Snippets Groups Projects
Commit 5278901e authored by David Trattnig's avatar David Trattnig
Browse files

Test: Detection of track type

parent 2ac40fa7
No related branches found
No related tags found
1 merge request!3Liquidsoap 2 migration
#!/usr/bin/env liquidsoap
#
# Aura Engine (https://gitlab.servus.at/aura/engine)
#
# Copyright (C) 2017-now() - The Aura Engine Team.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
%include "base_config.liq"
# Init defaults
engine_default_track_type = "0"
engine_current_track_type = ref("-1")
# Evaluates the track type based on the given:
# a.) "meta.track_type" passed as annotation, and if not available on
# b.) "engine_current_track_type" passed via server function
# c.) "meta.source" and if not available on
# d.) configured default track type setting
#
# Returns:
# 0=QUEUE/FILE, 1=STREAM, 2=LIVE ANALOG, 3=PLAYLIST
#
def eval_track_type(meta_track_type, meta_source) =
# let source = meta["source"]
type_mapping = [
("fallback_folder", "0"),
("fallback_playlist", "3"),
("in_filesystem_0", "0"),
("in_filesystem_0", "0"),
("in_http_0", "1"),
("in_http_1", "1"),
("linein_0", "2"),
("linein_1", "2"),
("linein_2", "2"),
("linein_3", "2"),
("linein_4", "2")
]
if meta_track_type != "" then
engine_current_track_type := meta_track_type
else
if !engine_current_track_type == "" then
let source_type = list.assoc(
default=engine_default_track_type,
meta_source,
type_mapping
)
engine_current_track_type := source_type
end
end
!engine_current_track_type
end
# Case 1: Passed meta track type => 33
engine_current_track_type := "55"
type = eval_track_type("33", "fallback_playlist")
print("Got Type: #{type}")
# Case 2: Passed track type via server function => 55
engine_current_track_type := "55"
type = eval_track_type("", "fallback_playlist")
print("Got Type: #{type}")
# Case 3: Detect track type via source => 3
engine_current_track_type := ""
type = eval_track_type("", "fallback_playlist")
print("Got Type: #{type}")
# Case 4: Default track type => 0
engine_current_track_type := ""
type = eval_track_type("", "fallback_playlistx")
print("Got Type: #{type}")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment