11from datetime import timedelta
2- from typing import List , Union
2+ from typing import List , Union , Optional
33
44import twitch .helix as helix
55from twitch .api import API
@@ -9,11 +9,21 @@ class Helix:
99 BASE_URL : str = 'https://api.twitch.tv/helix/'
1010
1111 def __init__ (self , client_id : str , client_secret : str = None , use_cache : bool = False ,
12- cache_duration : timedelta = timedelta (minutes = 30 ), rate_limit : int = 30 ):
12+ cache_duration : Optional [timedelta ] = None , rate_limit : int = 30 ):
13+ """
14+ Helix API (New Twitch API)
15+ https://dev.twitch.tv/docs/api/
16+
17+ :param client_id: Twitch client ID
18+ :param client_secret: Twitch client secret
19+ :param use_cache: Cache API requests (recommended)
20+ :param cache_duration: Cache duration
21+ :param rate_limit: API rate limit
22+ """
1323 self .client_id : str = client_id
1424 self .client_secret : str = client_secret
1525 self .use_cache : bool = use_cache
16- self .cache_duration : timedelta = cache_duration
26+ self .cache_duration : Optional [ timedelta ] = cache_duration
1727 self .rate_limit : int = rate_limit
1828
1929 def api (self ) -> API :
@@ -25,9 +35,9 @@ def users(self, *args) -> 'helix.Users':
2535 def user (self , user : Union [str , int ]) -> 'helix.User' :
2636 return self .users (user )[0 ]
2737
28- def videos (self , video_ids : Union [str , int , List [Union [str , int ]]], ** kwargs ) -> 'helix.Videos' :
29- if type (video_ids ) != list :
30- video_ids = [video_ids ]
38+ def videos (self , video_ids : Union [str , int , List [Union [str , int ]]] = None , ** kwargs ) -> 'helix.Videos' :
39+ if video_ids and type (video_ids ) != list :
40+ video_ids = [int ( video_ids ) ]
3141 return helix .Videos (self .api (), video_ids = video_ids , ** kwargs )
3242
3343 def video (self , video_id : Union [str , int ] = None , ** kwargs ) -> 'helix.Video' :
0 commit comments