How to update description and thumbnail of the Twitch stream videos via Twitch API

I am trying to update stream info like below but it fails

tags and title set but description and thumbnail is not

the messages i got as below

2024-06-26 10:55:38,843 - INFO - Twitch token is valid
2024-06-26 10:55:38,843 - INFO - Attempting to stream video from: C:\inetpub\ftproot\stream\downloads\a2yGs8bEeQg.webm
2024-06-26 10:55:39,578 - INFO - Updated stream info - Title: SORA Video To Video Is Literally Mind Blowing - 12 HD Demos - Changes Industry Forever For Real, Category: Science & Technology, Tags: ['technology', 'learning', 'software', 'education', 'howto', 'tech', 'programming', 'development', 'science', 'lecture']
2024-06-26 10:55:39,703 - ERROR - Failed to update stream info: 400 Client Error: Bad Request for url: https://api.twitch.tv/helix/channels?broadcaster_id=906233081
2024-06-26 10:55:39,703 - ERROR - Response content: No response
2024-06-26 10:55:39,859 - INFO - Attempting to stream to: rtmp://mia05.contribute.live-video.net/app/REMOVEDBYMODERATOR
2024-06-26 10:55:39,859 - DEBUG -  < :8roe!8roe@8roe.tmi.twitch.tv JOIN #secourses
    async def update_stream_info(self, title, description, thumbnail_url):
        headers = {
            'Client-ID': self.client_id,
            'Authorization': f'Bearer {self.token_data["access_token"]}',
        }
        
        title = title[:140]  # Ensure title is not too long
        tags = get_tags(title, description)

        science_tech_id = "509670"

        data = {
            'broadcaster_id': self.user_id,
            'title': title,
            'game_id': science_tech_id,
            'broadcaster_language': 'en',
            'tags': tags
        }
        
        try:
            response = requests.patch(f'https://api.twitch.tv/helix/channels?broadcaster_id={self.user_id}', 
                                      headers=headers, 
                                      json=data)
            response.raise_for_status()
            logging.info(f"Updated stream info - Title: {title}, Category: Science & Technology, Tags: {tags}")

            if thumbnail_url:
                thumbnail_data = {
                    'thumbnail_url': thumbnail_url
                }
                thumbnail_response = requests.patch(f'https://api.twitch.tv/helix/channels?broadcaster_id={self.user_id}',
                                                    headers=headers,
                                                    json=thumbnail_data)
                thumbnail_response.raise_for_status()
                logging.info(f"Updated stream thumbnail: {thumbnail_url}")

        except requests.RequestException as e:
            logging.error(f"Failed to update stream info: {e}")
            logging.error(f"Response content: {e.response.content if e.response else 'No response'}")

then i try to update description and thumbnail after stream ended but still fails

i need help

async def update_post_stream_info(self, metadata):
    logging.info("Stream ended. Waiting for Twitch to update...")
    await asyncio.sleep(60)  # Wait for 1 minute

    headers = {
        'Client-ID': self.client_id,
        'Authorization': f'Bearer {self.token_data["access_token"]}',
    }

    # Update description
    description_data = {
        'broadcaster_id': self.user_id,
        'description': metadata['description'][:5000] 
    }
    try:
        description_response = requests.patch(f'https://api.twitch.tv/helix/channel_information', headers=headers, json=description_data)
        description_response.raise_for_status()
        logging.info("Updated post-stream description")
    except requests.RequestException as e:
        logging.error(f"Failed to update post-stream description: {e}")
        logging.error(f"Response content: {e.response.content if e.response else 'No response'}")

I could update my app with example python methods as well

You cannot control the thumbnail of a live stream.

Wheres the body of the response? HTTP Code is half the information.

2024-06-26 10:55:39,859 - INFO - Attempting to stream to:

You leaked your streamkey you should reset it, I edited your post to remove it but the horse has bolted

This is not supported

has no thumbnail field.

So it updated the title/category/tags

Then failed to update the thumbnail as you cannot update the thumbnail.

1 Like

how do i get body response? you see my full code

i am able to set thumbnails after stream manually from interface but i can’t do that with API?

I want to update description of the stream as well. title tags category works but description and thumbnail fails

Correct.

Streams have a thumbnail of a recentish screenshot of the stream
Vods can have a uplodated thumbnail but you cannot modify vod’s via the API

Streams don’t have descriptions

I don’t know python well enough to answer that

1 Like

so after stream ended can I update the video description via API

No, there is no API support to modify VOD’s

1 Like

ok so my final verification

I can’t set description or thumbnail of streams via API neither before starting stream, neither during stream or after stream ended right?

so these streams after ended they are called as VOD. do you have any plans to let API to modify VOD or I have to use browser interface and do manually?

Correct.

Streams do not have a settable thumbnail or does a stream have a description.

VOD’s have no API support for modification of the VOD

I cannot speak to what Twitch plans or doesn’t plan to do.

Uservoice is the home for feature requests: https://twitch.uservoice.com/forums/310213-developers

A browser manually has to be used to give a VOD a custom thumbnail and/or description.

1 Like

Thank you for all answers. 1 final question

during stream I see tags but after stream ended they are empty and can’t be set from browser as well

is this expected?

Tags refer to a stream not to vod content I guess. So they don’t carry over. As to if they should or not I don’t know. that is first party stuff and kinda outside the realm of the forum.

1 Like

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