PetterKraabol / Twitch-Python

Object-oriented Twitch API for Python developers
https://pypi.org/project/twitch-python
MIT License
214 stars 37 forks source link

Error when iterating through videos of a channel #7

Closed underchemist closed 5 years ago

underchemist commented 5 years ago

When attempting to iterate through videos as in #3 I'm getting a TypeErrror.

import twitch

helix = twitch.Helix('<client-id>')

for video in helix.user('moonmoon_ow').videos():
    print(video.id)

which yields

 File "c:\Users\yanns\git\Twitch-Python\debug-twitch.py", line 5, in <module>
    for video in helix.user('moonmoon_ow').videos():
  File "c:\Users\yanns\git\Twitch-Python\twitch\helix\resources\resource.py", line 53, in __iter__
    remaining = 0 if remaining is not None and len(elements) > remaining else remaining - self._kwargs['first']
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

it seems like there might be some invalid boolean logic? From my debugging the variable remaining is indeed None so the if statement immediately fails and the else statement is evaluated. since remaining is None however we get a TypeError trying to subtract an int from a NoneType.

Am I using the videos() method as intended?

PetterKraabol commented 5 years ago

Thanks! Fixed in 0.0.16

underchemist commented 5 years ago

nice, very quick was about to submit a PR but you have tests :P