python-twitch-client icon indicating copy to clipboard operation
python-twitch-client copied to clipboard

Question about get_clips

Open wolfgangam31 opened this issue 4 years ago • 1 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

wolfgangam31 avatar Feb 27 '21 22:02 wolfgangam31

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: https://github.com/tsifrer/python-twitch-client/commit/bd2d79135f62bf45acd244079e0873f4987a6352

tsifrer avatar Mar 16 '21 09:03 tsifrer