Skip to content

Commit

Permalink
Merge pull request #237 from dmunozv04/improve-exceptions
Browse files Browse the repository at this point in the history
Improve exceptions
  • Loading branch information
dmunozv04 authored Jan 30, 2025
2 parents f75dff8 + dca9186 commit c8b9fe1
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 30 deletions.
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ assignees: ''

---

Before opening an issue make sure that there are no duplicates and that you are on the latest version.
Before opening an issue make sure that there are no duplicates and that you are
on the latest version.
**Describe the bug**
A clear and concise description of what the bug is.

Expand Down
6 changes: 4 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ assignees: ''
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
A clear and concise description of what the problem is. Ex. I'm always
frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
A clear and concise description of any alternative solutions or features you've
considered.

**Additional context**
Add any other context or screenshots about the feature request here.
5 changes: 2 additions & 3 deletions .github/workflows/build_docker_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,5 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/dmunozv04/isponsorblocktv:buildcache
# Only cache if it's not a pull request
cache-to: ${{ github.event_name != 'pull_request' && 'type=registry,ref=ghcr.io/dmunozv04/isponsorblocktv:buildcache,mode=max' || '' }}
cache-from: type=gha
cache-to: type=gha,mode=max
1 change: 1 addition & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LICENSE.md
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
[![GitHub Release](https://img.shields.io/github/v/release/dmunozv04/isponsorblocktv?logo=GitHub&style=flat)](https://github.com/dmunozv04/iSponsorBlockTV/releases/latest)
[![GitHub Repo stars](https://img.shields.io/github/stars/dmunozv04/isponsorblocktv?style=flat)](https://github.com/dmunozv04/isponsorblocktv)

Skip sponsor segments in YouTube videos playing on a YouTube TV device (see below for compatibility details).
Skip sponsor segments in YouTube videos playing on a YouTube TV device (see
below for compatibility details).

This project is written in asynchronous python and should be pretty quick.

## Installation

Check the [wiki](https://github.com/dmunozv04/iSponsorBlockTV/wiki/Installation)

Warning: docker armv7 builds have been deprecated. Amd64 and arm64 builds are still available.

## Compatibility

Legend: ✅ = Working, ❌ = Not working, ❔ = Not tested
Expand All @@ -39,18 +38,23 @@ Open an issue/pull request if you have tested a device that isn't listed here.
## Usage

Run iSponsorBlockTV on a computer that has network access.
Auto discovery will require the computer to be on the same network as the device during setup.
The device can also be manually added to iSponsorBlockTV with a YouTube TV code. This code can be found in the settings page of your YouTube application.
Auto discovery will require the computer to be on the same network as the device
during setup.
The device can also be manually added to iSponsorBlockTV with a YouTube TV code.
This code can be found in the settings page of your YouTube application.

It connects to the device, watches its activity and skips any sponsor segment using the [SponsorBlock](https://sponsor.ajay.app/) API.
It connects to the device, watches its activity and skips any sponsor segment
using the [SponsorBlock](https://sponsor.ajay.app/) API.
It can also skip/mute YouTube ads.

## Libraries used

- [pyytlounge](https://github.com/FabioGNR/pyytlounge) Used to interact with the device
- [pyytlounge](https://github.com/FabioGNR/pyytlounge) Used to interact with the
device
- asyncio and [aiohttp](https://github.com/aio-libs/aiohttp)
- [async-cache](https://github.com/iamsinghrajat/async-cache)
- [Textual](https://github.com/textualize/textual/) Used for the amazing new graphical configurator
- [Textual](https://github.com/textualize/textual/) Used for the amazing new
graphical configurator
- [ssdp](https://github.com/codingjoe/ssdp) Used for auto discovery

## Projects using this project
Expand All @@ -68,8 +72,10 @@ It can also skip/mute YouTube ads.
## Contributors

- [dmunozv04](https://github.com/dmunozv04) - creator and maintainer
- [HaltCatchFire](https://github.com/HaltCatchFire) - updated dependencies and improved skip logic
- [Oxixes](https://github.com/oxixes) - added support for channel whitelist and minor improvements
- [HaltCatchFire](https://github.com/HaltCatchFire) - updated dependencies and
improved skip logic
- [Oxixes](https://github.com/oxixes) - added support for channel whitelist and
minor improvements

## License

Expand Down
14 changes: 7 additions & 7 deletions src/iSponsorBlockTV/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ async def refresh_auth_loop(self):
await asyncio.sleep(60 * 60 * 24) # Refresh every 24 hours
try:
await self.lounge_controller.refresh_auth()
except:
except BaseException:
# traceback.print_exc()
pass

async def is_available(self):
try:
return await self.lounge_controller.is_available()
except:
except BaseException:
# traceback.print_exc()
return False

Expand All @@ -57,20 +57,20 @@ async def loop(self):
try:
self.logger.debug("Refreshing auth")
await lounge_controller.refresh_auth()
except:
except BaseException:
await asyncio.sleep(10)
while not (await self.is_available()) and not self.cancelled:
await asyncio.sleep(10)
try:
await lounge_controller.connect()
except:
except BaseException:
pass
while not lounge_controller.connected() and not self.cancelled:
# Doesn't connect to the device if it's a kids profile (it's broken)
await asyncio.sleep(10)
try:
await lounge_controller.connect()
except:
except BaseException:
pass
self.logger.info(
"Connected to device %s (%s)", lounge_controller.screen_name, self.name
Expand All @@ -79,14 +79,14 @@ async def loop(self):
self.logger.info("Subscribing to lounge")
sub = await lounge_controller.subscribe_monitored(self)
await sub
except:
except BaseException:
pass

# Method called on playback state change
async def __call__(self, state):
try:
self.task.cancel()
except:
except BaseException:
pass
time_start = time.time()
self.task = asyncio.create_task(self.process_playstatus(state, time_start))
Expand Down
7 changes: 3 additions & 4 deletions src/iSponsorBlockTV/setup_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ async def handle_add_device_pin(self) -> None:
paired = False
try:
paired = await lounge_controller.pair(pairing_code)
except:
except BaseException:
pass
if paired:
device = {
Expand Down Expand Up @@ -476,7 +476,6 @@ def handle_radio_set_changed(self, event: RadioSet.Changed) -> None:

@on(Button.Pressed, "#add-channel-switch-buttons > *")
def handle_switch_buttons(self, event: Button.Pressed) -> None:
button_ = event.button.id
self.query_one("#add-channel-switcher").current = event.button.id.replace(
"-button", "-container"
)
Expand All @@ -496,7 +495,7 @@ async def handle_search_channel(self) -> None:
self.query_one("#channel-search-results").remove_children()
try:
channels_list = await self.api_helper.search_channels(channel_name)
except:
except BaseException:
self.query_one("#add-channel-info").update(
"[#ff0000]Failed to search for channel"
)
Expand Down Expand Up @@ -943,7 +942,7 @@ def changed_api_key(self, event: Input.Changed):
self.app.query_one("#warning-no-key").display = (
not event.input.value
) and self.config.channel_whitelist
except:
except BaseException:
pass


Expand Down
6 changes: 3 additions & 3 deletions src/iSponsorBlockTV/ytlounge.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ async def _watchdog(self):
) # YouTube sends at least a message every 30 seconds (no-op or any other)
try:
self.subscribe_task.cancel()
except Exception:
except BaseException:
pass

# Subscribe to the lounge and start the watchdog
async def subscribe_monitored(self, callback):
self.callback = callback
try:
self.subscribe_task_watchdog.cancel()
except:
except BaseException:
pass # No watchdog task
self.subscribe_task = asyncio.create_task(super().subscribe(callback))
self.subscribe_task_watchdog = asyncio.create_task(self._watchdog())
Expand All @@ -64,7 +64,7 @@ def _process_event(self, event_id: int, event_type: str, args):
# (Re)start the watchdog
try:
self.subscribe_task_watchdog.cancel()
except:
except BaseException:
pass
finally:
self.subscribe_task_watchdog = asyncio.create_task(self._watchdog())
Expand Down

0 comments on commit c8b9fe1

Please sign in to comment.