Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
radiopanik
django-panik-nonstop
Commits
913f8462
Commit
913f8462
authored
Jun 14, 2020
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stamina: add "soft stop" in nonstop zones
parent
20fc4ca6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
nonstop/management/commands/stamina.py
nonstop/management/commands/stamina.py
+8
-3
No files found.
nonstop/management/commands/stamina.py
View file @
913f8462
...
...
@@ -120,6 +120,7 @@ class Command(BaseCommand):
if
isinstance
(
slot
,
Nonstop
):
self
.
playlist
=
self
.
get_playlist
(
slot
,
now
,
slot
.
end_datetime
)
self
.
playhead
=
0
self
.
softstop
=
False
while
True
:
now
=
datetime
.
datetime
.
now
()
try
:
...
...
@@ -130,8 +131,9 @@ class Command(BaseCommand):
print
(
now
,
track
.
title
,
track
.
duration
,
'- future tracks:'
,
[
x
.
title
for
x
in
self
.
playlist
[
self
.
playhead
+
1
:
self
.
playhead
+
3
]])
await
self
.
player_process
(
track
)
# TODO: detect "soft spot", to switch to another nonstop
# tranche
if
self
.
softstop
:
# track was left to finish, but now the playlist should stop.
break
self
.
playhead
+=
1
elif
slot
.
is_stream
():
print
(
now
,
'playing stream'
,
slot
.
stream
)
...
...
@@ -245,7 +247,10 @@ class Command(BaseCommand):
expected_slot
=
self
.
slot
if
current_slot
!=
expected_slot
:
print
(
now
,
'unexpected change'
,
current_slot
,
'vs'
,
expected_slot
)
if
isinstance
(
current_slot
,
Nonstop
)
and
not
isinstance
(
expected_slot
,
Nonstop
):
if
isinstance
(
current_slot
,
Nonstop
)
and
isinstance
(
expected_slot
,
Nonstop
):
# ask for a softstop, i.e. finish the track then switch.
self
.
softstop
=
True
else
:
# interrupt nonstop
print
(
'interrupting nonstop'
)
self
.
play_task
.
cancel
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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