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
7ffb1c3c
Verified
Commit
7ffb1c3c
authored
8 months ago
by
Chris Pastl
Committed by
Ole Binder
6 months ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor: adapt fetch_timeslots, fetch_playlist
parent
48fd5ab4
No related branches found
No related tags found
1 merge request
!46
Steering playout schema and virtual timeslot integration
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/aura_engine/scheduling/api.py
+23
-31
23 additions, 31 deletions
src/aura_engine/scheduling/api.py
with
23 additions
and
31 deletions
src/aura_engine/scheduling/api.py
+
23
−
31
View file @
7ffb1c3c
...
...
@@ -159,23 +159,13 @@ class ApiFetcher(threading.Thread):
@private
"""
api_timeslots
=
None
url
=
self
.
url_api_timeslots
self
.
logger
.
debug
(
"
Fetch timeslots from Steering API...
"
)
url
=
self
.
url_api_timeslots
result
=
self
.
api
.
get
(
url
,
params
=
{
"
includeVirtual
"
:
"
true
"
})
api_timeslots
=
result
.
json
if
not
api_timeslots
:
return
# FIXME Steering doesn't provide JSON as per a valid JSON schema.
# Hence we need to split the array manually for now.
# @see https://gitlab.servus.at/aura/steering/-/issues/154
# api_timetable: list[API_PLAYOUT_ENTRY] = []
# for entry in api_timeslots:
# api_timeslot = API_PLAYOUT_ENTRY.from_dict(entry)
# if self.is_valid_timeslot(entry):
# api_timetable.append(api_timeslot)
# Transform API timeslots to engine timeslots
timeslots
:
list
[
Timeslot
]
=
[]
for
api_ts
in
api_timeslots
:
...
...
@@ -184,29 +174,28 @@ class ApiFetcher(threading.Thread):
id
=
api_ts
.
show
.
id
,
name
=
api_ts
.
show
.
name
,
)
# FIXME There is no defined delimiter for multiple entries of following props yet
# For now only a list with one entry is assigned.
episode
=
Episode
(
id
=
api_ts
.
episode
.
id
,
title
=
api_ts
.
episode
.
title
,
)
episode
=
Episode
(
id
=
ep
.
id
,
title
=
ep
.
title
)
if
(
ep
:
=
api_ts
.
episode
)
and
ep
else
None
# TODO resolve timeslot referenced by `repetition_id`
timeslot
=
Timeslot
(
id
=
api_ts
.
timeslot
.
id
,
repetition_id
=
api_ts
.
timeslot
.
repetition_of_id
,
start
=
api_ts
.
timeslot
.
start
.
timestamp
(),
end
=
api_ts
.
timeslot
.
end
.
timestamp
(),
id
=
api_ts
.
id
,
repetition_id
=
api_ts
.
timeslot
.
repetition_of_id
if
api_ts
.
timeslot
else
None
,
start
=
api_ts
.
start
.
timestamp
(),
end
=
api_ts
.
end
.
timestamp
(),
show
=
show
,
episode
=
episode
,
)
# Fetch playlists for timeslot
playlist_timeslot
=
self
.
fetch_playlist
(
api_ts
.
timeslot
.
playlist_id
)
playlist_schedule
=
(
self
.
fetch_playlist
(
api_ts
.
schedule
.
default_playlist_id
)
if
api_ts
.
schedule
else
None
)
playlist_show
=
self
.
fetch_playlist
(
api_ts
.
show
.
default_playlist_id
)
playlist_timeslot
=
None
playlist_schedule
=
None
playlist_show
=
None
if
(
ts
:
=
api_ts
.
timeslot
)
and
ts
and
(
plid
:
=
ts
.
playlist_id
)
and
plid
:
playlist_timeslot
=
self
.
fetch_playlist
(
plid
)
if
(
sc
:
=
api_ts
.
schedule
)
and
sc
and
(
plid
:
=
sc
.
default_playlist_id
)
and
plid
:
playlist_schedule
=
self
.
fetch_playlist
(
plid
)
if
(
sh
:
=
api_ts
.
show
)
and
sh
and
(
plid
:
=
sh
.
default_playlist_id
):
playlist_show
=
self
.
fetch_playlist
(
plid
)
timeslot
.
set_playlists
(
playlist_timeslot
,
playlist_schedule
,
playlist_show
)
self
.
expand_item_duration
(
playlist_timeslot
)
self
.
expand_item_duration
(
playlist_schedule
)
...
...
@@ -233,11 +222,11 @@ class ApiFetcher(threading.Thread):
playlist
:
Playlist
=
None
url
=
self
.
url_api_playlist
.
replace
(
"
${ID}
"
,
str
(
playlist_id
))
self
.
logger
.
debug
(
"
Fetch playlist from Tank API...
"
)
self
.
logger
.
debug
(
f
"
Fetch playlist
'
{
playlist_id
}
'
from Tank API...
"
)
result
=
self
.
api
.
get
(
url
,
headers
=
self
.
tank_headers
)
SU
.
log_json
(
self
.
logger
,
result
.
json
)
api_playlist
=
API_PLAYLIST
.
from_dict
(
result
.
json
)
if
api_playlist
:
try
:
api_playlist
=
API_PLAYLIST
.
from_dict
(
result
.
json
)
playlist
=
Playlist
(
api_playlist
.
id
,
api_playlist
.
description
,
api_playlist
.
playout_mode
!=
"
linear
"
)
...
...
@@ -266,6 +255,9 @@ class ApiFetcher(threading.Thread):
for
i
in
items
:
playlist
.
add
(
i
)
except
Exception
as
e
:
self
.
logger
.
error
(
SU
.
red
(
f
"
Decode API_PLAYLIST failed:
{
e
}
"
))
return
playlist
@private
...
...
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