Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formato de áudio não encontrado #822

Open
4 tasks done
tonykx opened this issue Nov 29, 2024 · 0 comments
Open
4 tasks done

Formato de áudio não encontrado #822

tonykx opened this issue Nov 29, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@tonykx
Copy link

tonykx commented Nov 29, 2024

Steps to reproduce

case 'p': {
if (args.length < 1) return reply("Insira o comando, e em seguida um nome para a pesquisa!");

const { Innertube } = require('youtubei.js');
const fs = require('fs');
const fetch = require("node-fetch");

// Criação do cliente YouTube com cookie
const youtube = await Innertube.create({
    cookie: 'x'
});

try {
    // Pesquisa no YouTube
    const searchResults = await youtube.search(args.join(" "));
    const firstResult = searchResults.results[0];
    if (!firstResult) return reply("Nenhum vídeo encontrado.");

    // Obter informações do vídeo
    const videoId = firstResult.id;
    const videoInfo = await youtube.getBasicInfo(videoId);
    const audioFormat = videoInfo.streaming_data?.formats.find(f => f.mime_type.includes('audio/mp4'));
    if (!audioFormat) return reply("Formato de áudio não encontrado.");

    // Decifrar URL de áudio
    const audioUrl = audioFormat.decipher(youtube.session.player);
    const vidName = await getRandom('.mp3');
    const path = `Del/${vidName}`;
    const writer = fs.createWriteStream(path);

    // Baixar o áudio
    const audioStream = await fetch(audioUrl);
    if (!audioStream.ok) throw new Error(`Erro ao baixar áudio: ${audioStream.statusText}`);

    audioStream.body.pipe(writer);

    writer.on("finish", async () => {
        console.log("Download Completo!");
        await conn.sendMessage(from, { audio: { url: path }, mimetype: "audio/mpeg" }, { quoted: info });
        fs.unlink(path, (err) => {
            if (err) console.error("Erro ao deletar o arquivo:", err);
        });
    });
} catch (error) {
    console.error("Erro durante o processo:", error);
    reply("Ocorreu um erro ao tentar reproduzir o áudio.");
}

break;

}

Failure Logs

[YOUTUBEJS][Text]: Unable to find matching run for command run. Skipping... {
  command_run: { startIndex: 0, length: 54, onTap: { innertubeCommand: [Object] } },
  input_data: {
    content: 'Maria Marçal - Deixa (Clipe Oficial MK Music) · 4:20',
    commandRuns: [ [Object] ]
  },
  parsed_runs: [
    {
      text: 'Maria Marçal - Deixa (Clipe Oficial MK Music) · 4:20',
      startIndex: 0
    }
  ]
}
[YOUTUBEJS][Text]: Unable to find matching run for command run. Skipping... {
  command_run: { startIndex: 0, length: 55, onTap: { innertubeCommand: [Object] } },
  input_data: {
    content: 'Valesca Mayssa | Eu Sou Teu Pai [Clipe Oficial] · 6:32',
    commandRuns: [ [Object] ]
  },
  parsed_runs: [
    {
      text: 'Valesca Mayssa | Eu Sou Teu Pai [Clipe Oficial] · 6:32',
      startIndex: 0
    }
  ]
}

Expected behavior

Download do áudio

Current behavior

Erro ao encontrar o formato, e encontro apenas informações, como título, etc

Version

Default

Anything else?

Mesmo com o uso de cookies, estou tendo isso, observem minha função que mandei

Checklist

  • I am running the latest version.
  • I checked the documentation and found no answer.
  • I have searched the existing issues and made sure this is not a duplicate.
  • I have provided sufficient information.
@tonykx tonykx added the bug Something isn't working label Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant