DrKain/scrape-youtube

[Feature request] Support for new channel handles

Closed this issue · 9 comments

Currently the old channel ID/URL is returned (still working) but YouTube is using @ handles.
This should be included in the 'channel' object along with the old ID.
Example:

{
    "id": "UCYDD7WruLEgEBfjxeor48aw",
    "name": "The Heavy",
    "link": "https://www.youtube.com/channel/UCYDD7WruLEgEBfjxeor48aw",
    "verified": true,
    "thumbnail": "https://yt3.ggpht.com/oMj9hZlJsbS-JI4MUZnwPDcfwIW36KhYeA5CnOG3_5lwHPnmaY_FL5hjBuUFBo32esrBmoOiZKI=s0?imgmax=0"
}

..will become:

{
    "id": "UCYDD7WruLEgEBfjxeor48aw",
    "name": "The Heavy",
    "handle": "@TheHeavyOfficial",
    "link": "https://www.youtube.com/@TheHeavyOfficial",
    "verified": true,
    "thumbnail": "https://yt3.ggpht.com/oMj9hZlJsbS-JI4MUZnwPDcfwIW36KhYeA5CnOG3_5lwHPnmaY_FL5hjBuUFBo32esrBmoOiZKI=s0?imgmax=0"
}

ID should remain as it is unique/locked, unlike handles.

Would you assign this issue to me @DrKain

Sure thing

Yes, the interface should be updated accordingly

how can I get the handle detail?

exports.getChannelData = function (video) {
    var channel = (video.ownerText || video.longBylineText)['runs'][0];
    return {
        id: channel.navigationEndpoint.browseEndpoint.browseId,
        name: channel.text,
        link: getChannelLink(channel),
        verified: isVerified(video),
        thumbnail: getChannelThumbnail(video)
    };
};

so after that, I can add a handle here
file location scrape-youtube\lib\parser.js

how can I get the handle detail?

You'll need to take a look at the render data to see where it's available. The best place to look would be the channel object.

so after that, I can add a handle here
file location scrape-youtube\lib\parser.js

You won't need to modify the lib directory as it's auto-generated by the build script.

Thank for it
but i didn't find any way to get youtube handle

That's fine, I'll un-assign and leave it open for another user unless I find the time later this week.

Note for anyone reading this issue, the YouTube render data hasn't fully rolled out handles for all channels. I'm about to push an update shortly closing this issue but handles will be either null or a string.

If a handle is found the channel link will use the handle, otherwise it will default to the channel ID.

A good example of this is "The Heavy" topic channel, these are auto generated and do not have handles.
https://www.youtube.com/channel/UCbGFbVqBTN3aCjUwz3FChFw

 {
    id: 'UCbGFbVqBTN3aCjUwz3FChFw',
    name: 'The Heavy - Topic',
    link: 'https://www.youtube.com/channel/UCbGFbVqBTN3aCjUwz3FChFw',
    handle: null,
    verified: false,
    thumbnail: 'https:https://yt3.ggpht.com/oMj9hZlJsbS-JI4MUZnwPDcfwIW36KhYeA5CnOG3_5lwHPnmaY_FL5hjBuUFBo32esrBmoOiZKI=s0?imgmax=0',
    description: '',
    videoCount: 139,
    subscribers: '0',
    subscriberCount: 0
  },
  {
    id: 'UCMBr8hDifMR8C8uNnTvzL-w',
    name: 'ROY Shiel-Roberts',
    link: 'https://www.youtube.com/@royshiel-roberts9035',
    handle: '@royshiel-roberts9035',
    verified: false,
    thumbnail: 'https://yt3.googleusercontent.com/ytc/AL5GRJVvrxLPwLVu5QmBhZYr1dyVFYVHb9PNK7iNAudCbA=s0?imgmax=0',
    description: 'For fun and my gaming stuff.',
    videoCount: 0,
    subscribers: '3',
    subscriberCount: 3
  }