Hello all,
I have a streamer that sets markers and wants me to make clips from their VODs.
I am looking to automate this using ffmpeg and the videos that I download. Ok, cool, so I have all of the ffmpeg stuff scripted out in order to use the timestamp to get the right part of the video and do the trimming for me. Now i want to get the markers programatically. I am looking to run this script maybe once per day, or maybe a couple times in a row every other day.
However, it’s getting the access that I’m confused about. However, the API authentication workflow is confusing to me.
Do I already have the correct permissions?
From what I can tell, since I’m a mod and editor on the streamer’s page, I should have the correct permisssions. From the docs:
Requires a user access token that includes the user:read:broadcast scope.
Authentication
For authentication I got a client ID and secret from Twitch Developers.
I created a brand new app for this and got the client id and secret that I redacted in the code below.
Code
I found the pyTwitchAPI library, and went to use it:
#!/usr/bin/env python3
from twitchAPI.twitch import Twitch
from twitchAPI.oauth import UserAuthenticator
from twitchAPI.types import AuthScope
import pprint
import asyncio
async def main():
twitch = await Twitch('REDACTED_CLIENT_ID', 'REDACTED_CLIENT_SECRET')
target_scope = [AuthScope.BITS_READ]
auth = UserAuthenticator(twitch, target_scope, force_verify=False)
# this will open your default browser and prompt you with the twitch verification website
token, refresh_token = await auth.authenticate()
# add User authentication
await twitch.set_user_authentication(token, target_scope, refresh_token)
stream_markers = twitch.get_stream_markers(user_id='', video_id='REDACTED_VIDEO_ID')
pprint.pprint(await anext(stream_markers))
asyncio.run(main())
But it’s giving me the following error:
twitchAPI.types.MissingScopeException: Require user auth scope USER_READ_BROADCAST
This looks like a permission issue to me, but I can’t figure out why. Any thoughts?