Androz2091 / discord-player

🎧 Complete framework to simplify the implementation of music commands using discord.js v14
https://discord-player.js.org/
MIT License
589 stars 192 forks source link

player cannot search for songs on m.youtube.com #1891

Closed ringo360 closed 5 months ago

ringo360 commented 5 months ago

Describe the bug When a user searches for a song on m.youtube.com, the result is not found

To Reproduce Steps to reproduce the behavior:

  1. Make discord bot
  2. Write the code like this:
    const player = useMainPlayer();
    const query = 'https://m.youtube.com/watch?v=u9Bh7N2LrVs'
    const searchResult = await player.search(query, {
    searchEngine: QueryType.AUTO,
    });
    if (
    !searchResult ||
    searchResult.tracks.length == 0 ||
    !searchResult.tracks
    ) {
    console.log('Failed to search');
    } else {
    //...
    }

Expected behavior The song plays correctly.

Screenshots Nothing

Please complete the following information:

Additional context I'm thinking that it might be possible to fix it by redirecting the m.youtube.com domain to youtube.com or by replacing it with replace.

Sorry for bad English. I used translator because I'm not good at English :/

twlite commented 5 months ago

https://github.com/Androz2091/discord-player/blob/b677fbf659a2f30535ed57bf0abc9adccc6339ad/packages/discord-player/src/utils/QueryResolver.ts#L24 I think it is happening because this line does not contain m.youtube.com, which makes query resolver reject this query.