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

Add related videos to .getDetails func #69

Closed
piccojs opened this issue Jun 7, 2022 · 7 comments · Fixed by #276
Closed

Add related videos to .getDetails func #69

piccojs opened this issue Jun 7, 2022 · 7 comments · Fixed by #276
Labels
enhancement New feature or request

Comments

@piccojs
Copy link

piccojs commented Jun 7, 2022

It would be great if I could get a list of videos related to a certain ID. Seems easy enough? please help.

@piccojs piccojs added the enhancement New feature or request label Jun 7, 2022
@LuanRT
Copy link
Owner

LuanRT commented Jun 7, 2022

Hi there,

Can you try the latest version? Just do:

npm install git+https://github.com/LuanRT/YouTube.js.git

I'm currently in the process of refactoring some things in the library and I recently added the getInfo method — it can retrieve pretty much everything you want and it is much faster than getDetails.

Ex:

const info = await session.getInfo('VCRkMsOFjI8');
console.log(info.watch_next_feed);

Note:
getDetails is still available but will be removed in future versions.

@piccojs
Copy link
Author

piccojs commented Jun 8, 2022

Merci monsieur 👍

@piccojs piccojs closed this as completed Jun 8, 2022
@walking-octopus
Copy link

It's not yet parsed, but I'll use it after the official release.

@walking-octopus
Copy link

await yt.getInfo("x3IWvqMv8Ms").watch_next_feed returns undefined in v2.0.2.

@absidue
Copy link
Collaborator

absidue commented Jan 5, 2023

The watch_next_feed is always undefined in 2.7.0, I presume YouTube changed their layout breaking the current way of extracting it.

@LuanRT
Copy link
Owner

LuanRT commented Jan 5, 2023

The watch_next_feed is always undefined in 2.7.0, I presume YouTube changed their layout breaking the current way of extracting it.

@absidue
It seems that the VideoInfo class is taking into consideration the layout of an authenticated session, but not that of an unauthenticated one. When logged in, the items of the watch next feed are inside an ItemSection, and along with that node will be a RelatedChipCloud. Something similar to this:

{
  secondary_results: [
    RelatedChipCloud {
      type: 'RelatedChipCloud',
      content: SuperParsedResult {}
    },
    ItemSection {
      type: 'ItemSection',
      header: null,
      contents: [Array],
      target_id: 'sid-wn-chips'
    }
}

An unauthenticated session's secondary_results array will be the watch next feed items themselves instead. No RelatedChipCloud and no ItemSection. So that's why it's undefined for you, it is always looking for an ItemSection even when it's not there:

this.related_chip_cloud = secondary_results.firstOfType(RelatedChipCloud)?.content.item().as(ChipCloud);
this.watch_next_feed = secondary_results.firstOfType(ItemSection)?.contents;

Honestly, I did not realize YouTube didn't allow logged out users to apply filters to that feed.

Anywho, I'll be fixing this later today. Thanks for the heads up!

Edit:
Some images to better demonstrate what I mean.

Logged in:
Screenshot 2023-01-05 173935

Logged out:
Screenshot 2023-01-05 174133

@LuanRT LuanRT reopened this Jan 5, 2023
@absidue
Copy link
Collaborator

absidue commented Jan 5, 2023

That's weird, thanks for looking into it 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants