1

I was able to download Twitch clips and entire VODs using this library as an embed code in my program written in Python.

The download_clip function takes input from the link, which extracts the slug from the clip, rearranging the link used for the download itself.

I was reading the tool repository and I can't find any information if there is any way to query the game information on such clips.

Specifically, I need to know what game was being played during the livestream so I can validate my analysis later.

I am able to download clips using the following code:

def download_clip(link: str):
    clip_id = get_clip_slug(link)
    url = f'https://clips.twitch.tv/{clip_id}'

    ydl_opts = {'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'}
    try:
        with YoutubeDL(ydl_opts) as ydl:
            ydl.download([url])
    except:
        print('Not working..')

I also took a look at the youtube-dl and its exactly the same thing.. I can't find any info about it. Any workaround or tips?

  • What is the exception/error? – Marc Apr 07 '23 at 18:56
  • Hey @marc there's no exception msg for downloading clips or vods. Like I said in the post, I need to check the game which was played during the livestreams since the Twitch platform allows the content creators to specify this in order to attract viewers related to their content and I can't find how to request such info through the yt-dlp embeded code. – Dan Alvares Apr 08 '23 at 21:58
  • Poorly phrased on my part. Something must be returned or happen. I have little insight on your problem, but here is where I might start to debug, all straight forward stuff. https://replit.com/@datamafia/paranioa#main.py. There could be messages (errors or ?) heading out somewhere to "null", any number of means to suppress errors and messages - less likely IMO. – Marc Apr 10 '23 at 17:14

1 Answers1

0

Unfortunately only videos with chapters provide the info I was looking for (while utilizing yt_dlp) and since I'm working with Twitch clips I decided to give a try to the official Twitch API.

I was able to request the infos desired with the following code:

def check_game_id(link):
    slug = obter_id_clip(link)
    headers = {'Authorization': f'Bearer {access_token}', 'Client-Id': client_id}
    params = {'id': slug}
    
    response = requests.get('https://api.twitch.tv/helix/clips', params=params, headers=headers)
    informacoes = response.json()
    game_id = informacoes['data'][0]['game_id']
    
    return game_id
dan1st
  • 12,568
  • 8
  • 34
  • 67