pip install TwitchDev 명령어를 이용하여 TwitchDev 를 설치할 수 있습니다.트위치 공식 API 와 그외 비공식 API 등 다양한 요청을 쉽게 보내기 위해 제작되었습니다.
아직 초기 개발버전이라 앱토큰을 이용하는 API 까지만 구현했습니다.
업데이트를 원한다면
pip install TwitchDev --upgrade 명령어를 입력해주세요.트위치 인증과 관련된 클래스 입니다.
트위치 콘솔 (https://dev.twitch.tv/console) 에서 클라이언트 아이디와 시크릿을 발급받을 수 있습니다.
.OAuthClientCredentialsFlow(self, client_id, client_secret, scope=None): 앱토큰을 요청합니다..RefreshingAccessTokens(self, client_id, client_secret, refresh_token, scope=None): 토큰을 리프레쉬 합니다..RevokingAccessTokens(self, client_id, token): 토큰을 제거합니다..ValidatingRequests(self, token): 토큰을 검증합니다..UserInfo(self, token): 토큰의 유저 정보를 확인합니다..delete_token(self, token): 토큰을 제거합니다. (토큰을 검증하여 얻은 클라이언트id로 토큰을 제거합니다.).reset_token(self, client_id, client_secret): 토큰을 완전 초기화 합니다. (50개 생성 후 삭제)
트위치API 레퍼런스 (https://dev.twitch.tv/docs/api/reference) 를 기반으로 만들어졌습니다.
따라서 해당 사이트에서 세부사항 (인증, 파라미터, 응답 정보 등) 을 확인할 수 있습니다.
(토큰) 또는 (클라이언트 아이디 + 클라이언트 시크릿) 조합 만으로도 사용할 수 있습니다.
우선 클래스를 생성할때 토큰을 이용하여 헤더를 생성을 시도합니다.
정상적인 토큰이 아니라면 클라이언트 아이디와 클라이언트 시크릿을 이용하여 헤더를 생성합니다.
헤더를 생성하지 못했다면 오류를 반환합니다.
.GetCheermotes(self, broadcaster_id): 비트 이모티콘을 조회합니다..GetChannelInformation(self, broadcaster_id): 채널 정보를 조회합니다..GetChannelEmotes(self, broadcaster_id): 채널 이모티콘을 조회합니다..GetGlobalEmotes(self): 글로벌 이모티콘을 조회합니다..GetEmoteSets(self, emote_set_id): 이모티콘 세트를 조회합니다..GetChannelChatBadges(self, broadcaster_id): 채널 뱃지를 조회합니다..GetGlobalChatBadges(self): 글로벌 뱃지를 조회합니다..GetChatSettings(self, broadcaster_id, moderator_id=None): 채팅 설정을 조회합니다..GetClips(self, broadcaster_id=None, game_id=None, id=None, started_at=None, ended_at=None, first=None, after=None, before=None): 클립을 조회합니다..GetTopGames(self, first=None, after=None, before=None): 상위 카테고리를 조회합니다..GetGames(self, id=None, name=None): 키테고리를 조회합니다..GetChannelStreamSchedule(self, broadcaster_id): 채널 스케줄을 조회합니다..GetChanneliCalendar(self, broadcaster_id): 채널 i캘린더를 조회합니다..SearchCategories(self, query, first=None, after=None): 카테고리를 검색합니다..SearchChannels(self, query, live_only=None, first=None, after=None): 채널을 검색합니다..GetStreams(self, user_id=None, user_login=None, game_id=None, language=None, first=None, after=None, before=None): 스트림 정보를 가져옵니다..GetUsers(self, id=None, login=None): 유저 정보를 가져옵니다..GetUsersFollows(self, from_id=None, to_id=None, first=None, after=None): 유저 팔로우 팔로잉 정보를 조회합니다..GetVideos(self, id=None, user_id=None, game_id=None, language=None, period=None, sort=None, type=None, first=None, after=None, before=None): 비디오 정보를 조회합니다..uid(self, *login): 유저 login 리스트를 유저 id 리스트로 변환해줍니다. (최대100개) 파라미터로 login이 아닌 id 를 사용하는 경우 유용합니다.
.PlaybackAccessToken(self, login="", vodID=""): PlaybackAccessToken 을 발급합니다..StreamPlayback(self, login): PlaybackAccessToken 을 발급하여 생방송 m3u8을 가져옵니다. (->text).VideoPlayback(self ,vodID): PlaybackAccessToken 을 발급하여 다시보기 m3u8을 가져옵니다. (->text).HomeTrackQuery(self,login): HomeTrackQuery 정보를 가져옵니다. (GQL).Comments(self, vodID, content_offset_seconds=None, cursor=None): 다시보기에서 채팅을 가져옵니다..regex_m3u8(self, Playback): Playback 으로 m3u8 목록을 추출합니다.
.User(self, channel): 채널에 참여하고있는 유저 목록을 가져옵니다..Chatters(self, channel): 채널에 참여하고 있는 유저수를 가져옵니다..Servers(self): 트위치 IRC 서버 목록을 가져옵니다.
.BitEmoteLookup(self, channel): 비트 이모티콘을 가져옵니다..ChatDelayCheck(self, username, raw=None): 채팅 딜레이를 확인합니다..EmoteLookup(self, emote, id=None): 이모티콘을 조회합니다..EmoteSetLookup(self, setid): 이모티콘 세트를 조회합니다..BulkEmotesetLookup(self, set_id): 이모티콘 세트를 조회합니다..LowLatencyCheck(self, username, raw=None): 낮은 딜레이 설정을 조회합니다..ModVIPLookup(self, channel): 매니저와 VIP를 조회합니다..GetUserData(self, username, id=None, skipCache=None): 유저 데이터를 조회합니다..StreamScheduleLookup(self, channel): 스트림 스케줄을 조회합니다..SubageLookup(self, username, channel): 구독 상태를 확인합니다.
.vod_544146_workers_dev(self, vodID): vod의 m3u8 목록을 가져옵니다. (->list) (https://vod.544146.workers.dev/{vodID})
- ver0.0.5 : AUTH.reset_token 추가