talmobi / yt-search

100 stars 33 forks source link

ChannelSearchResult[] returning incorrect info #71

Closed maxxestes closed 1 year ago

maxxestes commented 1 year ago

What I'm guessing is a YouTube update has broken the return of ChannelSearchResult. The number in this person's google account is taking the place of the sub-count. I'm guessing this is where the sub-count used to be. this also affects the video number since the sub count is where THAT used to be. I'm still able to do what I wanted to since the sub count is just in the videoCount though.

Edit: Seems like the issue changes if the user's name doesn't have a number in it. The subCount and subCountLabel is undefined while everything else is correct.

var yts = require("yt-search")
const options = {search: "Seek and Destroy - Metallica music video", category: 'music', pageStart: 1, pageEnd: 1, gl: 'US'};

let results = await yts(options);
let authorChannel = results.videos[0].author.name;
const channelOptions = {search: authorChannel, pageStart: 1, pageEnd: 1, gl: 'US'};
let channel = await yts(channelOptions);
if (channel.channels[0]){
    console.log(channel.channels[0].subCount);
    console.log(channel.channels[0].subCountLabel);
    console.log(channel.accounts[0].videoCount);
    console.log(channel.accounts[0].name);
    console.log(channel.accounts[0].title);
    console.log(channel.accounts[0].image);
    console.log(channel.accounts[0].url);
    console.log(channel.accounts[0].thumbnail);
}

output:
9579
"@juandavidgiraldo9579"
228
"juan david giraldo"
"https://yt3.googleusercontent.com/ytc/AMLnZu962Tv5IhJOEcgXv-PI2ZbVKTR1-nmdvh3jPsLm=s88-c-k-c0x00ffffff-no-rj-mo"
"https://youtube.com/@juandavidgiraldo9579"
"https://yt3.googleusercontent.com/ytc/AMLnZu962Tv5IhJOEcgXv-PI2ZbVKTR1-nmdvh3jPsLm=s88-c-k-c0x00ffffff-no-rj-mo"
undefined

expected:
228
N/A
N/A
"juan david giraldo"
"https://yt3.googleusercontent.com/ytc/AMLnZu962Tv5IhJOEcgXv-PI2ZbVKTR1-nmdvh3jPsLm=s88-c-k-c0x00ffffff-no-rj-mo"
"https://youtube.com/@juandavidgiraldo9579"
"https://yt3.googleusercontent.com/ytc/AMLnZu962Tv5IhJOEcgXv-PI2ZbVKTR1-nmdvh3jPsLm=s88-c-k-c0x00ffffff-no-rj-mo"
undefined
talmobi commented 1 year ago

@maxxestes thank you for the report, there is indeed an issue like you say with sub count and video count -- I will look into it and also update tests 🙇

maxxestes commented 1 year ago

@talmobi No problem! Glad I could help. This is my first time submitting an issue so do you know if it sends a GitHub notification like when you @ me when this issue is closed? If not could you @ me again when it's resolved? I'll need to update my code to use the sub-count whenever I can. Thanks in advance.

talmobi commented 1 year ago

@maxxestes I'm not sure, but I will ping you.

It looks like channel results don't include video count anymore, and that the sub count is misplaced where video count used to be -- and the channel name is where sub count used to be -- similar to what you already pointed out.

They might have done it like this because the channel results used to show "sub count | video count" and now it shows "channel name | sub count" -- and they decided to change result data to display it differently...

It's a bit messed up and weird -- YouTube might update/change it again soon to something else -- but looks like video count is not available anymore -- I will add a fallback for the sub count.

maxxestes commented 1 year ago

I completely agree with your diagnosis. One thing I'll add though is that the reason it doesn't work is the addition of handles. https://support.google.com/youtube/answer/11585688?visit_id=638093115105766534-473352333&p=handles_info&rd=1. Seems like their attempt at a unique @ like Twitter so I don't think that it's going anywhere. There is a definite possibility that YouTube could change the positioning though.

talmobi commented 1 year ago

@maxxestes updated v 2.10.4 to parse sub count correctly and sets unavailable video count to -1.