Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
engine
Commits
a74044ef
Commit
a74044ef
authored
4 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Moved to specific classes.
#44
parent
711f09ac
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/base/utils.py
+1
-116
1 addition, 116 deletions
modules/base/utils.py
modules/scheduling/types.py
+0
-56
0 additions, 56 deletions
modules/scheduling/types.py
with
1 addition
and
172 deletions
modules/base/utils.py
+
1
−
116
View file @
a74044ef
...
@@ -21,123 +21,8 @@ import datetime
...
@@ -21,123 +21,8 @@ import datetime
import
time
import
time
from
enum
import
Enum
from
enum
import
Enum
from
modules.core.channels
import
ChannelType
from
modules.scheduling.types
import
PlaylistType
class
EngineUtil
:
"""
A class for Engine utilities.
"""
@staticmethod
def
get_channel_type
(
uri
):
"""
Returns the channel type, depending on the passed URI and source.
Args:
uri (String): The URI of the source
"""
if
uri
.
startswith
(
"
https
"
):
return
ChannelType
.
HTTPS
if
uri
.
startswith
(
"
http
"
):
return
ChannelType
.
HTTP
if
uri
.
startswith
(
"
pool
"
)
or
uri
.
startswith
(
"
playlist
"
)
or
uri
.
startswith
(
"
file
"
):
return
ChannelType
.
FILESYSTEM
if
uri
.
startswith
(
"
line://
"
):
return
ChannelType
.
LIVE
@staticmethod
def
uri_to_filepath
(
base_dir
,
uri
):
"""
Converts a file-system URI to an actual, absolute path to the file.
Args:
basi_dir (String): The location of the audio store.
uri (String): The URI of the file
Returns:
path (String): Absolute file path
"""
return
base_dir
+
"
/
"
+
uri
[
7
:]
+
"
.flac
"
@staticmethod
def
get_playlist_type
(
fallback_id
):
"""
Converts an playlist type ID to the playlist type object.
Args:
id (String): playlist type ID
Returns:
type (PlaylistType): The type
"""
if
fallback_id
==
0
:
return
PlaylistType
.
DEFAULT
elif
fallback_id
==
1
:
return
PlaylistType
.
SHOW
elif
fallback_id
==
2
:
return
PlaylistType
.
TIMESLOT
else
:
return
PlaylistType
.
STATION
@staticmethod
def
get_entries_string
(
entries
):
"""
Returns a list of entries as String for logging purposes.
"""
s
=
""
if
isinstance
(
entries
,
list
):
for
entry
in
entries
:
s
+=
str
(
entry
)
if
entry
!=
entries
[
-
1
]:
s
+=
"
,
"
else
:
s
=
str
(
entries
)
return
s
@staticmethod
def
lqs_annotate_cuein
(
uri
,
cue_in
):
"""
Wraps the given URI with a Liquidsoap Cue In annotation.
Args:
uri (String): The path to the audio source
cue_in (Float): The value in seconds wher the cue in should start
Returns:
(String): The annotated URI
"""
if
cue_in
>
0.0
:
uri
=
"
annotate:liq_cue_in=
\"
%s
\"
:%s
"
%
(
str
(
cue_in
),
uri
)
return
uri
@staticmethod
def
engine_info
(
component
,
version
):
"""
Prints the engine logo and version info.
"""
return
"""
\n
█████╗ ██╗ ██╗██████╗ █████╗ ███████╗███╗ ██╗ ██████╗ ██╗███╗ ██╗███████╗
██╔══██╗██║ ██║██╔══██╗██╔══██╗ ██╔════╝████╗ ██║██╔════╝ ██║████╗ ██║██╔════╝
███████║██║ ██║██████╔╝███████║ █████╗ ██╔██╗ ██║██║ ███╗██║██╔██╗ ██║█████╗
██╔══██║██║ ██║██╔══██╗██╔══██║ ██╔══╝ ██║╚██╗██║██║ ██║██║██║╚██╗██║██╔══╝
██║ ██║╚██████╔╝██║ ██║██║ ██║ ███████╗██║ ╚████║╚██████╔╝██║██║ ╚████║███████╗
╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝╚══════╝
%s v%s - Ready to play!
\n
"""
%
(
component
,
version
)
class
SimpleUtil
:
class
SimpleUtil
:
"""
"""
...
...
This diff is collapsed.
Click to expand it.
modules/scheduling/types.py
deleted
100644 → 0
+
0
−
56
View file @
711f09ac
#
# Aura Engine (https://gitlab.servus.at/aura/engine)
#
# Copyright (C) 2017-2020 - 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/>.
from
enum
import
Enum
class
PlaylistType
(
Enum
):
"""
Types of playlists.
"""
DEFAULT
=
{
"
id
"
:
0
,
"
name
"
:
"
default
"
}
# Default play mode
SHOW
=
{
"
id
"
:
1
,
"
name
"
:
"
show
"
}
# The first played when some default playlist fails
TIMESLOT
=
{
"
id
"
:
2
,
"
name
"
:
"
timeslot
"
}
# The second played when the timeslot fallback fails
STATION
=
{
"
id
"
:
3
,
"
name
"
:
"
station
"
}
# The last played when everything else fails
@property
def
id
(
self
):
return
self
.
value
[
"
id
"
]
def
__str__
(
self
):
return
str
(
self
.
value
[
"
name
"
])
# class TimerType(Enum):
# """
# Types of queue timers.
# """
# SWITCH = "switch"
# FADEIN = "fadein"
# FADEOUT = "fadeout"
class
EntryQueueState
(
Enum
):
"""
Types of playlist entrie behaviours.
"""
OKAY
=
"
ok
"
CUT
=
"
cut
"
OUT_OF_SCHEDULE
=
"
oos
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment