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:
dmunozv04
2023-11-29 11:33:29 +01:00
parent 20c6870e4c
commit 7b6f9bd8a0
3 changed files with 16 additions and 14 deletions

View File

@@ -1,5 +1,4 @@
appdirs==1.4.4 aiohttp==3.9.0
aiohttp==3.8.6
argparse==1.4.0 argparse==1.4.0
async-cache==1.1.1 async-cache==1.1.1
pyytlounge==1.6.3 pyytlounge==1.6.3

View File

@@ -6,11 +6,13 @@ from . import api_helpers, ytlounge
class DeviceListener: class DeviceListener:
def __init__(self, api_helper, config, screen_id, offset): def __init__(self, api_helper, config, device):
self.task: asyncio.Task = None self.task: asyncio.Task = None
self.api_helper = api_helper self.api_helper = api_helper
self.lounge_controller = ytlounge.YtLoungeApi(screen_id, config, api_helper) self.lounge_controller = ytlounge.YtLoungeApi(
self.offset = offset device.screen_id, config, api_helper)
self.offset = device.offset
self.name = device.name
self.cancelled = False self.cancelled = False
# Ensures that we have a valid auth token # Ensures that we have a valid auth token
@@ -53,6 +55,7 @@ class DeviceListener:
await lounge_controller.connect() await lounge_controller.connect()
except: except:
pass pass
print(f"Connected to device {lounge_controller.screen_name} ({self.name})")
try: try:
# print("Subscribing to lounge") # print("Subscribing to lounge")
sub = await lounge_controller.subscribe_monitored(self) sub = await lounge_controller.subscribe_monitored(self)
@@ -103,10 +106,10 @@ class DeviceListener:
# Skips to the next segment (waits for the time to pass) # Skips to the next segment (waits for the time to pass)
async def skip(self, time_to, position, UUID): async def skip(self, time_to, position, UUID):
await asyncio.sleep(time_to) await asyncio.sleep(time_to)
asyncio.create_task(self.lounge_controller.seek_to(position)) await asyncio.gather(
asyncio.create_task( self.lounge_controller.seek_to(position),
self.api_helper.mark_viewed_segments(UUID) self.api_helper.mark_viewed_segments(UUID)
) # Don't wait for this to finish )
# Stops the connection to the device # Stops the connection to the device
async def cancel(self): async def cancel(self):
@@ -133,7 +136,7 @@ def main(config, debug):
web_session = aiohttp.ClientSession(loop=loop, connector=tcp_connector) web_session = aiohttp.ClientSession(loop=loop, connector=tcp_connector)
api_helper = api_helpers.ApiHelper(config, web_session) api_helper = api_helpers.ApiHelper(config, web_session)
for i in config.devices: for i in config.devices:
device = DeviceListener(api_helper, config, i.screen_id, i.offset) device = DeviceListener(api_helper, config, i)
devices.append(device) devices.append(device)
tasks.append(loop.create_task(device.loop())) tasks.append(loop.create_task(device.loop()))
tasks.append(loop.create_task(device.refresh_auth_loop())) tasks.append(loop.create_task(device.refresh_auth_loop()))

View File

@@ -481,7 +481,7 @@ class ApiKeyManager(Vertical):
def compose(self) -> ComposeResult: def compose(self) -> ComposeResult:
yield Label("YouTube Api Key", classes="title") yield Label("YouTube Api Key", classes="title")
yield Label( 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"): with Grid(id="api-key-grid"):
yield Input(placeholder="YouTube Api Key", id="api-key-input", password=True, value=self.config.apikey) yield Input(placeholder="YouTube Api Key", id="api-key-input", password=True, value=self.config.apikey)
yield Button("Show key", id="api-key-view") 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.", "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") classes="subtitle", id="skip-count-tracking-subtitle")
with Horizontal(id="ad-skip-mute-container"): 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", 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") label="Enable muting ads")
@on(Checkbox.Changed, "#mute-ads-switch") @on(Checkbox.Changed, "#mute-ads-switch")