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

YouTube video view count: "invalid response data" #7373

Closed
ghost opened this issue Dec 14, 2021 · 1 comment · Fixed by #7410
Closed

YouTube video view count: "invalid response data" #7373

ghost opened this issue Dec 14, 2021 · 1 comment · Fixed by #7410
Labels
bug Bugs in badges and the frontend good first issue New contributors, join in! service-badge New or updated service badge

Comments

@ghost ghost added the question Support questions, usage questions, unconfirmed bugs, discussions, ideas label Dec 14, 2021
@calebcartwright
Copy link
Member

Thank you for the report! Looks like Youtube have changed their API response structure, as it now includes objects under the items field which do not have the dislike count nor subscriber count failing schema validation:

https://www.googleapis.com/youtube/v3/videos?part=statistics&id=abBdk8bSPKU

{
  "kind": "youtube#videoListResponse",
  "etag": "oolaHBsncBupkZFd7QlP8ZRIPKI",
  "items": [
    {
      "kind": "youtube#video",
      "etag": "pl3CDI4TqeRo5CsjDhJrUX5NAhE",
      "id": "abBdk8bSPKU",
      "statistics": {
        "viewCount": "400",
        "likeCount": "7",
        "favoriteCount": "0",
        "commentCount": "0"
      }
    }
  ],
  "pageInfo": {
    "totalResults": 1,
    "resultsPerPage": 1
  }
}

const schema = Joi.object({
pageInfo: Joi.object({
totalResults: nonNegativeInteger,
resultsPerPage: nonNegativeInteger,
}).required(),
items: Joi.array().items(
Joi.object({
statistics: Joi.alternatives(
Joi.object({
viewCount: nonNegativeInteger,
likeCount: nonNegativeInteger,
dislikeCount: nonNegativeInteger,
commentCount: nonNegativeInteger,
}),
Joi.object({
viewCount: nonNegativeInteger,
subscriberCount: nonNegativeInteger,
})
),
})
),
}).required()

I'm going to guess that Youtube has either dropped the dislike counts outright, or has switched to eliding the field if the value is zero, and we'll need to account for that, both in the schema linked above and then some handling of that scenario in the likes badge

@calebcartwright calebcartwright added bug Bugs in badges and the frontend service-badge New or updated service badge and removed question Support questions, usage questions, unconfirmed bugs, discussions, ideas labels Dec 15, 2021
LangLangBart added a commit to LangLangBart/boonGUI that referenced this issue Dec 15, 2021
Youtube video view count is currently broken for the shield badge (see badges/shields#7373). I will remove it for now. Seeh deleted one of its linked videos, I replaced with a new one.
@calebcartwright calebcartwright added the good first issue New contributors, join in! label Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs in badges and the frontend good first issue New contributors, join in! service-badge New or updated service badge
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant