How to get game info when downloading Twitch clips with yt-dlp?

I’ve been using yt-dlp to grab Twitch clips and full VODs in my Python program. It works great for downloading, but I’m stuck on one thing. I need to find out what game was being played in each clip. This is important for my analysis later on.

Here’s a snippet of my code for downloading clips:

def get_clip(url):
    clip_part = extract_clip_id(url)
    full_url = f'https://clips.twitch.tv/{clip_part}'

    options = {'format': 'best[ext=mp4]'}
    try:
        with YoutubeDL(options) as downloader:
            downloader.download([full_url])
    except Exception:
        print('Download failed')

I’ve looked through the yt-dlp docs and even checked youtube-dl, but I can’t find anything about getting game info. Does anyone know if there’s a way to do this with yt-dlp? Or maybe there’s another method I could try? Any help would be awesome!

Unfortunately, yt-dlp does not support retrieving game metadata directly from Twitch clips. You can, however, integrate the Twitch API to obtain the necessary information. Start by extracting the clip ID from the URL, then use the Twitch API’s Get Clips endpoint to fetch the clip details, including the game ID. This requires setting up API credentials and handling authentication as well as respecting rate limits. Integrating these two tools will add a bit of complexity to your workflow but should provide you with the game data needed for your analysis.