Handle some edge cases in !queue
This commit is contained in:
parent
7b8fe5509d
commit
4f2ca9c5b6
1 changed files with 11 additions and 9 deletions
|
|
@ -275,22 +275,19 @@ class ArgonDJBot(yaboli.Bot):
|
||||||
|
|
||||||
@yaboli.command("queue", "q")
|
@yaboli.command("queue", "q")
|
||||||
async def command_queue(self, room, message, argstr):
|
async def command_queue(self, room, message, argstr):
|
||||||
lines = []
|
|
||||||
video_ids = []
|
video_ids = []
|
||||||
|
lines_parse_error = []
|
||||||
args = self.parse_args(argstr)
|
args = self.parse_args(argstr)
|
||||||
if not args:
|
|
||||||
await room.send("No videos specified", message.mid)
|
|
||||||
return
|
|
||||||
|
|
||||||
for arg in args:
|
for arg in args:
|
||||||
if arg == "-id": continue
|
if arg == "-id": continue
|
||||||
match = re.match(self.YOUTUBE_RE, arg)
|
match = re.match(self.YOUTUBE_RE, arg)
|
||||||
if match:
|
if match:
|
||||||
video_ids.append(match.group(self.YOUTUBE_RE_GROUP))
|
video_ids.append(match.group(self.YOUTUBE_RE_GROUP))
|
||||||
else:
|
else:
|
||||||
lines.append(f"Could not parse {arg!r}")
|
lines_parse_error.append(f"Could not parse {arg!r}")
|
||||||
|
|
||||||
|
lines = []
|
||||||
|
lines_api_error = []
|
||||||
videos = await self.yt.get_videos(video_ids)
|
videos = await self.yt.get_videos(video_ids)
|
||||||
for vid in video_ids:
|
for vid in video_ids:
|
||||||
video = videos.get(vid)
|
video = videos.get(vid)
|
||||||
|
|
@ -300,10 +297,15 @@ class ArgonDJBot(yaboli.Bot):
|
||||||
|
|
||||||
info = Playlist.format_list_entry(video, position, until)
|
info = Playlist.format_list_entry(video, position, until)
|
||||||
lines.extend(info)
|
lines.extend(info)
|
||||||
|
else:
|
||||||
|
lines_api_error.append(f"Video with id {vid} could not be accessed via the API")
|
||||||
|
|
||||||
|
text = "\n".join(lines + lines_parse_error + lines_api_error)
|
||||||
|
if not lines:
|
||||||
|
await room.send("No valid videos specified\n" + text, message.mid)
|
||||||
|
return
|
||||||
|
|
||||||
text = "\n".join(lines)
|
|
||||||
await room.send(text, message.mid)
|
await room.send(text, message.mid)
|
||||||
|
|
||||||
self.playlist.play(room)
|
self.playlist.play(room)
|
||||||
|
|
||||||
@yaboli.command("skip", "s")
|
@yaboli.command("skip", "s")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue