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

Certain channels do not resolve #297

Closed
ronvoluted opened this issue Jan 4, 2021 · 4 comments
Closed

Certain channels do not resolve #297

ronvoluted opened this issue Jan 4, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@ronvoluted
Copy link

ronvoluted commented Jan 4, 2021

This may be a YouTube limitation but reporting here in case it's otherwise. If you try getChannel() with this URL it will fail with "Item not found" error:

https://www.youtube.com/c/ChilledCow

but the same URL with a trailing slash will work just fine:

https://www.youtube.com/c/ChilledCow/

Using just "ChilledCow" also works. However, other channels do not work even with trailing slash or with only the end path.

const { YouTube } = require('popyt');
const youtube = new YouTube(YOUTUBE_KEY);

/*
Working:
'https://www.youtube.com/c/ChilledCow/'
'ChilledCow'

"Item not found":
'https://www.youtube.com/c/ChilledCow'
'https://www.youtube.com/c/fosterkittensofficial/'
'https://www.youtube.com/c/fosterkittensofficial'
'fosterkittensofficial'
*/

const query = 'https://www.youtube.com/c/ChilledCow/';

youtube
  .getChannel(query)
  .then(res => console.log(res.data.snippet))
  .catch(err => console.error(err));

When I load those failing URLs in the browser, they load fine and I can't discern any particular difference between the working and non-working URLs. Thank you for the library! 🙇🏼‍♂️

@ronvoluted ronvoluted added the bug Something isn't working label Jan 4, 2021
@brandonbothell
Copy link
Owner

The problem with the trailing slash was with my code. I have since fixed that, but I cannot push it until I finish my current YouTube API compliance review.

The problem with certain channels not working at all is due to a limitation with the YouTube API. There is no way to get a channel from its custom URL, so popyt sort of mimics this by grabbing the end of the URL and searching for it. In the case of "fosterkittensofficial", their actual username is "Cindy Congdon", so "fosterkittensofficial" returns no results (and if it did, they would most likely be garbage). I have also edited the documentation of the getChannel() function to clarify this.

Once my compliance review is complete, I will push these new changes and close this issue. Thanks!

@ronvoluted
Copy link
Author

No worries and no rush! Glad a cause could be found.

Yeah for urls where there's no id or username, I just grabbed the html as is then regexed the id:

/(?<="channelId":")[A-Za-z0-9]{24}/g
/(?<="externalId":")[A-Za-z0-9]{24}/g
/(?<="browseId":")[A-Za-z0-9]{24}/g

Wasn't sure if channelId was always present so the other two are just fallbacks.

@brandonbothell
Copy link
Owner

brandonbothell commented Feb 18, 2021 via email

@ronvoluted
Copy link
Author

Oh 100% agreed, just an account of how one person ended up resolving it.

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

2 participants