Time before preview update

How many time i need to wait after stream was started for preview update?
5 mins, or maybe more?
Just when i try to get rpeview it’s always same, an old preview…

See Kraken/streams delay / cache?

It usually takes no longer than 3 minutes to get an updated preview.

See also


Thx for the answer

What is it :stuck_out_tongue:

Tryed 3 and 5, preview is same
some part of code:

// here is function how i get preview

function sendDiscord (element) {
    snekfetch.get('https://api.twitch.tv/kraken/streams/' + element).set({
        'Client-ID': settings.twitch.clientID
      }).then(res => {
        let embed = new Discord.RichEmbed()
        //some part of code hidden
        //some part of code hidden
      client.channels.get(settings.discord.announceChannel).send(`@everyone ${res.body.stream.channel.url}`, {embed})

// here i'm heck every minute if stream online, if online i did other things. here i make 5 minutes timeout for check preview after 5 minutes since stream was catched as live

for (let i = 0; i < settings.twitch.channels.length; i++) {
      let element = settings.twitch.channels[i]
      snekfetch.get('https://api.twitch.tv/kraken/streams/' + element).set({
        'Client-ID': settings.twitch.clientID
      }).then(res => {
        if (res.body.stream) {
          if (cache[element]) return
          cache[element] = true
          // run our cd
          setTimeout(function() { 
         }, 300000);
        } else cache[element] = false
      }).catch(e => console.log(e))

I’ve added notes for my code


Whats the problem?

Is it the URL to the preview never changes (as it never will)

Or that the image in the preview is the same?

Either way the preview image URL returned by https://api.twitch.tv/kraken/streams/<userID> doesn’t change. It’s image content does

So for the streamer bikeman, /streams/ will always return:

"preview": {
    "small": "https://static-cdn.jtvnw.net/previews-ttv/live_user_bikeman-80x45.jpg",
    "medium": "https://static-cdn.jtvnw.net/previews-ttv/live_user_bikeman-320x180.jpg",
    "large": "https://static-cdn.jtvnw.net/previews-ttv/live_user_bikeman-640x360.jpg",
    "template": "https://static-cdn.jtvnw.net/previews-ttv/live_user_bikeman-{width}x{height}.jpg"

The large image URL is always https://static-cdn.jtvnw.net/previews-ttv/live_user_bikeman-640x360.jpg but the image content of that image changes periodically on Twitch’s servers

Further more, you are taking this image and sending it to a Discord chat. You are posting the same image URL over and over and over again, so Discord clients are not bothering to fetch a new preview of the image it’s caching it.

Either way, if you are trying to use the preview image in a going live notification, don’t, the preview image is useless for that use case

1 Like

I know other bots who doing same, but their images not cached as you said|
Yea mine image always same, and iguess it twitch side
and i know that url never change, i’m about image content

I fixed that by adding unix timestamp to my image preview URL
it like
thx for the answer @BarryCarlyon
It was rly discord cache!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.