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
13588aaf
Commit
13588aaf
authored
4 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
No caching of current playlist. engine-clock#1
parent
57ba7f64
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/plugins/trackservice.py
+58
-62
58 additions, 62 deletions
modules/plugins/trackservice.py
modules/scheduling/scheduler.py
+11
-0
11 additions, 0 deletions
modules/scheduling/scheduler.py
with
69 additions
and
62 deletions
modules/plugins/trackservice.py
+
58
−
62
View file @
13588aaf
...
@@ -23,6 +23,7 @@ import requests
...
@@ -23,6 +23,7 @@ import requests
from
modules.base.utils
import
SimpleUtil
as
SU
from
modules.base.utils
import
SimpleUtil
as
SU
from
modules.base.models
import
Playlist
class
TrackServiceHandler
():
class
TrackServiceHandler
():
...
@@ -32,7 +33,6 @@ class TrackServiceHandler():
...
@@ -32,7 +33,6 @@ class TrackServiceHandler():
logger
=
None
logger
=
None
config
=
None
config
=
None
soundsystem
=
None
soundsystem
=
None
last_playlist
=
None
def
__init__
(
self
,
config
,
soundsystem
):
def
__init__
(
self
,
config
,
soundsystem
):
...
@@ -85,64 +85,60 @@ class TrackServiceHandler():
...
@@ -85,64 +85,60 @@ class TrackServiceHandler():
"""
"""
Posts the current and next show information to the Engine API.
Posts the current and next show information to the Engine API.
"""
"""
current_playlist
=
entry
.
playlist
current_playlist
=
self
.
soundsystem
.
scheduler
.
get_active_playlist
()
if
current_playlist
==
self
.
last_playlist
:
current_schedule
=
current_playlist
.
schedule
self
.
logger
.
info
(
"
Playlist didn
'
t change since last update.
"
)
next_schedule
=
self
.
soundsystem
.
scheduler
.
get_next_schedules
(
1
)
else
:
if
next_schedule
:
next_schedule
=
next_schedule
[
0
]
self
.
last_playlist
=
current_playlist
current_schedule
=
current_playlist
.
schedule
data
=
dict
()
next_schedule
=
self
.
soundsystem
.
scheduler
.
get_next_schedules
(
1
)
data
[
"
engine_source
"
]
=
self
.
config
.
get
(
"
api_engine_number
"
)
if
next_schedule
:
next_schedule
=
next_schedule
[
0
]
if
current_playlist
:
data
=
dict
()
data
[
"
current_playlist
"
]
=
dict
()
data
[
"
engine_source
"
]
=
self
.
config
.
get
(
"
api_engine_number
"
)
data
[
"
current_playlist
"
][
"
playlist_id
"
]
=
current_playlist
.
playlist_id
data
[
"
current_playlist
"
][
"
entries
"
]
=
[]
if
current_playlist
:
for
e
in
current_playlist
.
entries
:
data
[
"
current_playlist
"
]
=
dict
()
entry
=
dict
()
data
[
"
current_playlist
"
][
"
playlist_id
"
]
=
current_playlist
.
playlist_id
entry
[
"
track_start
"
]
=
e
.
entry_start
data
[
"
current_playlist
"
][
"
entries
"
]
=
[]
entry
[
"
track_artist
"
]
=
e
.
meta_data
.
artist
for
e
in
current_playlist
.
entries
:
entry
[
"
track_album
"
]
=
e
.
meta_data
.
album
entry
=
dict
()
entry
[
"
track_title
"
]
=
e
.
meta_data
.
title
entry
[
"
track_start
"
]
=
e
.
entry_start
entry
[
"
track_num
"
]
=
e
.
entry_num
entry
[
"
track_artist
"
]
=
e
.
meta_data
.
artist
entry
[
"
track_duration
"
]
=
e
.
duration
entry
[
"
track_album
"
]
=
e
.
meta_data
.
album
entry
[
"
track_type
"
]
=
e
.
get_type
().
numeric
entry
[
"
track_title
"
]
=
e
.
meta_data
.
title
entry
=
SU
.
clean_dictionary
(
entry
)
entry
[
"
track_num
"
]
=
e
.
entry_num
data
[
"
current_playlist
"
][
"
entries
"
].
append
(
entry
)
entry
[
"
track_duration
"
]
=
e
.
duration
entry
[
"
track_type
"
]
=
e
.
get_type
().
numeric
if
current_schedule
:
entry
=
SU
.
clean_dictionary
(
entry
)
cs
=
dict
()
data
[
"
current_playlist
"
][
"
entries
"
].
append
(
entry
)
cs
[
"
schedule_id
"
]
=
current_schedule
.
schedule_id
cs
[
"
schedule_start
"
]
=
current_schedule
.
schedule_start
if
current_schedule
:
cs
[
"
schedule_end
"
]
=
current_schedule
.
schedule_end
cs
=
dict
()
cs
[
"
show_id
"
]
=
current_schedule
.
show_id
cs
[
"
schedule_id
"
]
=
current_schedule
.
schedule_id
cs
[
"
show_name
"
]
=
current_schedule
.
show_name
cs
[
"
schedule_start
"
]
=
current_schedule
.
schedule_start
cs
[
"
playlist_id
"
]
=
current_schedule
.
playlist_id
cs
[
"
schedule_end
"
]
=
current_schedule
.
schedule_end
cs
[
"
fallback_type
"
]
=
current_schedule
.
fallback_state
.
id
cs
[
"
show_id
"
]
=
current_schedule
.
show_id
cs
=
SU
.
clean_dictionary
(
cs
)
cs
[
"
show_name
"
]
=
current_schedule
.
show_name
data
[
"
current_schedule
"
]
=
cs
cs
[
"
playlist_id
"
]
=
current_schedule
.
playlist_id
cs
[
"
fallback_type
"
]
=
current_schedule
.
fallback_state
.
id
if
next_schedule
:
cs
=
SU
.
clean_dictionary
(
cs
)
ns
=
dict
()
data
[
"
current_schedule
"
]
=
cs
ns
[
"
schedule_id
"
]
=
next_schedule
.
schedule_id
ns
[
"
schedule_start
"
]
=
next_schedule
.
schedule_start
if
next_schedule
:
ns
[
"
schedule_end
"
]
=
next_schedule
.
schedule_end
ns
=
dict
()
ns
[
"
show_id
"
]
=
next_schedule
.
show_id
ns
[
"
schedule_id
"
]
=
next_schedule
.
schedule_id
ns
[
"
show_name
"
]
=
next_schedule
.
show_name
ns
[
"
schedule_start
"
]
=
next_schedule
.
schedule_start
ns
[
"
playlist_id
"
]
=
next_schedule
.
playlist_id
ns
[
"
schedule_end
"
]
=
next_schedule
.
schedule_end
ns
[
"
fallback_type
"
]
=
next_schedule
.
fallback_state
.
id
ns
[
"
show_id
"
]
=
next_schedule
.
show_id
ns
=
SU
.
clean_dictionary
(
ns
)
ns
[
"
show_name
"
]
=
next_schedule
.
show_name
data
[
"
next_schedule
"
]
=
ns
ns
[
"
playlist_id
"
]
=
next_schedule
.
playlist_id
ns
[
"
fallback_type
"
]
=
next_schedule
.
fallback_state
.
id
ns
=
SU
.
clean_dictionary
(
ns
)
data
=
SU
.
clean_dictionary
(
data
)
data
[
"
next_schedule
"
]
=
ns
self
.
logger
.
info
(
"
Posting clock info update to Engine API...
"
)
url
=
self
.
config
.
get
(
"
api_engine_store_clock
"
)
data
=
SU
.
clean_dictionary
(
data
)
headers
=
{
'
content-type
'
:
'
application/json
'
}
body
=
json
.
dumps
(
data
,
indent
=
4
,
sort_keys
=
True
,
default
=
str
)
self
.
logger
.
info
(
"
Posting clock info update to Engine API...
"
)
response
=
requests
.
put
(
url
,
data
=
body
,
headers
=
headers
)
url
=
self
.
config
.
get
(
"
api_engine_store_clock
"
)
self
.
logger
.
info
(
"
Engine API response: %s
"
%
response
.
status_code
)
headers
=
{
'
content-type
'
:
'
application/json
'
}
\ No newline at end of file
body
=
json
.
dumps
(
data
,
indent
=
4
,
sort_keys
=
True
,
default
=
str
)
response
=
requests
.
put
(
url
,
data
=
body
,
headers
=
headers
)
self
.
logger
.
info
(
"
Engine API response: %s
"
%
response
.
status_code
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
modules/scheduling/scheduler.py
+
11
−
0
View file @
13588aaf
...
@@ -343,6 +343,17 @@ class AuraScheduler(threading.Thread):
...
@@ -343,6 +343,17 @@ class AuraScheduler(threading.Thread):
return
next_schedules
return
next_schedules
def
get_active_playlist
(
self
):
"""
Retrieves the currently playing playlist.
Returns:
(Playlist): The resolved playlist
"""
schedule
=
self
.
get_active_schedule
()
playlist
=
self
.
fallback_manager
.
resolve_playlist
(
schedule
)
return
playlist
# FIXME Review relevance.
# FIXME Review relevance.
def
get_act_programme_as_string
(
self
):
def
get_act_programme_as_string
(
self
):
...
...
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