This repository was archived by the owner on Jan 28, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Copyright (c) 2025 bilitool
2+
3+ import requests
4+
5+ class BiliLiveList :
6+ def __init__ (self , headers ):
7+ self .headers = headers
8+
9+ def get_live_info (self , room ) -> dict :
10+ """Get the live info of the room"""
11+
12+ url = "https://api.live.bilibili.com/room/v1/Room/get_info?room_id={room}" .format (
13+ room = room
14+ )
15+ response = requests .get (url = url , headers = self .headers )
16+ if response .status_code != 200 :
17+ raise Exception ('HTTP ERROR' )
18+ response_json = response .json ().get ("data" )
19+ if response .json ().get ("code" ) != 0 :
20+ raise Exception (response .json ().get ("message" ))
21+ return response_json
22+
Original file line number Diff line number Diff line change 22
33import unittest
44from bilitool .feed .bili_video_list import BiliVideoList
5+ from bilitool .feed .bili_live_list import BiliLiveList
56
67class TestBiliList (unittest .TestCase ):
8+ def setUp (self ):
9+ self .headers = {
10+ "User-Agent" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/63.0.3239.108"
11+ }
12+
713 def test_get_bili_video_list (self ):
814 bili = BiliVideoList ()
915 bili .print_video_list_info (bili .get_bili_video_list (50 , 'not_pubed' ))
1016
1117 def test_print_video_info_via_bvid (self ):
1218 bili = BiliVideoList ()
13- bili .print_video_info_via_bvid ('BV1pCr6YcEgD' )
19+ bili .print_video_info_via_bvid ('BV1pCr6YcEgD' )
20+
21+ def test_get_live_info (self ):
22+ bili = BiliLiveList (self .headers )
23+ print (bili .get_live_info (25538755 ))
You can’t perform that action at this time.
0 commit comments