Skip to content

Commit

Permalink
Refactor 'last_danmaku_time' initialization order in ws-server.py
Browse files Browse the repository at this point in the history
The initialization of 'last_danmaku_time' is moved down right after the live stream starts instead of being at the start of '_main' function. This will ensure that the value of 'last_danmaku_time' reflects more accurately the start of the live stream, helping with more precise time tracking.

Signed-off-by: hldh214 <hldh214@gmail.com>
  • Loading branch information
hldh214 committed Jul 5, 2024
1 parent 8b146bc commit c5e6b61
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions recorder/danmaku/douyin/ws-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ async def consumer_handler(websocket):


async def _main(room_id, interval):
global last_danmaku_time
last_danmaku_time[room_id] = datetime.datetime.now()
logging.info(f'Started danmaku subscriber: {room_id}')

while True:
Expand All @@ -193,6 +191,8 @@ async def _main(room_id, interval):
continue

logging.info(f'Live started: {room_id}')
global last_danmaku_time
last_danmaku_time[room_id] = datetime.datetime.now()
hook_result = asyncio.Future()
task = asyncio.create_task(get_raw_js(hook_result))
try:
Expand Down

0 comments on commit c5e6b61

Please sign in to comment.