Show which video will be played next

This commit is contained in:
Joscha 2018-08-11 18:14:01 +00:00
parent 572fc78b8b
commit f119029055

View file

@ -91,6 +91,14 @@ class Playlist:
]
return "\n".join(lines)
@staticmethod
def format_next(video, player):
if video and player:
player = mention(player, ping=False)
return f"Next: {video.title!r} from {player}"
else:
return "Next: Nothing"
# commands regarding currently playing video
def play(self, room):
@ -112,8 +120,13 @@ class Playlist:
self.playing_video = video
self.playing_until = time.time() + duration
message = self.format_play(video, player)
await room.send(message)
text = self.format_play(video, player)
msg = await room.send(text)
next_video = self.next()
video, player = next_video if next_video else (None, None)
text = self.format_next(video, player)
await room.send(text, msg.mid)
await asyncio.sleep(duration)
@ -152,6 +165,9 @@ class Playlist:
def items(self):
return enumerate(self.waiting)
def next(self):
return self.waiting[0] if self.waiting else None
def playtime_left(self):
if self.playing_until:
seconds = self.playing_until - time.time()