Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
radiopanik
django-panik-emissions
Commits
dbb804db
Commit
dbb804db
authored
Jul 16, 2017
by
fred
Browse files
deal with program segments
parent
40d56a7a
Changes
1
Hide whitespace changes
Inline
Side-by-side
emissions/utils.py
View file @
dbb804db
...
...
@@ -179,6 +179,33 @@ def period_program(date_start, date_end, prefetch_sounds=True,
program
=
[
x
for
x
in
program
if
x
is
not
None
]
# add back emissions between short episodes
new_programs
=
[]
for
i
,
slot
in
enumerate
(
program
[:]):
if
not
isinstance
(
slot
,
Schedule
):
continue
slot_end
=
slot
.
datetime
+
timedelta
(
minutes
=
slot
.
emission
.
duration
)
j
=
i
+
1
while
j
<
len
(
program
)
-
1
:
if
program
[
j
]:
this_slot_end
=
program
[
j
].
datetime
+
timedelta
(
minutes
=
program
[
j
].
get_duration
())
if
slot_end
>
this_slot_end
:
# duplicate episode with a different time
schedule
=
Schedule
()
schedule
.
emission
=
slot
.
emission
schedule
.
weeks
=
slot
.
weeks
schedule
.
datetime
=
slot
.
datetime
.
replace
(
hour
=
this_slot_end
.
hour
,
minute
=
this_slot_end
.
minute
)
schedule
.
duration
=
(
program
[
j
+
1
].
datetime
-
this_slot_end
).
seconds
/
60
new_programs
.
append
(
schedule
)
j
+=
1
if
new_programs
:
program
=
program
+
new_programs
program
.
sort
(
key
=
lambda
x
:
x
.
datetime
)
if
not
include_nonstop
:
return
program
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment