@Bethce

После скачивания плей листа ботом пайтон такая ошибка, как решить OSError: [WinError 10038]?

Ошибка
Command raised an exception: KeyError: 'formats'
Exception in voice thread Thread-9
Traceback (most recent call last):
  File "C:\Users\Артур\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\player.py", line 603, in run
    self._do_run()
  File "C:\Users\Артур\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\player.py", line 596, in _do_run
    play_audio(data, encode=not self.source.is_opus())
  File "C:\Users\Артур\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\voice_client.py", line 638, in send_audio_packet
    self.socket.sendto(packet, (self.endpoint_ip, self.voice_port))
OSError: [WinError 10038] Сделана попытка выполнить операцию на объекте, не являющемся сокетом


Код

import os
import ffmpeg
import asyncio
import discord
import datetime
import json
import requests
import random
from discord.ext import commands
from youtube_dl import YoutubeDL
from asyncio import sleep
from discord.utils import get
from os import system
import asyncio
import aiohttp
import psutil
from asyncio import sleep
from discord import FFmpegPCMAudio, Activity, ActivityType
from discord.ext import commands
from youtube_dl import YoutubeDL
from asyncio import sleep
import requests as rq, time
from discord.ext import tasks
import requests
import json
from pprint import pprint
import pafy
from discord import FFmpegPCMAudio, PCMVolumeTransformer

intents = discord.Intents.default()
intents.members = True

Bot = commands.Bot(intents=intents, command_prefix = lambda b, m: ["m.", "M.", "м.", "М."])
Bot.remove_command('help')

YDL_OPTIONS = {'format': 'worstaudio/best', 'playlist': 'True', 'simulate': 'True',
               'preferredquality': '192', 'preferredcodec': 'mp3', 'key': 'FFmpegExtractAudio'}
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}

@Bot.command()
async def play(ctx, url):
    await ctx.message.author.voice.channel.connect(reconnect=True)
    
    voice = get(Bot.voice_clients, guild=ctx.guild)
    print(voice)
    with YoutubeDL(YDL_OPTIONS) as ydl:
        info = ydl.extract_info(url, download=False)
    URL = info['formats'][0]['url']
    voice.play(discord.FFmpegPCMAudio(executable="C:\\Windows\\System32\\ffmpeg.exe", source = URL, **FFMPEG_OPTIONS))
    voice.is_playing()



Вся консоль
[ START ] #9909 запущен!
<discord.voice_client.VoiceClient object at 0x000001C1D8256790>
[youtube:tab] Downloading playlist PLgULlLHTSGIQ9BeVZY37fJP50CYc3lkW2 - add --no-playlist to just download video MNbM4tA_MmU
[youtube:tab] PLgULlLHTSGIQ9BeVZY37fJP50CYc3lkW2: Downloading webpage
[youtube:tab] PLgULlLHTSGIQ9BeVZY37fJP50CYc3lkW2: Downloading webpage
[download] Downloading playlist: Новинки Музыка 2022 - Популярные Песни -  Плейлист 2022 - Хиты 2022
[youtube:tab] playlist Новинки Музыка 2022 - Популярные Песни -  Плейлист 2022 - Хиты 2022: Downloading 99 videos
[download] Downloading video 1 of 99
[youtube] MNbM4tA_MmU: Downloading webpage
[download] Downloading video 2 of 99
[youtube] YQaG6-RBSzk: Downloading webpage
[download] Downloading video 3 of 99
[youtube] Expq6fmXLUM: Downloading webpage
[download] Downloading video 4 of 99
[youtube] WJvtX-Ec1S8: Downloading webpage
[download] Downloading video 5 of 99
[youtube] Xl08OlVMpI0: Downloading webpage
Обрезал
[youtube] uPQyzWF2-14: Downloading webpage
[download] Downloading video 97 of 99
[youtube] QKX8HRBekTA: Downloading webpage
[download] Downloading video 98 of 99
[youtube] S16Fq5VXqaM: Downloading webpage
[download] Downloading video 99 of 99
[youtube] ewCPQeAtICk: Downloading webpage
[download] Finished downloading playlist: Новинки Музыка 2022 - Популярные Песни -  Плейлист 2022 - Хиты 2022
Command raised an exception: KeyError: 'formats'
Exception in voice thread Thread-9
Traceback (most recent call last):
  File "C:\Users\Артур\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\player.py", line 603, in run
    self._do_run()
  File "C:\Users\Артур\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\player.py", line 596, in _do_run
    play_audio(data, encode=not self.source.is_opus())
  File "C:\Users\Артур\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\voice_client.py", line 638, in send_audio_packet
    self.socket.sendto(packet, (self.endpoint_ip, self.voice_port))
OSError: [WinError 10038] Сделана попытка выполнить операцию на объекте, не являющемся сокетом


После скачивания плейлиста выдает ошибку.
  • Вопрос задан
  • 38 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы