mirror of
https://github.com/dmunozv04/iSponsorBlockTV.git
synced 2026-01-27 12:50:52 +03:00
Sync with main
Co-authored-by: tsia <github@tsia.de> Co-authored-by: kot0dama <89980752+kot0dama@users.noreply.github.com> Co-authored-by: boltgolt <boltgolt@gmail.com>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
appdirs==1.4.4
|
||||
aiohttp==3.8.6
|
||||
aiohttp==3.9.0
|
||||
argparse==1.4.0
|
||||
async-cache==1.1.1
|
||||
pyytlounge==1.6.3
|
||||
@@ -7,4 +6,4 @@ rich==13.6.0
|
||||
ssdp==1.3.0
|
||||
textual==0.40.0
|
||||
textual-slider==0.1.1
|
||||
xmltodict==0.13.0
|
||||
xmltodict==0.13.0
|
||||
@@ -6,11 +6,13 @@ from . import api_helpers, ytlounge
|
||||
|
||||
|
||||
class DeviceListener:
|
||||
def __init__(self, api_helper, config, screen_id, offset):
|
||||
def __init__(self, api_helper, config, device):
|
||||
self.task: asyncio.Task = None
|
||||
self.api_helper = api_helper
|
||||
self.lounge_controller = ytlounge.YtLoungeApi(screen_id, config, api_helper)
|
||||
self.offset = offset
|
||||
self.lounge_controller = ytlounge.YtLoungeApi(
|
||||
device.screen_id, config, api_helper)
|
||||
self.offset = device.offset
|
||||
self.name = device.name
|
||||
self.cancelled = False
|
||||
|
||||
# Ensures that we have a valid auth token
|
||||
@@ -53,6 +55,7 @@ class DeviceListener:
|
||||
await lounge_controller.connect()
|
||||
except:
|
||||
pass
|
||||
print(f"Connected to device {lounge_controller.screen_name} ({self.name})")
|
||||
try:
|
||||
# print("Subscribing to lounge")
|
||||
sub = await lounge_controller.subscribe_monitored(self)
|
||||
@@ -103,10 +106,10 @@ class DeviceListener:
|
||||
# Skips to the next segment (waits for the time to pass)
|
||||
async def skip(self, time_to, position, UUID):
|
||||
await asyncio.sleep(time_to)
|
||||
asyncio.create_task(self.lounge_controller.seek_to(position))
|
||||
asyncio.create_task(
|
||||
await asyncio.gather(
|
||||
self.lounge_controller.seek_to(position),
|
||||
self.api_helper.mark_viewed_segments(UUID)
|
||||
) # Don't wait for this to finish
|
||||
)
|
||||
|
||||
# Stops the connection to the device
|
||||
async def cancel(self):
|
||||
@@ -133,7 +136,7 @@ def main(config, debug):
|
||||
web_session = aiohttp.ClientSession(loop=loop, connector=tcp_connector)
|
||||
api_helper = api_helpers.ApiHelper(config, web_session)
|
||||
for i in config.devices:
|
||||
device = DeviceListener(api_helper, config, i.screen_id, i.offset)
|
||||
device = DeviceListener(api_helper, config, i)
|
||||
devices.append(device)
|
||||
tasks.append(loop.create_task(device.loop()))
|
||||
tasks.append(loop.create_task(device.refresh_auth_loop()))
|
||||
@@ -143,4 +146,4 @@ def main(config, debug):
|
||||
print("Keyboard interrupt detected, cancelling tasks and exiting...")
|
||||
loop.run_until_complete(finish(devices))
|
||||
finally:
|
||||
loop.run_until_complete(web_session.close())
|
||||
loop.run_until_complete(web_session.close())
|
||||
@@ -481,7 +481,7 @@ class ApiKeyManager(Vertical):
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Label("YouTube Api Key", classes="title")
|
||||
yield Label(
|
||||
"You can get a YouTube Api Key from the [link=https://console.developers.google.com/apis/credentials]Google Cloud Console[/link]")
|
||||
"You can get a YouTube Data API v3 Key from the [link=https://console.developers.google.com/apis/credentials]Google Cloud Console[/link]. This key is only required if you're whitelisting channels.")
|
||||
with Grid(id="api-key-grid"):
|
||||
yield Input(placeholder="YouTube Api Key", id="api-key-input", password=True, value=self.config.apikey)
|
||||
yield Button("Show key", id="api-key-view")
|
||||
@@ -559,9 +559,9 @@ class AdSkipMuteManager(Vertical):
|
||||
"This feature allows you to automatically mute and/or skip native YouTube ads. Skipping ads only works if that ad shows the 'Skip Ad' button, if it doesn't then it will only be able to be muted.",
|
||||
classes="subtitle", id="skip-count-tracking-subtitle")
|
||||
with Horizontal(id="ad-skip-mute-container"):
|
||||
yield Checkbox(value=self.config.mute_ads, id="mute-ads-switch",
|
||||
label="Enable skipping ads")
|
||||
yield Checkbox(value=self.config.skip_ads, id="skip-ads-switch",
|
||||
label="Enable skipping ads")
|
||||
yield Checkbox(value=self.config.mute_ads, id="mute-ads-switch",
|
||||
label="Enable muting ads")
|
||||
|
||||
@on(Checkbox.Changed, "#mute-ads-switch")
|
||||
|
||||
Reference in New Issue
Block a user