Compare commits
5 Commits
019e60450f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
69f5af19ae
|
|||
|
7f402e7f52
|
|||
|
44dd986696
|
|||
|
5a4f277aa9
|
|||
|
17f5dca773
|
@@ -254,7 +254,7 @@ async def skip(message):
|
|||||||
if not command_allowed(message):
|
if not command_allowed(message):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not players[message.guild.id].queue:
|
if not players[message.guild.id] and not players[message.guild.id].queue:
|
||||||
message.guild.voice_client.stop()
|
message.guild.voice_client.stop()
|
||||||
await utils.reply(
|
await utils.reply(
|
||||||
message,
|
message,
|
||||||
|
|||||||
15
extra.py
15
extra.py
@@ -2,7 +2,7 @@ import asyncio
|
|||||||
import string
|
import string
|
||||||
|
|
||||||
import disnake
|
import disnake
|
||||||
import youtube_transcript_api
|
from youtube_transcript_api._api import YouTubeTranscriptApi
|
||||||
|
|
||||||
from state import client, kill, players
|
from state import client, kill, players
|
||||||
|
|
||||||
@@ -15,9 +15,8 @@ async def transcript(
|
|||||||
upper=True,
|
upper=True,
|
||||||
):
|
):
|
||||||
initial_id = message.guild.voice_client.source.id
|
initial_id = message.guild.voice_client.source.id
|
||||||
transcript_list = youtube_transcript_api.YouTubeTranscriptApi.list_transcripts(
|
transcript_list = YouTubeTranscriptApi().list(initial_id)
|
||||||
initial_id,
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
transcript = transcript_list.find_manually_created_transcript(languages).fetch()
|
transcript = transcript_list.find_manually_created_transcript(languages).fetch()
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -25,21 +24,21 @@ async def transcript(
|
|||||||
await message.channel.send("(autogenerated)")
|
await message.channel.send("(autogenerated)")
|
||||||
|
|
||||||
messages = []
|
messages = []
|
||||||
for line in transcript:
|
for line in transcript.snippets:
|
||||||
if (
|
if (
|
||||||
players[message.guild.id].current.player.original.progress
|
players[message.guild.id].current.player.original.progress
|
||||||
>= line["start"] + line["duration"]
|
>= line.start + line.duration
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
while (
|
while (
|
||||||
players[message.guild.id].current.player.original.progress < line["start"]
|
players[message.guild.id].current.player.original.progress < line.start
|
||||||
):
|
):
|
||||||
await asyncio.sleep(0.2)
|
await asyncio.sleep(0.2)
|
||||||
|
|
||||||
messages.insert(
|
messages.insert(
|
||||||
0,
|
0,
|
||||||
await message.channel.send(line["text"].upper() if upper else line["text"]),
|
await message.channel.send(line.text.upper() if upper else line.text),
|
||||||
)
|
)
|
||||||
if len(messages) > max_messages:
|
if len(messages) > max_messages:
|
||||||
try:
|
try:
|
||||||
|
|||||||
2
tasks.py
2
tasks.py
@@ -15,7 +15,7 @@ async def cleanup():
|
|||||||
|
|
||||||
targets = []
|
targets = []
|
||||||
for guild_id, player in players.items():
|
for guild_id, player in players.items():
|
||||||
if len(player.queue) == 0:
|
if len(player.queue) == 0 and not player.current:
|
||||||
targets.append(guild_id)
|
targets.append(guild_id)
|
||||||
for target in targets:
|
for target in targets:
|
||||||
del players[target]
|
del players[target]
|
||||||
|
|||||||
Reference in New Issue
Block a user