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

LOGIN_REQUIRED #760

Open
4 tasks done
tonykx opened this issue Sep 21, 2024 · 8 comments
Open
4 tasks done

LOGIN_REQUIRED #760

tonykx opened this issue Sep 21, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@tonykx
Copy link

tonykx commented Sep 21, 2024

Steps to reproduce

Estou tendo esse problema, por favor, alguém pode verificar o que há de errado no meu código:

case 'playyy': {
try {
if (args.length < 1) {
return reply("Insira o comando, e em seguida um nome para a pesquisa!");
}
const { Innertube } = require('youtubei.js');
const youtube = await Innertube.create({
access_token: "x"
});
const searchResults = await youtube.search(args.join(" "));
if (!searchResults.results || searchResults.results.length === 0) {
return reply("Nenhum vídeo encontrado.");
}
const firstResult = searchResults.results[0];
const videoId = firstResult.id;
const videoInfo = await youtube.getBasicInfo(videoId);
const playabilityStatus = videoInfo.playability_status.status;
const message = Título: ${firstResult.title.text}\n +
Autor: ${firstResult.author.name}\n +
Duração: ${firstResult.duration.text}\n +
Visualizações: ${firstResult.view_count.text}\n +
Publicado: ${firstResult.published.text}\n +
Link: https://www.youtube.com/watch?v=${videoId};
await reply(message);
if (playabilityStatus === 'LOGIN_REQUIRED') {
return reply("Este vídeo requer login para acesso.");
}
const audioFormat = videoInfo.streaming_data?.formats?.find(format => format.mimeType.includes('audio/mp4'));
if (!audioFormat) {
return reply("Formato de áudio não encontrado.");
}
const audioUrl = audioFormat.decipher(youtube.session.player);
const vidName = await getRandom('.mp3');
const path = Del/${vidName};
const writer = fs.createWriteStream(path);
fetch(audioUrl, {
headers: {
'Authorization': Bearer ${accessToken}
}
})
.then(res => {
if (!res.ok) {
throw new Error(Erro na resposta do fetch: ${res.status} ${res.statusText});
}
return res.body.pipe(writer);
})
.catch(err => {
return reply("Erro ao baixar o áudio.");
});
writer.on("finish", async () => {
await conn.sendMessage(from, { audio: { url: path }, mimetype: "audio/mpeg" }, { quoted: info });
await fs.unlinkSync(path);
});

} catch (error) {
    return reply("Ocorreu um erro durante o processamento.");
}
break;

}

Failure Logs

Primeiro resultado encontrado: Video {
  type: 'Video',
  id: '93TXfW3MT4o',
  title: Text {
    runs: [ [TextRun] ],
    text: 'Maria Marçal - Deixa (Clipe Oficial MK Music)'
  },
  snippets: [ { text: [Text], hover_text: [Text] } ],
  expandable_metadata: null,
  thumbnails: [
    Thumbnail {
      url: 'https://i.ytimg.com/vi/93TXfW3MT4o/hq720.jpg?sqp=-oaymwEcCNAFEJQDSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLC_NvVgOH9U00Q_Q8Arf_CJTaccHA',
      width: 720,
      height: 404
    },
    Thumbnail {
      url: 'https://i.ytimg.com/vi/93TXfW3MT4o/hq720.jpg?sqp=-oaymwEcCOgCEMoBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLBRSfxnkxls0dryaNee94lHxdc9kg',
      width: 360,
      height: 202
    }
  ],
  thumbnail_overlays: [
    ThumbnailOverlayTimeStatus {
      type: 'ThumbnailOverlayTimeStatus',
      text: '4:20',
      style: 'DEFAULT'
    },
    ThumbnailOverlayToggleButton {
      type: 'ThumbnailOverlayToggleButton',
      is_toggled: false,
      icon_type: [Object],
      tooltip: [Object],
      toggled_endpoint: [NavigationEndpoint],
      untoggled_endpoint: [NavigationEndpoint]
    },
    ThumbnailOverlayToggleButton {
      type: 'ThumbnailOverlayToggleButton',
      icon_type: [Object],
      tooltip: [Object],
      untoggled_endpoint: [NavigationEndpoint]
    },
    ThumbnailOverlayNowPlaying {
      type: 'ThumbnailOverlayNowPlaying',
      text: 'Now playing'
    },
    ThumbnailOverlayLoadingPreview {
      type: 'ThumbnailOverlayLoadingPreview',
      text: [Text]
    }
  ],
  rich_thumbnail: [
    Thumbnail {
      url: 'https://i.ytimg.com/an_webp/93TXfW3MT4o/mqdefault_6s.webp?du=3000&sqp=CJz2urcG&rs=AOn4CLBLYNbWKcCtBtmpIO-a2VP12BTx9w',
      width: 320,
      height: 180
    }
  ],
  author: Author {
    id: 'UCbVwJCxsVbmaP1PFmbGQDeQ',
    name: 'MK MUSIC',
    thumbnails: [ [Thumbnail] ],
    endpoint: NavigationEndpoint {
      type: 'NavigationEndpoint',
      payload: [Object],
      metadata: [Object]
    },
    badges: [ [MetadataBadge] ],
    is_moderator: false,
    is_verified: true,
    is_verified_artist: false,
    url: 'https://www.youtube.com/@mkmusic'
  },
  badges: [
    MetadataBadge {
      type: 'MetadataBadge',
      style: 'BADGE_STYLE_TYPE_SIMPLE',
      label: '4K'
    },
    MetadataBadge {
      type: 'MetadataBadge',
      style: 'BADGE_STYLE_TYPE_SIMPLE',
      label: 'CC'
    }
  ],
  endpoint: NavigationEndpoint {
    type: 'NavigationEndpoint',
    payload: {
      videoId: '93TXfW3MT4o',
      params: 'qgMFZGVpeGG6AwoIxLLPqoqtguB5ugMLCLOP-N2Wluj79wG6AwoIhL-FmrCnhOpxugMPEg1SRDkzVFhmVzNNVDRvugMKCJe21Kn32s3ZeLoDCgjj-PDouKneyAm6AwsIoL-2ns2i0tDtAboDCwi_l7qd2tL4wrABugMKCKGW1fSf0JfIIboDCgjr0PuL983Mtn66AwsI2rDr887cv7q5AboDCgjf3p-64JSSi366AwsIsq-C6Knxq6P1AboDCgiz6ZKY-tnongu6AwoI3oe35rrDvp47ugMLCLe2ofmpht-N3wG6AwsI56rT_dmnkpXWAboDCgi1-ZyMjIyMpwG6AwsIzOSSqKjm7KDsAfIDBQ14e14-',
      playerParams: 'ygUFZGVpeGE%3D',
      watchEndpointSupportedOnesieConfig: [Object]
    },
    metadata: {
      url: '/watch?v=93TXfW3MT4o&pp=ygUFZGVpeGE%3D',
      page_type: 'WEB_PAGE_TYPE_WATCH',
      api_url: '/player'
    }
  },
  published: Text { text: '1 year ago' },
  view_count: Text { text: '230,956,115 views' },
  short_view_count: Text { text: '230M views' },
  duration: { text: '4:20', seconds: 260 },
  show_action_menu: false,
  is_watched: false,
  menu: Menu {
    type: 'Menu',
    items: [ [MenuServiceItem], [MenuServiceItemDownload], [MenuServiceItem] ],
    top_level_buttons: [],
    label: 'Action menu'
  },
  search_video_result_entity_key: 'Egs5M1RYZlczTVQ0byDnAigB'
}
Informações do vídeo obtidas: VideoInfo {
  basic_info: {
    embed: null,
    channel: null,
    is_unlisted: undefined,
    is_family_safe: undefined,
    category: null,
    has_ypc_metadata: null,
    start_timestamp: null,
    end_timestamp: null,
    view_count: undefined,
    url_canonical: null,
    tags: null,
    like_count: undefined,
    is_liked: undefined,
    is_disliked: undefined
  },
  annotations: undefined,
  storyboards: undefined,
  endscreen: undefined,
  captions: undefined,
  cards: undefined,
  streaming_data: undefined,
  playability_status: {
    status: 'LOGIN_REQUIRED',
    reason: 'Sign in to confirm you’re not a bot',
    embeddable: false,
    audio_only_playablility: null,
    error_screen: PlayerErrorMessage {
      type: 'PlayerErrorMessage',
      subreason: [Text],
      reason: [Text],
      proceed_button: [Button],
      thumbnails: [Array],
      icon_type: 'ERROR_OUTLINE'
    }
  },
  player_config: undefined

Expected behavior

Obter áudio

Current behavior

Obtenho as informações do vídeo, como título, link. Porém não estou conseguindo obter o áudio, pede autorização de login, veja se há algo de errado no meu código.

Version

Default

Anything else?

Se alguém puder corrigir, ficarei grato

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 Sep 21, 2024
@rustynail1984
Copy link

yes, i can confirm that the Trusted Session aka poToken solution isnt working anymore, even on WEB_EMBEDED_PLAYER client.

Another Death Strike, using oAuth Tokens only working for few minutes.. Accounts get banned really quickly.

@tonykx
Copy link
Author

tonykx commented Sep 21, 2024

Sim, posso confirmar que a solução Trusted Session, também conhecida como poToken, não está mais funcionando, mesmo no cliente.WEB_EMBEDED_PLAYER

Outro Death Strike, usando tokens oAuth funcionando apenas por alguns minutos.. As contas são banidas muito rapidamente.

Irmão vc tem alguma solução? Só preciso receber o áudio

@LuanRT
Copy link
Owner

LuanRT commented Sep 21, 2024

@tonykx please use English so others can understand you.
And unfortunately no, there's no solution to this problem yet. You can either login and risk an account or use residential IPs.

@tonykx
Copy link
Author

tonykx commented Sep 21, 2024

por favor, use o inglês para que outras pessoas possam entendê-lo. E infelizmente não, ainda não há solução para esse problema. Você pode fazer login e arriscar uma conta ou usar IPs residenciais.

How can I login to get the audio? It's ok if the Google account is banned. Please adapt it in my code

@retrouser955
Copy link

@tonykx here's an example for oauth2

@tonykx
Copy link
Author

tonykx commented Sep 21, 2024

I left it like this here, but I noticed that it shows a date, meaning it will expire tomorrow, does anyone know what I can do?

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

const { Innertube } = require('youtubei.js');
const youtube = await Innertube.create();

async function signIn() {
    const credentials = {
        access_token: 'x',
        refresh_token: 'x',
        scope: 'x',
        token_type: 'x',
        expiry_date: '2024-09-22T09:24:22.041Z'
    };

    await youtube.session.signIn(credentials);
    await youtube.session.oauth.cacheCredentials();
    console.log('Login bem-sucedido');
}
await signIn();

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

    const videoId = firstResult.id;
    const videoInfo = await youtube.getBasicInfo(videoId);
    const audioFormat = videoInfo.streaming_data?.formats[0]; 
    if (!audioFormat) {
        return reply("Formato de áudio não encontrado.");
    }

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

    const fetch = (await import("node-fetch")).default;

    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;

}

@IRGC
Copy link

IRGC commented Sep 21, 2024

rustynail1984 if we subscribe to youtube premium then use its oauth token will it work?

@IRGC
Copy link

IRGC commented Sep 21, 2024

for some reason i cant play any video while i am logged in to an account i tried subscribing to premium still cant play anything.

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

5 participants