diff --git a/twitch/helix/api.py b/twitch/helix/api.py index 37e436b..0bb5f2a 100644 --- a/twitch/helix/api.py +++ b/twitch/helix/api.py @@ -21,6 +21,7 @@ Tag, User, Video, + Channel ) @@ -374,3 +375,23 @@ def get_tags(self, after=None, page_size=20, tag_ids=None): resource=Tag, params=params, ) + + def search_channels(self, query, after=None, page_size=20, live_only=False): + """https://dev.twitch.tv/docs/api/reference#search-channels""" + if page_size > 100: + raise TwitchAttributeException('Maximum number of objects to return is 100') + + params = { + 'query': query, + 'after': after, + 'first': page_size, + 'live_only': live_only + } + + return APICursor( + client_id=self._client_id, + oauth_token=self._oauth_token, + path='search/channels', + resource=Channel, + params=params, + ) \ No newline at end of file diff --git a/twitch/resources.py b/twitch/resources.py index 456aa0a..c9d4fbb 100644 --- a/twitch/resources.py +++ b/twitch/resources.py @@ -68,7 +68,7 @@ def refresh_from(self, values): class _DateTime(object): @classmethod def construct_from(cls, value): - if value is None: + if value is None or value == '': return None try: dt = datetime.strptime(value, "%Y-%m-%dT%H:%M:%SZ")