import requests
import time
import webbrowser
import datetime

while True:
    channel_id = input("치지직 채널 ID를 입력하세요: ")  # 치지직 채널 아이디
    refresh = 60  # 재탐색 쿨타임

    try:
        headers = {'User-Agent': 'Mozilla/5.0'}  # 봇 판정 방지
        response = requests.get(f"https://[Log in to view URL]", headers=headers)
        response.raise_for_status()  # HTTP 에러가 발생했는지 확인
        channel_info = response.json().get("content")

        # 응답 데이터에서 channelId가 None인지 확인하여 잘못된 채널 ID 확인
        if channel_info.get("channelId") is None:
            print("존재하지 않는 채널 ID입니다. 다시 입력해 주세요.")
            continue  # 잘못된 채널 ID일 경우 다시 입력받음

        open_live = channel_info.get("openLive")
        channel_name = channel_info.get("channelName", "알 수 없음")  # 채널 이름이 없으면 기본값

        if open_live: 
            print(f"{channel_name} 방송이 켜졌습니다! 10초 후에 접속합니다...")
            
            # 10초 카운트다운 출력
            for i in range(10, 0, -1):
                print(f"{i}초 후에 접속합니다...", end="\r")
                time.sleep(1)

            webbrowser.open(f"https://[Log in to view URL]", new=0)  # 방송 열기
            break  # 방송 시작되었으니 종료

        date = datetime.datetime.now().strftime('%H:%M:%S')  # 시간 정보
        print(f'[{date}] {channel_name} 방송 대기 중, {refresh}초 후 다시 확인합니다...')  # 안내문구

        time.sleep(refresh)  # 설정한 시간만큼 대기
    except requests.exceptions.HTTPError as err:
        print(f"HTTP 오류 발생: {err}")
    except requests.exceptions.Timeout:
        print("요청이 시간 초과되었습니다. 인터넷 연결을 확인하세요.")
    except requests.exceptions.ConnectionError:
        print("연결 오류가 발생했습니다. 인터넷 연결을 확인하세요.")
    except requests.exceptions.RequestException as err:
        print(f"알 수 없는 오류 발생: {err}")

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: