justintv / Twitch-API

A home for details about our API
www.twitch.tv
1.72k stars 381 forks source link

[Property Request]: Image asset availability boolean #291

Open levi opened 9 years ago

levi commented 9 years ago

Sometimes a game doesn't have box art, a stream doesn't have a preview or a channel doesn't have an avatar. Twitch falls back by redirecting the image URL to a 404 image. In the game box art example: http://static-cdn.jtvnw.net/ttv-static/404_boxart-180x250.jpg. I would like to request the addition of a property to game, stream, and channel objects that identifies if an asset url points to an actual image. For example:

  "game": {
    "name": "League of Legends",
    "box": {
      "large": "http://static-cdn.jtvnw.net/ttv-boxart/League%20of%20Legends.jpg?w=272&h=380&fit=scale",
      "medium": "http://static-cdn.jtvnw.net/ttv-boxart/League%20of%20Legends.jpg?w=136&h=190&fit=scale",
      "small": "http://static-cdn.jtvnw.net/ttv-boxart/League%20of%20Legends.jpg?w=52&h=72&fit=scale",
      "template": "http://static-cdn.jtvnw.net/ttv-boxart/League%20of%20Legends.jpg?w={width}&h={height}&fit=scale",
      "available": true,
    },
    "logo": {
      "large": "http://static-cdn.jtvnw.net/ttv-logoart/League%20of%20Legends.jpg?w=240&h=144&fit=scale",
      "medium": "http://static-cdn.jtvnw.net/ttv-logoart/League%20of%20Legends.jpg?w=120&h=72&fit=scale",
      "small": "http://static-cdn.jtvnw.net/ttv-logoart/League%20of%20Legends.jpg?w=60&h=36&fit=scale",
      "template": "http://static-cdn.jtvnw.net/ttv-logoart/League%20of%20Legends.jpg?w={width}&h={height}&fit=scale",
      "available": false,
    },
    "_links": {},
    "_id": 21779,
    "giantbomb_id": 24024
  }

Here I have included the available flag, which is a part of what I've been calling the asset object (any hash with large, medium, small, template attributes). It would educate clients on the availability of an image, thus removing the need to do an unnecessary request identifying if there's a redirect. The naming I'm not too concerned about, since I just made it up while writing this, but the function would be highly useful for my api consumers and I'm sure many others'.

chrishanel commented 8 years ago

This is pretty old, but I'm bumping this because we need the functionality to be able to perform our own actions should the API be serving us the 404 boxart.