디스코드봇 ffmpeng File ended prematurely at pos. 계속 이렇게 오류떠요 도와주세요
조회수 778회
import discord
import re
import asyncio
import random
import openpyxl
import datetime
import pytz
import youtube_dl
import os
youtube_dl.utils.bug_reports_message = lambda: ''
ytdl_format_options = {
'format': 'bestaudio/best',
'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
'restrictfilenames': True,
'noplaylist': True,
'nocheckcertificate': True,
'ignoreerrors': False,
'logtostderr': False,
'quiet': True,
'no_warnings': True,
'default_search': 'auto',
'source_address': '0.0.0.0' # bind to ipv4 since ipv6 addresses cause issues sometimes
}
ffmpeg_options = {
'options': '-vn'
}
ytdl = youtube_dl.YoutubeDL(ytdl_format_options)
class YTDLSource(discord.PCMVolumeTransformer):
def __init__(self, source, *, data, volume=0.2):
super().__init__(source, volume)
self.data = data
self.title = data.get('title')
self.url = data.get('url')
@classmethod
async def from_url(cls, url, *, loop=None, stream=False):
loop = loop or asyncio.get_event_loop()
data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream))
if 'entries' in data:
data = data['entries'][0]
filename = data['url'] if stream else ytdl.prepare_filename(data)
return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data)
client = discord.Client()
queues = {} #큐
def check_queue(id):
queues[id].start()
if queues[id] != []:
player = queues[id].pop(0)
players[guild.id] = player
player.start() # queues = {} 저장했던 노래 정보를 불러오는 구문
@client.event
async def on_message(message):
if message.content.lower().startswith("-mplay"):
msg = message.content.split(" ")
try:
url = message.content.replace("-mplay ", '')
guild = message.guild
voice_client = guild.voice_client
if voice_client == None:
vc = message.author.voice.channel
await vc.connect()
vc2 = guild.voice_client
player = await YTDLSource.from_url(url)
vc2.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
emb = discord.Embed(title=None, description=f"Now Playing {player.title}" + "[" + "<@" + str(message.author.id) + ">" + "]", color=0x049e46)
await message.channel.send(content=None, embed=emb)
else:
guild = message.guild
voice_client = guild.voice_client
player = await YTDLSource.from_url(url)
voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
except:
player = await YTDLSource.from_url(url)
emb = discord.Embed(title=None, description=f"Queued {player.title}" + " [" + "<@" + str(message.author.id) + ">" + "]", color=0x049e46)
await message.channel.send(content=None, embed=emb)
if guild.id in queues: # 큐 에다가 저장 하는구문
queues[guild.id].append(player.title)
else:
queues[guild.id] = [player.title]
-mplay 노래이름 으로 노래를 틀었을때 노래가 끝난후 queues 저장한노래가 재생 되어야하는데 계속 [matroska,webm @ 000001fdacef8740] File ended prematurely at pos. 267761 (0x415f1) 이 오류가 뜨네요. 도와주세요. 정리 못한점 죄송합니다.
-
(•́ ✖ •̀)
알 수 없는 사용자
댓글 입력