mirror of
https://github.com/dmunozv04/iSponsorBlockTV.git
synced 2025-12-06 20:06:44 +03:00
Fix watchdog triggering too much
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import asyncio
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
from typing import Any, List
|
||||
|
||||
import pyytlounge
|
||||
@@ -50,12 +51,12 @@ class YtLoungeApi(pyytlounge.YtLoungeApi):
|
||||
it cancels the current subscription.
|
||||
"""
|
||||
self.watchdog_running = True
|
||||
self.last_event_time = asyncio.get_event_loop().time()
|
||||
self.last_event_time = time.time()
|
||||
|
||||
try:
|
||||
while self.watchdog_running:
|
||||
await asyncio.sleep(10)
|
||||
current_time = asyncio.get_event_loop().time()
|
||||
current_time = time.time()
|
||||
time_since_last_event = current_time - self.last_event_time
|
||||
|
||||
# YouTube sends a message at least every 30 seconds
|
||||
@@ -105,7 +106,7 @@ class YtLoungeApi(pyytlounge.YtLoungeApi):
|
||||
def _process_event(self, event_type: str, args: List[Any]):
|
||||
self.logger.debug(f"process_event({event_type}, {args})")
|
||||
# Update last event time for the watchdog
|
||||
self.last_event_time = asyncio.get_event_loop().time()
|
||||
self.last_event_time = time.time()
|
||||
|
||||
# A bunch of events useful to detect ads playing,
|
||||
# and the next video before it starts playing
|
||||
|
||||
Reference in New Issue
Block a user