mirror of
https://github.com/dmunozv04/iSponsorBlockTV.git
synced 2025-12-12 23:16:45 +03:00
Improve exceptions
This commit is contained in:
@@ -38,14 +38,14 @@ class DeviceListener:
|
|||||||
await asyncio.sleep(60 * 60 * 24) # Refresh every 24 hours
|
await asyncio.sleep(60 * 60 * 24) # Refresh every 24 hours
|
||||||
try:
|
try:
|
||||||
await self.lounge_controller.refresh_auth()
|
await self.lounge_controller.refresh_auth()
|
||||||
except:
|
except BaseException:
|
||||||
# traceback.print_exc()
|
# traceback.print_exc()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def is_available(self):
|
async def is_available(self):
|
||||||
try:
|
try:
|
||||||
return await self.lounge_controller.is_available()
|
return await self.lounge_controller.is_available()
|
||||||
except:
|
except BaseException:
|
||||||
# traceback.print_exc()
|
# traceback.print_exc()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -57,20 +57,20 @@ class DeviceListener:
|
|||||||
try:
|
try:
|
||||||
self.logger.debug("Refreshing auth")
|
self.logger.debug("Refreshing auth")
|
||||||
await lounge_controller.refresh_auth()
|
await lounge_controller.refresh_auth()
|
||||||
except:
|
except BaseException:
|
||||||
await asyncio.sleep(10)
|
await asyncio.sleep(10)
|
||||||
while not (await self.is_available()) and not self.cancelled:
|
while not (await self.is_available()) and not self.cancelled:
|
||||||
await asyncio.sleep(10)
|
await asyncio.sleep(10)
|
||||||
try:
|
try:
|
||||||
await lounge_controller.connect()
|
await lounge_controller.connect()
|
||||||
except:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
while not lounge_controller.connected() and not self.cancelled:
|
while not lounge_controller.connected() and not self.cancelled:
|
||||||
# Doesn't connect to the device if it's a kids profile (it's broken)
|
# Doesn't connect to the device if it's a kids profile (it's broken)
|
||||||
await asyncio.sleep(10)
|
await asyncio.sleep(10)
|
||||||
try:
|
try:
|
||||||
await lounge_controller.connect()
|
await lounge_controller.connect()
|
||||||
except:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"Connected to device %s (%s)", lounge_controller.screen_name, self.name
|
"Connected to device %s (%s)", lounge_controller.screen_name, self.name
|
||||||
@@ -79,14 +79,14 @@ class DeviceListener:
|
|||||||
self.logger.info("Subscribing to lounge")
|
self.logger.info("Subscribing to lounge")
|
||||||
sub = await lounge_controller.subscribe_monitored(self)
|
sub = await lounge_controller.subscribe_monitored(self)
|
||||||
await sub
|
await sub
|
||||||
except:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Method called on playback state change
|
# Method called on playback state change
|
||||||
async def __call__(self, state):
|
async def __call__(self, state):
|
||||||
try:
|
try:
|
||||||
self.task.cancel()
|
self.task.cancel()
|
||||||
except:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
time_start = time.time()
|
time_start = time.time()
|
||||||
self.task = asyncio.create_task(self.process_playstatus(state, time_start))
|
self.task = asyncio.create_task(self.process_playstatus(state, time_start))
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ class AddDevice(ModalWithClickExit):
|
|||||||
paired = False
|
paired = False
|
||||||
try:
|
try:
|
||||||
paired = await lounge_controller.pair(pairing_code)
|
paired = await lounge_controller.pair(pairing_code)
|
||||||
except:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
if paired:
|
if paired:
|
||||||
device = {
|
device = {
|
||||||
@@ -496,7 +496,7 @@ class AddChannel(ModalWithClickExit):
|
|||||||
self.query_one("#channel-search-results").remove_children()
|
self.query_one("#channel-search-results").remove_children()
|
||||||
try:
|
try:
|
||||||
channels_list = await self.api_helper.search_channels(channel_name)
|
channels_list = await self.api_helper.search_channels(channel_name)
|
||||||
except:
|
except BaseException:
|
||||||
self.query_one("#add-channel-info").update(
|
self.query_one("#add-channel-info").update(
|
||||||
"[#ff0000]Failed to search for channel"
|
"[#ff0000]Failed to search for channel"
|
||||||
)
|
)
|
||||||
@@ -943,7 +943,7 @@ class ISponsorBlockTVSetupMainScreen(Screen):
|
|||||||
self.app.query_one("#warning-no-key").display = (
|
self.app.query_one("#warning-no-key").display = (
|
||||||
not event.input.value
|
not event.input.value
|
||||||
) and self.config.channel_whitelist
|
) and self.config.channel_whitelist
|
||||||
except:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class YtLoungeApi(pyytlounge.YtLoungeApi):
|
|||||||
) # YouTube sends at least a message every 30 seconds (no-op or any other)
|
) # YouTube sends at least a message every 30 seconds (no-op or any other)
|
||||||
try:
|
try:
|
||||||
self.subscribe_task.cancel()
|
self.subscribe_task.cancel()
|
||||||
except Exception:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Subscribe to the lounge and start the watchdog
|
# Subscribe to the lounge and start the watchdog
|
||||||
@@ -52,7 +52,7 @@ class YtLoungeApi(pyytlounge.YtLoungeApi):
|
|||||||
self.callback = callback
|
self.callback = callback
|
||||||
try:
|
try:
|
||||||
self.subscribe_task_watchdog.cancel()
|
self.subscribe_task_watchdog.cancel()
|
||||||
except:
|
except BaseException:
|
||||||
pass # No watchdog task
|
pass # No watchdog task
|
||||||
self.subscribe_task = asyncio.create_task(super().subscribe(callback))
|
self.subscribe_task = asyncio.create_task(super().subscribe(callback))
|
||||||
self.subscribe_task_watchdog = asyncio.create_task(self._watchdog())
|
self.subscribe_task_watchdog = asyncio.create_task(self._watchdog())
|
||||||
@@ -64,7 +64,7 @@ class YtLoungeApi(pyytlounge.YtLoungeApi):
|
|||||||
# (Re)start the watchdog
|
# (Re)start the watchdog
|
||||||
try:
|
try:
|
||||||
self.subscribe_task_watchdog.cancel()
|
self.subscribe_task_watchdog.cancel()
|
||||||
except:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
self.subscribe_task_watchdog = asyncio.create_task(self._watchdog())
|
self.subscribe_task_watchdog = asyncio.create_task(self._watchdog())
|
||||||
|
|||||||
Reference in New Issue
Block a user