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
8d9c9884
Commit
8d9c9884
authored
4 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Assign next timeslot. Docs.
#43
#44
parent
7473fd8a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/plugins/trackservice.py
+27
-5
27 additions, 5 deletions
modules/plugins/trackservice.py
with
27 additions
and
5 deletions
modules/plugins/trackservice.py
+
27
−
5
View file @
8d9c9884
...
@@ -64,6 +64,11 @@ class TrackServiceHandler():
...
@@ -64,6 +64,11 @@ class TrackServiceHandler():
def
on_queue
(
self
,
entries
):
def
on_queue
(
self
,
entries
):
"""
"""
Items have been queued. They are stored to the local playlog, allowing later
matching and retrieval to augment meta-information.
Args:
entries ([PlaylistEntry]): The entries which got queued
"""
"""
for
entry
in
entries
:
for
entry
in
entries
:
self
.
playlog
.
add
(
entry
)
self
.
playlog
.
add
(
entry
)
...
@@ -100,6 +105,7 @@ class TrackServiceHandler():
...
@@ -100,6 +105,7 @@ class TrackServiceHandler():
self
.
store_clock_info
(
data
)
self
.
store_clock_info
(
data
)
def
on_metadata
(
self
,
meta
):
def
on_metadata
(
self
,
meta
):
"""
"""
Some metadata update was sent from Liquidsoap.
Some metadata update was sent from Liquidsoap.
...
@@ -138,7 +144,6 @@ class TrackServiceHandler():
...
@@ -138,7 +144,6 @@ class TrackServiceHandler():
self
.
store_trackservice
(
data
)
self
.
store_trackservice
(
data
)
self
.
store_clock_info
(
data
)
self
.
store_clock_info
(
data
)
def
store_trackservice
(
self
,
data
):
def
store_trackservice
(
self
,
data
):
...
@@ -163,8 +168,8 @@ class TrackServiceHandler():
...
@@ -163,8 +168,8 @@ class TrackServiceHandler():
"""
"""
current_playlist
=
self
.
engine
.
scheduler
.
get_active_playlist
()
current_playlist
=
self
.
engine
.
scheduler
.
get_active_playlist
()
(
past_timeslot
,
current_timeslot
,
next_timeslot
)
=
self
.
playlog
.
get_timeslots
()
(
past_timeslot
,
current_timeslot
,
next_timeslot
)
=
self
.
playlog
.
get_timeslots
()
next_timeslot
=
self
.
engine
.
scheduler
.
get_next_
schedule
s
(
1
)
#
next_timeslot = self.engine.scheduler.get_next_
timeslot
s(1)
if
next_timeslot
:
next_timeslot
=
next_timeslot
[
0
]
#
if next_timeslot: next_timeslot = next_timeslot[0]
data
=
dict
()
data
=
dict
()
data
[
"
engine_source
"
]
=
self
.
config
.
get
(
"
api_engine_number
"
)
data
[
"
engine_source
"
]
=
self
.
config
.
get
(
"
api_engine_number
"
)
...
@@ -239,13 +244,21 @@ class Playlog:
...
@@ -239,13 +244,21 @@ class Playlog:
def
set_timeslot
(
self
,
timeslot
):
def
set_timeslot
(
self
,
timeslot
):
"""
"""
Sets the current timeslot and proper default values if no timeslot is available.
Any previous timeslot is stored to `self.previous_timeslot` and the following one
to `self.next_timeslot`.
This method is protect by overwritting by multiple calls with the same timeslot.
Args:
timeslot (Timeslot): The current timeslot
"""
"""
if
timeslot
and
self
.
previous_timeslot
:
if
timeslot
and
self
.
previous_timeslot
:
if
self
.
previous_timeslot
.
get
(
"
schedule_start
"
)
==
timeslot
.
schedule_start
:
if
self
.
previous_timeslot
.
get
(
"
schedule_start
"
)
==
timeslot
.
schedule_start
:
return
# Avoid overwrite by multiple calls in a row
return
# Avoid overwrite by multiple calls in a row
data
=
{}
data
=
{}
next_timeslot
=
self
.
engine
.
scheduler
.
get_next_
schedule
s
(
1
)
next_timeslot
=
self
.
engine
.
scheduler
.
get_next_
timeslot
s
(
1
)
if
next_timeslot
:
next_timeslot
=
next_timeslot
[
0
]
if
next_timeslot
:
next_timeslot
=
next_timeslot
[
0
]
if
timeslot
:
if
timeslot
:
...
@@ -281,7 +294,7 @@ class Playlog:
...
@@ -281,7 +294,7 @@ class Playlog:
data
[
"
schedule_end
"
]
=
datetime
.
now
()
+
timedelta
(
hours
=
1
)
data
[
"
schedule_end
"
]
=
datetime
.
now
()
+
timedelta
(
hours
=
1
)
if
self
.
next_timeslot
:
if
next_timeslot
:
ns
=
{}
ns
=
{}
self
.
assign_fallback_playlist
(
ns
,
next_timeslot
)
self
.
assign_fallback_playlist
(
ns
,
next_timeslot
)
ns
[
"
schedule_id
"
]
=
next_timeslot
.
schedule_id
ns
[
"
schedule_id
"
]
=
next_timeslot
.
schedule_id
...
@@ -298,6 +311,11 @@ class Playlog:
...
@@ -298,6 +311,11 @@ class Playlog:
def
assign_fallback_playlist
(
self
,
data
,
timeslot
):
def
assign_fallback_playlist
(
self
,
data
,
timeslot
):
"""
"""
Assigns fallback info to the given timeslot.
Args:
data ({}): The dictionary holding the (virtual) timeslot
timeslot (Timeslot): The actual timeslot object to retrieve fallback info from
"""
"""
fallback_type
=
None
fallback_type
=
None
playlist
=
None
playlist
=
None
...
@@ -318,6 +336,10 @@ class Playlog:
...
@@ -318,6 +336,10 @@ class Playlog:
def
get_timeslots
(
self
):
def
get_timeslots
(
self
):
"""
"""
Retrieves all available timeslots for the past, future and the current one.
Returns:
({}, {}, {})
"""
"""
return
(
self
.
previous_timeslot
,
self
.
current_timeslot
,
self
.
next_timeslot
)
return
(
self
.
previous_timeslot
,
self
.
current_timeslot
,
self
.
next_timeslot
)
...
...
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