Show which video will be played next
This commit is contained in:
parent
572fc78b8b
commit
f119029055
1 changed files with 18 additions and 2 deletions
|
|
@ -91,6 +91,14 @@ class Playlist:
|
||||||
]
|
]
|
||||||
return "\n".join(lines)
|
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
|
# commands regarding currently playing video
|
||||||
|
|
||||||
def play(self, room):
|
def play(self, room):
|
||||||
|
|
@ -112,8 +120,13 @@ class Playlist:
|
||||||
self.playing_video = video
|
self.playing_video = video
|
||||||
self.playing_until = time.time() + duration
|
self.playing_until = time.time() + duration
|
||||||
|
|
||||||
message = self.format_play(video, player)
|
text = self.format_play(video, player)
|
||||||
await room.send(message)
|
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)
|
await asyncio.sleep(duration)
|
||||||
|
|
||||||
|
|
@ -152,6 +165,9 @@ class Playlist:
|
||||||
def items(self):
|
def items(self):
|
||||||
return enumerate(self.waiting)
|
return enumerate(self.waiting)
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
return self.waiting[0] if self.waiting else None
|
||||||
|
|
||||||
def playtime_left(self):
|
def playtime_left(self):
|
||||||
if self.playing_until:
|
if self.playing_until:
|
||||||
seconds = self.playing_until - time.time()
|
seconds = self.playing_until - time.time()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue