Seahorse Helicopter
Seahorse Helicopter

Reputation: 31

Get a List of Twitch VOD IDs by Streamer

I'm wondering if there is a Twitch app/website out there that will give me a list of all the vod IDs for past broadcasts that exist for a specified Twitch channel. I use ReChat to download chat logs so I can search for moments I want to revisit from past streams when I don't remember on which stream they occurred, but I'm finding it tedious to copy and paste each VOD ID one by one.

I'm not a dev myself but I know there is something in the JSON API that makes this possible - just don't know how to use it so I'm wondering if someone else has set this up anywhere on the Internet. Thanks for everyone's help!

Upvotes: 3

Views: 10013

Answers (3)

Aaron
Aaron

Reputation: 51

I know you can get 100 from GQL.

You could make a POST request to: https://gql.twitch.tv/gql With

PostData = [{"operationName":"FilterableVideoTower_Videos","variables":{"limit":100,"channelOwnerLogin":"usernametogetvideos","broadcastType":null,"videoSort":"TIME","cursor":"MTQ1"},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"2023a089fca2860c46dcdeb37b2ab2b60899b52cca1bfa4e720b260216ec2dc6"}}}]

You also require a Client-Id header. Obtainable by going to Twitch on a browser and simply copying your own inside the network developer tool.

It will respond with the entire VOD information for 100 videos.

Upvotes: 2

Jan
Jan

Reputation: 111

So this took me way too long to figure out, I still don't know how to do proper url redirect authentication for users using your application, but if you just want a local, or server to server python script then here is how to do it with the "new twitch api". Hope it helps someone out there.

import requests
import json

## Its the name you see when you browse to the twitch url of the streamer
USER_ID = "<USER_ID_NAME_YOU_WANT_THE_VIDEOS_FROM>"

## First setup your application on your dashboard.
## here: https://dev.twitch.tv/console
## then click "Register Your Application" on the right hand side.
## For the oauth redirect just write: http://localhost
## Make note of your Client ID
## Make note of your Client Secret 
CLIENT_ID = "<YOUR_CLIENT_ID>" 
SECRET = "<YOUR_CLIENT_SECRET_CODE>"

## First get a local access token. 
secretKeyURL = "https://id.twitch.tv/oauth2/token?client_id={}&client_secret={}&grant_type=client_credentials".format(CLIENT_ID, SECRET)
responseA = requests.post(secretKeyURL)
accessTokenData = responseA.json()

## Then figure out the user id. 
userIDURL = "https://api.twitch.tv/helix/users?login=%s"%USER_ID
responseB = requests.get(userIDURL, headers={"Client-ID":CLIENT_ID,
                                                'Authorization': "Bearer "+accessTokenData["access_token"]})
userID = responseB.json()["data"][0]["id"]


## Now you can request the video clip data.
findVideoURL = "https://api.twitch.tv/helix/videos?user_id=%s"%userID
responseC= requests.get(findVideoURL, headers={"Client-ID":CLIENT_ID,
                                                'Authorization': "Bearer "+accessTokenData["access_token"]})
print ( json.dumps( responseC.json(), indent = 4)  )

Upvotes: 3

FloPinguin
FloPinguin

Reputation: 379

This python script will output the past broadcasts vod ids of a specific user (Using the new Twitch API v5).

import requests
import json

r = requests.get("https://api.twitch.tv/helix/videos?user_id=USERID&type=archive", headers={"Client-ID":"CLIENTID"})
j = json.loads(r.text)

for vod in j['data']:
    print(vod['id'])

You need to replace USERID with an actual user id. To obtain the user id of a streamer, an api call to a specific vod will help: https://api.twitch.tv/helix/videos?id=VODID. The response will include a user_id.

CLIENTID also needs to be replaced. You can obtain it by registering your application at Twitch Developers.

Upvotes: 2

Related Questions