import requests
import time
import webbrowser
import datetime
channel_id = input("치지직 채널 ID를 입력하세요: ") # 치지직 채널 아이디
refresh = 60 # 재탐색 쿨타임
while True:
try:
headers = {'User-Agent': 'Mozilla/5.0'} # 솔직히 잘 모르는데 없으면 봇 판정인지 오류생김
request = requests.get(f"https://[Log in to view URL]", headers=headers) # 솔직히 잘 모르는데 없으면 봇 판정인지 오류생김 2
response.raise_for_status() # HTTP 에러가 발생했는지 확인
channel_info = request.json().get("content") # 윗줄에서 API 정보 가져와서 json형식으로 변환
open_live = channel_info.get("openLive") # 방송 켰는지 확인하는 내용
channel_name = channel_info.get("channelName") # 채널 이름 정보 가져오기
if open_live == True:
webbrowser.open(f"https://[Log in to view URL]", new=0) # 방송 켰으니 인터넷으로 방송 켜줌
break # 방송 켜줬으니 프로그램 종료
date = datetime.datetime.today().strftime('%H:%M:%S') # 날짜랑 시간 정보
print('[' + date + '] ' + channel_name + ' 방송 대기중, {refresh}초 후 다시 확인합니다...') # 안내문구 작성
time.sleep(refresh) # 설정 시간마다 반복
except requests.exceptions.Timeout:
print("요청이 시간 초과되었습니다. 인터넷 연결을 확인하세요.")
except requests.exceptions.ConnectionError:
print("연결 오류가 발생했습니다. 인터넷 연결을 확인하세요.")
except requests.exceptions.HTTPError as err:
print(f"HTTP 오류 발생: {err}")
except requests.exceptions.RequestException as err:
print(f"알 수 없는 오류 발생: {err}")
except KeyError as err:
print(f"필수 데이터가 누락되었습니다: {err}")
To embed this project on your website, copy the following code and paste it into your website's HTML: