retrouser955 / discord-player-youtubei

Super charging your bot. dpy is a tiny extractor module to test the validity of youtubei.js in discord-player version 7.
https://discord-player.js.org
Creative Commons Zero v1.0 Universal
25 stars 8 forks source link

player.search fails to find any results for a query #2

Closed febkosq8 closed 4 months ago

febkosq8 commented 4 months ago

Trying to search for a query always returns no search results when we have discord-player-youtubei registered.

Same issue persists with or without authentication

Adding debug info below

C:\Users\Febkosq8\Documents\Git\Jappan_Discord_Bot>npm list
jappan@1.4.4 C:\Users\Febkosq8\Documents\Git\Jappan_Discord_Bot
├── @discord-player/equalizer@0.2.3
├── @discord-player/extractor@4.4.7
├── @discord-player/utils@0.2.2
├── @discordjs/voice@0.17.0
├── axios@1.7.2
├── colorette@2.0.20
├── discord-player-youtubei@1.0.1
├── discord-player@6.6.10
├── discord.js@14.15.3
├── dotenv@16.4.5
├── mediaplex@0.0.9
├── mongoose@8.4.4
├── nodemon@3.1.4
├── prettier@3.3.2
└── ytdl-core@4.11.5

Player Deps

[NOTICE] playerDeps being logged to console
Discord Player
--------------------------------------------------
- discord-player: 6.6.10
- discord-voip: 0.1.3
- discord.js: 14.15.3
- Node version: v20.13.1 (Detected Runtime: Node, Platform: win32 [x64])
- ffmpeg: 7.0-full_build-www.gyan.dev
- command: ffmpeg
- static: false
- libopus: true

Loaded Extractors:
--------------------------------------------------
com.retrouser955.discord-player.discord-player-youtubei
com.discord-player.spotifyextractor
com.discord-player.applemusicextractor
com.discord-player.soundcloudextractor
com.discord-player.vimeoextractor
com.discord-player.reverbnationextractor
com.discord-player.attachmentextractor

discord-voip
--------------------------------------------------
Core Dependencies
- discord-voip: 0.1.3
- @discord-player/opus: 0.1.2
- prism-media: 1.3.5

Opus Libraries
- mediaplex: 0.0.9
- @discordjs/opus: not found
- opusscript: not found

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.13
- tweetnacl: not found

FFmpeg
- version: 7.0-full_build-www.gyan.dev
- libopus: yes
- static: no
--------------------------------------------------

index.js - Loading the extractor

...
const { Player, useMainPlayer } = require("discord-player");
const { YoutubeiExtractor } = require("discord-player-youtubei");
const player = new Player(client, { skipFFmpeg: false });
await player.extractors.register(YoutubeiExtractor, {});
await player.extractors.loadDefault((ext) => ext !== "YouTubeExtractor");
...

play.js

...
const query = interaction.options.getString("query");
const searchResult = await player.search(query, {
    requestedBy: interaction.user,
    fallbackSearchEngine: "youtubeSearch",
});
console.log({ searchResult });

if (!searchResult.hasTracks()) {
    return await interaction.editReply(`We found no tracks for ${query}!`);
} else {
    await PlayerHandler.playGuildPlayer({ interaction, searchResult });
}
...

output of searchResult on a sample play query of "boy bad"

{
  searchResult: SearchResult {
    player: Player {
      _events: [Object: null prototype] {},
      _eventsCount: 0,
      _maxListeners: undefined,
      requiredEvents: [Array],
      id: '1256888139293659136',
      nodes: [GuildNodeManager],
      voiceUtils: [VoiceUtils],
      extractors: [ExtractorExecutionContext],
      events: [PlayerEventsEmitter],
      routePlanner: null,
      version: '6.6.10',
      lyrics: [LrcLib],
      client: [Client],
      options: [Object],
      [Symbol(shapeMode)]: false,
      [Symbol(kCapture)]: false
    },
    _data: {
      query: 'boy bad',
      queryType: 'youtubeSearch',
      requestedBy: [User],
      extractor: undefined
    }
  }
}
retrouser955 commented 4 months ago

Heyyy @febkosq8 could you try 1.0.2? This version includes fixes by @zijipia.

If that doesn't work, could you try manually searching with YouTubei.js?

typescript

import Innertube from "youtubei.js"

const tube = await Innertube.create()

console.log((await tube.search('boy bad')).results)

similarly, getting URL info

import Innertube from "youtubei.js"

const tube = await Innertube.create()

console.log((await tube.getBasicInfo('youtubeid')).basic_info)
retrouser955 commented 4 months ago

As per Discord, it is confirmed that search has been fixed and now streaming content is not working. Investigating this rn!

febkosq8 commented 4 months ago

Solved with #5 and v1.0.7

Can play youtube songs and playlists now