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

Empty video title + view count when getting any video's information #41

Open
Serena1432 opened this issue Nov 25, 2024 · 5 comments
Open
Labels
bug Something isn't working

Comments

@Serena1432
Copy link

Describe the bug

Recently I found out this ytdl-core library is unable to return the correct title and view count of any video. The title is always empty, and the view count is always 0.

Besides that, the library can still get the video URL properly, so I'm 100% sure that it isn't because of YouTube blocking due to age/country restriction or anything else.

I'm using my own OAuth2 key generated by cobalt library, and before maybe November 22 the library still worked flawlessly.

image

(Sorry for the bad font rendering, my Linux browser refuses to render the font in Amazon SSH website correctly)

Error Details (Log)

I added YTDL_DEBUG=true to my ENV but I didn't get any errors in the console, or I didn't actually know where it was. But here is one of the returned video object while requesting to https://www.youtube.com/watch?v=c5_0NPftdlY:

{
  videoDetails: {
    videoUrl: 'https://www.youtube.com/watch?v=c5_0NPftdlY',
    videoId: 'c5_0NPftdlY',
    playabilityStatus: 'UNKNOWN',
    title: '',
    author: null,
    lengthSeconds: 210,
    viewCount: 0,
    likes: null,
    media: null,
    storyboards: [ [Object], [Object], [Object] ],
    chapters: [],
    thumbnails: [ [Object] ],
    description: null,
    keywords: [],
    channelId: 'UC0YCzDj9HuC97mr2BzlaSBg',
    ageRestricted: false,
    allowRatings: true,
    isOwnerViewing: false,
    isCrawlable: true,
    isPrivate: false,
    isUnpluggedCorpus: false,
    isLiveContent: false,
    isUpcoming: false,
    isLowLatencyLiveStream: false,
    liveBroadcastDetails: null,
    published: null,
    publishDate: null,
    latencyClass: null,
    musicVideoType: 'MUSIC_VIDEO_TYPE_OMV'
  },
  relatedVideos: [],
  formats: [
    {
      itag: 18,
      url: '(redacted)',
      mimeType: 'video/mp4; codecs="avc1.42001E, mp4a.40.2"',
      codec: [Object],
      quality: [Object],
      bitrate: 487228,
      audioBitrate: 96,
      contentLength: '12777562',
      container: 'mp4',
      hasVideo: true,
      hasAudio: true,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 136,
      url: '(redacted)',
      mimeType: 'video/mp4; codecs="avc1.4d401f"',
      codec: [Object],
      quality: [Object],
      bitrate: 1872717,
      audioBitrate: NaN,
      contentLength: '11383987',
      container: 'mp4',
      hasVideo: true,
      hasAudio: false,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 247,
      url: '(redacted)',
      mimeType: 'video/webm; codecs="vp9"',
      codec: [Object],
      quality: [Object],
      bitrate: 1454907,
      audioBitrate: NaN,
      contentLength: '15589370',
      container: 'webm',
      hasVideo: true,
      hasAudio: false,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 398,
      url: '(redacted)',
      mimeType: 'video/mp4; codecs="av01.0.05M.08.0.110.06.01.06.0"',
      codec: [Object],
      quality: [Object],
      bitrate: 1294356,
      audioBitrate: NaN,
      contentLength: '11674891',
      container: 'mp4',
      hasVideo: true,
      hasAudio: false,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 135,
      url: '(redacted)',
      mimeType: 'video/mp4; codecs="avc1.4d401f"',
      codec: [Object],
      quality: [Object],
      bitrate: 999904,
      audioBitrate: NaN,
      contentLength: '7186615',
      container: 'mp4',
      hasVideo: true,
      hasAudio: false,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 397,
      url: '(redacted)',
      mimeType: 'video/mp4; codecs="av01.0.04M.08.0.110.06.01.06.0"',
      codec: [Object],
      quality: [Object],
      bitrate: 755709,
      audioBitrate: NaN,
      contentLength: '5829317',
      container: 'mp4',
      hasVideo: true,
      hasAudio: false,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 244,
      url: '(redacted)',
      mimeType: 'video/webm; codecs="vp9"',
      codec: [Object],
      quality: [Object],
      bitrate: 734445,
      audioBitrate: NaN,
      contentLength: '8459421',
      container: 'webm',
      hasVideo: true,
      hasAudio: false,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 134,
      url: '(redacted)',
      mimeType: 'video/mp4; codecs="avc1.4d401e"',
      codec: [Object],
      quality: [Object],
      bitrate: 585245,
      audioBitrate: NaN,
      contentLength: '4955776',
      container: 'mp4',
      hasVideo: true,
      hasAudio: false,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 396,
      url: '(redacted)',
      mimeType: 'video/mp4; codecs="av01.0.01M.08.0.110.06.01.06.0"',
      codec: [Object],
      quality: [Object],
      bitrate: 436569,
      audioBitrate: NaN,
      contentLength: '3499348',
      container: 'mp4',
      hasVideo: true,
      hasAudio: false,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 243,
      url: '(redacted)',
      mimeType: 'video/webm; codecs="vp9"',
      codec: [Object],
      quality: [Object],
      bitrate: 410500,
      audioBitrate: NaN,
      contentLength: '5203576',
      container: 'webm',
      hasVideo: true,
      hasAudio: false,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 133,
      url: '(redacted)',
      mimeType: 'video/mp4; codecs="avc1.4d4015"',
      codec: [Object],
      quality: [Object],
      bitrate: 300504,
      audioBitrate: NaN,
      contentLength: '2742539',
      container: 'mp4',
      hasVideo: true,
      hasAudio: false,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 242,
      url: '(redacted)',
      mimeType: 'video/webm; codecs="vp9"',
      codec: [Object],
      quality: [Object],
      bitrate: 215837,
      audioBitrate: NaN,
      contentLength: '2976810',
      container: 'webm',
      hasVideo: true,
      hasAudio: false,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 395,
      url: '(redacted)',
      mimeType: 'video/mp4; codecs="av01.0.00M.08.0.110.06.01.06.0"',
      codec: [Object],
      quality: [Object],
      bitrate: 204157,
      audioBitrate: NaN,
      contentLength: '1907354',
      container: 'mp4',
      hasVideo: true,
      hasAudio: false,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 160,
      url: '(redacted)',
      mimeType: 'video/mp4; codecs="avc1.4d400c"',
      codec: [Object],
      quality: [Object],
      bitrate: 122609,
      audioBitrate: NaN,
      contentLength: '1558814',
      container: 'mp4',
      hasVideo: true,
      hasAudio: false,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 394,
      url: '(redacted)',
      mimeType: 'video/mp4; codecs="av01.0.00M.08.0.110.06.01.06.0"',
      codec: [Object],
      quality: [Object],
      bitrate: 98476,
      audioBitrate: NaN,
      contentLength: '1292285',
      container: 'mp4',
      hasVideo: true,
      hasAudio: false,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 278,
      url: '(redacted)',
      mimeType: 'video/webm; codecs="vp9"',
      codec: [Object],
      quality: [Object],
      bitrate: 96796,
      audioBitrate: NaN,
      contentLength: '1706774',
      container: 'webm',
      hasVideo: true,
      hasAudio: false,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 251,
      url: '(redacted)',
      mimeType: 'audio/webm; codecs="opus"',
      codec: [Object],
      quality: [Object],
      bitrate: 145762,
      audioBitrate: 160,
      contentLength: '3351247',
      container: 'webm',
      hasVideo: false,
      hasAudio: true,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 140,
      url: '(redacted)',
      mimeType: 'audio/mp4; codecs="mp4a.40.2"',
      codec: [Object],
      quality: [Object],
      bitrate: 132831,
      audioBitrate: 128,
      contentLength: '3398376',
      container: 'mp4',
      hasVideo: false,
      hasAudio: true,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 250,
      url: '(redacted)',
      mimeType: 'audio/webm; codecs="opus"',
      codec: [Object],
      quality: [Object],
      bitrate: 74410,
      audioBitrate: 64,
      contentLength: '1688108',
      container: 'webm',
      hasVideo: false,
      hasAudio: true,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    },
    {
      itag: 249,
      url: '(redacted)',
      mimeType: 'audio/webm; codecs="opus"',
      codec: [Object],
      quality: [Object],
      bitrate: 56454,
      audioBitrate: 48,
      contentLength: '1273961',
      container: 'webm',
      hasVideo: false,
      hasAudio: true,
      isLive: false,
      isHLS: false,
      isDashMPD: false,
      sourceClientName: 'tv'
    }
  ],
  full: true,
  _metadata: {
    isMinimumMode: false,
    clients: [ 'web', 'mweb', 'tv', 'ios' ],
    html5PlayerId: '89dfc5b3',
    id: 'c5_0NPftdlY',
    options: {
      oauth2: [OAuth2],
      hl: 'en',
      gl: 'US',
      rewriteRequest: undefined,
      poToken: '',
      disablePoTokenAutoGeneration: false,
      visitorData: '',
      includesPlayerAPIResponse: false,
      includesNextAPIResponse: false,
      includesOriginalFormatData: false,
      includesRelatedVideo: true,
      clients: [Array],
      disableDefaultClients: false,
      disableRetryRequest: false,
      oauth2Credentials: [Object],
      parsesHLSFormat: false,
      originalProxy: undefined,
      quality: undefined,
      filter: undefined,
      excludingClients: [],
      includingClients: 'all',
      range: undefined,
      begin: undefined,
      liveBuffer: undefined,
      highWaterMark: undefined,
      IPv6Block: undefined,
      dlChunkSize: undefined,
      html5Player: undefined
    }
  },
  _ytdl: { version: '6.0.8' }
}

Environment

  • Video URL: Any
  • @ybd-project/ytdl-core version: 6.0.8 (latest)
  • Node.JS version: 18.20.4 (if I upgrade the Node.JS version, some of the libraries I'm using will throw some errors)
  • Operating system: Ubuntu 24.04.1 LTS (6.8.0-1018-aws)
@Serena1432 Serena1432 added the bug Something isn't working label Nov 25, 2024
@ybd-project
Copy link
Owner

Thank you for your report. What code are you implementing? I have not encountered the issue of empty video titles before.

@Serena1432
Copy link
Author

Serena1432 commented Nov 25, 2024

Thank you for your report. What code are you implementing? I have not encountered the issue of empty video titles before.

Here you go!

const {YtdlCore} = require("@ybd-project/ytdl-core");
var ytdl = new YtdlCore({
    oauth2Credentials: {
        accessToken: process.env.YOUTUBE_ACCESS_TOKEN,
        refreshToken: process.env.YOUTUBE_REFRESH_TOKEN,
        expiryDate: process.env.YOUTUBE_EXPIRY_DATE
    },
    noUpdate: true
});
var video = await ytdl.getFullInfo(url);

And the video object is returned as I described above.

Also if you want the other dependencies I used in my application, here's the dependencies property in package.json:

{
  "dependencies": {
    "@discordjs/builders": "^0.11.0",
    "@discordjs/opus": "^0.9.0",
    "@discordjs/rest": "^2.4.0",
    "@discordjs/voice": "^0.17.0",
    "@haileybot/captcha-generator": "^1.7.0",
    "@ybd-project/ytdl-core": "^6.0.8",
    "discord-api-types": "^0.26.1",
    "discord.js": "^13.17.1",
    "dotenv": "^10.0.0",
    "express": "^4.18.1",
    "ffmpeg": "^0.0.4",
    "fluent-ffmpeg": "^2.1.3",
    "libsodium-wrappers": "^0.7.15",
    "ms": "^2.1.3",
    "pg": "^8.7.1",
    "request": "^2.88.2"
  }
}

@ybd-project
Copy link
Owner

Can you remove the OAuth2 designation? I have recently seen a problem with OAuth2 (I don't know the details...) I have seen some of them.
Also, please use the option logDisplay for error logging, not the environment variable.

const ytdl = new YtdlCore({
    logDisplay: ["debug", "warning", "error"],
});

@hextor1
Copy link

hextor1 commented Nov 26, 2024

Hello @ybd-project Kindly help me to solve the API issues? I will be very thankful to you

@Serena1432
Copy link
Author

Can you remove the OAuth2 designation? I have recently seen a problem with OAuth2 (I don't know the details...) I have seen some of them.

If I remove the OAuth2 designation, the YouTube server will throw the Sign in to confirm you're not a bot error. Even poToken didn't work, so I had to login to my account using OAuth2 and the error was solved.

However even after that, sometimes YouTube just likes to logout my account midway, and I have to restart the application to login again.

Also, please use the option logDisplay for error logging, not the environment variable.

I did that one and here is the logged debug information:

[  DEBUG  ]: To speed up processing, html5Player and signatureTimestamp are pre-fetched and cached.
[  DEBUG  ]: [ Request ]: GET -> https://www.youtube.com/iframe_api
[  DEBUG  ]: [ FileCache ]: "poToken" is cached.
[  DEBUG  ]: [ FileCache ]: "visitorData" is cached.
[  DEBUG  ]: [ FileCache ]: "oauth2" is cached.
[  DEBUG  ]: [ Request ]: GET -> https://www.youtube.com/tv
[  DEBUG  ]: Since PoToken and VisitorData are not specified, they are generated automatically.
[  DEBUG  ]: [ FileCache ]: "poToken" is cached.
[  DEBUG  ]: [ FileCache ]: "visitorData" is cached.
[  DEBUG  ]: [ Request ]: GET -> https://www.youtube.com/s/player/89dfc5b3/player_ias.vflset/en_US/base.js
[  DEBUG  ]: Found YouTube TV script: /s/_/kabuki/_/js/k=kabuki.base.en_US.WgGAeWnWnVg.es5.O/am=ACCJSAAAABQAAAQ/d=1/excm=main/rs=ANjRhVlBZ6zz93LAM6C8-0Dtl8YhRdkWLA/m=base
[  DEBUG  ]: [ Request ]: GET -> https://www.youtube.com/s/_/kabuki/_/js/k=kabuki.base.en_US.WgGAeWnWnVg.es5.O/am=ACCJSAAAABQAAAQ/d=1/excm=main/rs=ANjRhVlBZ6zz93LAM6C8-0Dtl8YhRdkWLA/m=base
[  DEBUG  ]: [ FileCache ]: "html5Player" is cached.
[  DEBUG  ]: Found client ID: 861556708454-d6dlm3lh05idd8npek18k6be8ba3oc68.apps.googleusercontent.com
[  DEBUG  ]: Found client secret: SboVhoG9s0rNafixCSGGKXAT
[  DEBUG  ]: [ FileCache ]: "oauth2" is cached.
[  DEBUG  ]: [ Request ]: POST -> https://www.youtube.com/o/oauth2/token
[  DEBUG  ]: [ FileCache ]: Cache key "html5Player" was available.
[  DEBUG  ]: [ Request ]: POST -> https://www.youtube.com/youtubei/v1/player?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8&prettyPrint=false
[  DEBUG  ]: [ FileCache ]: Cache key "html5Player" was available.
[ WARNING ]: Specify poToken for stable and fast operation. See README for details.
[ WARNING ]: At least one client must be specified.
[  DEBUG  ]: [ Request ]: POST -> https://www.youtube.com/youtubei/v1/player?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8&prettyPrint=false
[  DEBUG  ]: [ Request ]: POST -> https://www.youtube.com/youtubei/v1/player?key=AIzaSyB-63vPrdThhKuerbB2N_l7Kwwcxj6yUAc&prettyPrint=false&id=JbP1BCXQazA&t=iiEj1uZGRneI
[  DEBUG  ]: [ Request ]: POST -> https://www.youtube.com/youtubei/v1/player?prettyPrint=false
[  DEBUG  ]: [ Request ]: POST -> https://www.youtube.com/youtubei/v1/player?prettyPrint=false
[  DEBUG  ]: [ Request ]: POST -> https://www.youtube.com/youtubei/v1/next?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8&prettyPrint=false
[  DEBUG  ]: [ Next ]: Error (Reason: Status Code: 400)
[  DEBUG  ]: [ Web ]: Error (Reason: Status Code: 400)
[  DEBUG  ]: [ MWeb ]: Error (Reason: Status Code: 400)
[  DEBUG  ]: [ Tv ]: Success
[  DEBUG  ]: [ Ios ]: Error (Reason: Status Code: 400)
[  DEBUG  ]: [ FileCache ]: Cache key "html5Player" was available.
[  DEBUG  ]: [ FileCache ]: Cache key "html5Player" was available.
[  DEBUG  ]: [ FileCache ]: Cache key "html5Player" was available.

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

3 participants