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
f5b7e0e6
Commit
f5b7e0e6
authored
4 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Trackservice call to Engine API.
parent
72812a16
No related branches found
No related tags found
No related merge requests found
Pipeline
#769
passed
4 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
modules/base/utils.py
+24
-4
24 additions, 4 deletions
modules/base/utils.py
modules/core/channels.py
+8
-0
8 additions, 0 deletions
modules/core/channels.py
modules/plugins/trackservice.py
+37
-7
37 additions, 7 deletions
modules/plugins/trackservice.py
with
69 additions
and
11 deletions
modules/base/utils.py
+
24
−
4
View file @
f5b7e0e6
...
...
@@ -69,7 +69,7 @@ class EngineUtil:
@staticmethod
def
get_playlist_type
(
id
):
def
get_playlist_type
(
fallback_
id
):
"""
Converts an playlist type ID to the playlist type object.
...
...
@@ -79,11 +79,11 @@ class EngineUtil:
Returns:
type (PlaylistType): The type
"""
if
id
==
0
:
if
fallback_
id
==
0
:
return
PlaylistType
.
DEFAULT
elif
id
==
1
:
elif
fallback_
id
==
1
:
return
PlaylistType
.
SHOW
elif
id
==
2
:
elif
fallback_
id
==
2
:
return
PlaylistType
.
TIMESLOT
else
:
return
PlaylistType
.
STATION
...
...
@@ -145,6 +145,26 @@ class SimpleUtil:
"""
@staticmethod
def
clean_dictionary
(
data
):
"""
Delete keys with the value `None` in a dictionary, recursively.
This alters the input so you may wish to `copy` the dict first.
Args:
data (dict): The dicationary
Returns:
(dict):
"""
for
key
,
value
in
list
(
data
.
items
()):
if
value
is
None
:
del
data
[
key
]
elif
isinstance
(
value
,
dict
):
SimpleUtil
.
clean_dictionary
(
value
)
return
data
@staticmethod
def
fmt_time
(
timestamp
):
"""
...
...
This diff is collapsed.
Click to expand it.
modules/core/channels.py
+
8
−
0
View file @
f5b7e0e6
...
...
@@ -55,18 +55,22 @@ class ChannelType(Enum):
"""
FILESYSTEM
=
{
"
id
"
:
"
fs
"
,
"
numeric
"
:
0
,
"
channels
"
:
[
Channel
.
FILESYSTEM_A
,
Channel
.
FILESYSTEM_B
]
}
HTTP
=
{
"
id
"
:
"
http
"
,
"
numeric
"
:
1
,
"
channels
"
:
[
Channel
.
HTTP_A
,
Channel
.
HTTP_B
]
}
HTTPS
=
{
"
id
"
:
"
https
"
,
"
numeric
"
:
2
,
"
channels
"
:
[
Channel
.
HTTPS_A
,
Channel
.
HTTPS_B
]
}
LIVE
=
{
"
id
"
:
"
live
"
,
"
numeric
"
:
3
,
"
channels
"
:
[
Channel
.
LIVE_0
,
Channel
.
LIVE_1
,
...
...
@@ -80,6 +84,10 @@ class ChannelType(Enum):
def
channels
(
self
):
return
self
.
value
[
"
channels
"
]
@property
def
numeric
(
self
):
return
self
.
value
[
"
numeric
"
]
def
__str__
(
self
):
return
str
(
self
.
value
[
"
id
"
])
...
...
This diff is collapsed.
Click to expand it.
modules/plugins/trackservice.py
+
37
−
7
View file @
f5b7e0e6
...
...
@@ -17,8 +17,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
json
import
logging
import
requests
from
modules.base.utils
import
SimpleUtil
as
SU
class
TrackserviceHandler
():
"""
...
...
@@ -27,6 +32,7 @@ class TrackserviceHandler():
logger
=
None
config
=
None
soundsystem
=
None
last_schedule
=
None
def
__init__
(
self
,
config
,
soundsystem
):
...
...
@@ -42,18 +48,42 @@ class TrackserviceHandler():
"""
Some track started playing.
"""
self
.
logger
.
info
(
"
::: CALLED TRACKSERVICE HANDLER :::
"
)
self
.
logger
.
info
(
"
PLAYING: %s <<<
"
%
(
str
(
entry
)))
self
.
store_trackservice
(
entry
)
self
.
store_s
chedule
(
entry
)
self
.
store_s
how_info
(
entry
)
def
store_trackservice
(
self
,
entry
):
"""
Posts the given `PlaylistEntry` to the Engine API
Trackservice
.
Posts the given `PlaylistEntry` to the Engine API
Playlog
.
"""
data
=
dict
()
data
[
"
track_start
"
]
=
entry
.
entry_start
data
[
"
track_artist
"
]
=
entry
.
meta_data
.
artist
data
[
"
track_album
"
]
=
entry
.
meta_data
.
album
data
[
"
track_title
"
]
=
entry
.
meta_data
.
title
data
[
"
track_duration
"
]
=
entry
.
duration
data
[
"
track_type
"
]
=
entry
.
get_type
().
numeric
data
[
"
timeslot_id
"
]
=
entry
.
playlist
.
schedule
.
schedule_id
data
[
"
show_name
"
]
=
entry
.
playlist
.
schedule
.
show_name
data
[
"
log_source
"
]
=
self
.
config
.
get
(
"
api_engine_number
"
)
data
=
SU
.
clean_dictionary
(
data
)
self
.
logger
.
info
(
"
Posting schedule update to Engine API...
"
)
url
=
self
.
config
.
get
(
"
api_engine_playlog_url
"
)
headers
=
{
'
content-type
'
:
'
application/json
'
}
body
=
json
.
dumps
(
data
,
indent
=
4
,
sort_keys
=
True
,
default
=
str
)
response
=
requests
.
post
(
url
,
data
=
body
,
headers
=
headers
)
self
.
logger
.
info
(
"
Engine API response: %s
"
%
response
.
status_code
)
def
store_s
chedule
(
self
,
entry
):
def
store_s
how_info
(
self
,
entry
):
"""
Posts the
given `PlaylistEntry`
to the Engine API
Clock Data
.
Posts the
current and next show information
to the Engine API.
"""
current_schedule
=
entry
.
playlist
.
schedule
if
current_schedule
==
self
.
last_schedule
:
self
.
logger
.
info
(
"
Schedule didn
'
t change since last update.
"
)
else
:
self
.
logger
.
info
(
"
Posting schedule update to Engine API...
"
)
# TODO Implement
\ No newline at end of file
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