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

Prevent YouTube API 403 errors from showing in tooltips #268

Open
jupjohn opened this issue Feb 15, 2022 · 0 comments
Open

Prevent YouTube API 403 errors from showing in tooltips #268

jupjohn opened this issue Feb 15, 2022 · 0 comments

Comments

@jupjohn
Copy link
Contributor

jupjohn commented Feb 15, 2022

As Chatterino grows, the calls to the YouTube API increase which causes call quotas to be hit more frequently. When a quota is exceeded, the Chatterino API returns a tooltip containing the YouTube HTML error response instead of the preview. Ideally c2api would return a nicer error message (such as "chatterino was unable to get information about this video"), or use an alternative source of data.

Since YouTube supports oEmbed, the thumbnail URL, video title, and channel name can be resolved without an API call. This is enough to present back to the user. An example workflow is below:

get YT preview request:
    call the YT API
    if YT call is success:
        return tooltip using YT data
    
    fetch oEmbed data
    return a slimmed down tooltip with just the thumbnail, title, & channel name

Example YT oEmbed response:

{
  "title": "Rick Astley - Never Gonna Give You Up (Official Music Video)",
  "author_name": "Rick Astley",
  "author_url": "https://www.youtube.com/c/RickastleyCoUkOfficial",
  "type": "video",
  "height": 113,
  "width": 200,
  "version": "1.0",
  "provider_name": "YouTube",
  "provider_url": "https://www.youtube.com/",
  "thumbnail_height": 360,
  "thumbnail_width": 480,
  "thumbnail_url": "https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg",
  "html": ...omitted for brevity...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant