tsifrer / python-twitch-client

Python wrapper for Twitch API

Home Page:http://python-twitch-client.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about get_clips

wolfgangam31 opened this issue · comments

Hello,

I'm pretty sure I'm doing something wrong, but I didn't find examples, so maybe it really doesn't work.
this is the request I'm doing for get_clips:

clip_settings = {
"broadcaster_id": None,
"game_id": 509658,
"clip_ids": None,
"after": None,
"before": None,
"started_at": (datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=7)).isoformat(),
"ended_at": None,
"page_size": 100
}

clips = client.get_clips(**clip_settings)

and I'm trying to write all the clips to CSV file, but it doesn't stop , it seems that when it gets to the end, it just writes the last page over and over again (so I added if i==4000)

with open('clips.csv', 'w', encoding='utf-8') as f:
writer = csv.writer(f)
for i, clip in enumerate(clips):
if i == 0:
writer.writerow([x for x in clip])
writer.writerow([clip[x] for x in clip])
if i == 4000:
break

how to I go over the results of each page and ask to continue only if there is another page?

thanks

Hey!

I'm assuming you're using TwitchHelix here.
I've found a bug that's causing this and the fix is in the latest master, so to get the fix you'll need to use the code from master branch.
Commit that fixes this issue: bd2d791