mirror of
https://github.com/dmunozv04/iSponsorBlockTV.git
synced 2025-12-21 15:08:28 +03:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
@@ -7,8 +7,9 @@ from . import api_helpers, ytlounge
|
|||||||
|
|
||||||
async def pair_device(web_session):
|
async def pair_device(web_session):
|
||||||
try:
|
try:
|
||||||
lounge_controller = ytlounge.YtLoungeApi("iSponsorBlockTV",
|
lounge_controller = ytlounge.YtLoungeApi(
|
||||||
web_session=web_session)
|
"iSponsorBlockTV", web_session=web_session
|
||||||
|
)
|
||||||
pairing_code = input(
|
pairing_code = input(
|
||||||
"Enter pairing code (found in Settings - Link with TV code): "
|
"Enter pairing code (found in Settings - Link with TV code): "
|
||||||
)
|
)
|
||||||
@@ -53,8 +54,7 @@ def main(config, debug: bool) -> None:
|
|||||||
):
|
):
|
||||||
del config["atvs"]
|
del config["atvs"]
|
||||||
devices = config.devices
|
devices = config.devices
|
||||||
while not input(
|
while not input(f"Paired with {len(devices)} Device(s). Add more? (y/n) ") == "n":
|
||||||
f"Paired with {len(devices)} Device(s). Add more? (y/n) ") == "n":
|
|
||||||
task = loop.create_task(pair_device(web_session))
|
task = loop.create_task(pair_device(web_session))
|
||||||
loop.run_until_complete(task)
|
loop.run_until_complete(task)
|
||||||
device = task.result()
|
device = task.result()
|
||||||
@@ -82,8 +82,7 @@ def main(config, debug: bool) -> None:
|
|||||||
|
|
||||||
skip_categories = config.skip_categories
|
skip_categories = config.skip_categories
|
||||||
if skip_categories:
|
if skip_categories:
|
||||||
if input(
|
if input("Skip categories already specified. Change them? (y/n) ") == "y":
|
||||||
"Skip categories already specified. Change them? (y/n) ") == "y":
|
|
||||||
categories = input(
|
categories = input(
|
||||||
"Enter skip categories (space or comma sepparated) Options: [sponsor"
|
"Enter skip categories (space or comma sepparated) Options: [sponsor"
|
||||||
" selfpromo exclusive_access interaction poi_highlight intro outro"
|
" selfpromo exclusive_access interaction poi_highlight intro outro"
|
||||||
@@ -107,8 +106,7 @@ def main(config, debug: bool) -> None:
|
|||||||
|
|
||||||
channel_whitelist = config.channel_whitelist
|
channel_whitelist = config.channel_whitelist
|
||||||
if (
|
if (
|
||||||
input(
|
input("Do you want to whitelist any channels from being ad-blocked? (y/n) ")
|
||||||
"Do you want to whitelist any channels from being ad-blocked? (y/n) ")
|
|
||||||
== "y"
|
== "y"
|
||||||
):
|
):
|
||||||
if not apikey:
|
if not apikey:
|
||||||
|
|||||||
@@ -336,7 +336,9 @@ class AddDevice(ModalWithClickExit):
|
|||||||
@on(Button.Pressed, "#add-device-pin-add-button")
|
@on(Button.Pressed, "#add-device-pin-add-button")
|
||||||
async def handle_add_device_pin(self) -> None:
|
async def handle_add_device_pin(self) -> None:
|
||||||
self.query_one("#add-device-pin-add-button").disabled = True
|
self.query_one("#add-device-pin-add-button").disabled = True
|
||||||
lounge_controller = ytlounge.YtLoungeApi("iSponsorBlockTV", web_session=self.web_session)
|
lounge_controller = ytlounge.YtLoungeApi(
|
||||||
|
"iSponsorBlockTV", web_session=self.web_session
|
||||||
|
)
|
||||||
pairing_code = self.query_one("#pairing-code-input").value
|
pairing_code = self.query_one("#pairing-code-input").value
|
||||||
pairing_code = int(
|
pairing_code = int(
|
||||||
pairing_code.replace("-", "").replace(" ", "")
|
pairing_code.replace("-", "").replace(" ", "")
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
from aiohttp import ClientSession
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import pyytlounge
|
import pyytlounge
|
||||||
|
from aiohttp import ClientSession
|
||||||
|
|
||||||
from .constants import youtube_client_blacklist
|
from .constants import youtube_client_blacklist
|
||||||
|
|
||||||
@@ -10,8 +10,14 @@ create_task = asyncio.create_task
|
|||||||
|
|
||||||
|
|
||||||
class YtLoungeApi(pyytlounge.YtLoungeApi):
|
class YtLoungeApi(pyytlounge.YtLoungeApi):
|
||||||
def __init__(self, screen_id, config=None, api_helper=None, logger=None,
|
def __init__(
|
||||||
web_session: ClientSession = None):
|
self,
|
||||||
|
screen_id,
|
||||||
|
config=None,
|
||||||
|
api_helper=None,
|
||||||
|
logger=None,
|
||||||
|
web_session: ClientSession = None,
|
||||||
|
):
|
||||||
super().__init__("iSponsorBlockTV", logger=logger)
|
super().__init__("iSponsorBlockTV", logger=logger)
|
||||||
if web_session is not None:
|
if web_session is not None:
|
||||||
self.session = web_session # And use the one we passed
|
self.session = web_session # And use the one we passed
|
||||||
@@ -126,8 +132,7 @@ class YtLoungeApi(pyytlounge.YtLoungeApi):
|
|||||||
for device in devices:
|
for device in devices:
|
||||||
if device["type"] == "LOUNGE_SCREEN":
|
if device["type"] == "LOUNGE_SCREEN":
|
||||||
device_info = json.loads(device.get("deviceInfo", "{}"))
|
device_info = json.loads(device.get("deviceInfo", "{}"))
|
||||||
if device_info.get("clientName",
|
if device_info.get("clientName", "") in youtube_client_blacklist:
|
||||||
"") in youtube_client_blacklist:
|
|
||||||
self._sid = None
|
self._sid = None
|
||||||
self._gsession = None # Force disconnect
|
self._gsession = None # Force disconnect
|
||||||
|
|
||||||
@@ -139,8 +144,7 @@ class YtLoungeApi(pyytlounge.YtLoungeApi):
|
|||||||
create_task(self.play_video(video_id_saved))
|
create_task(self.play_video(video_id_saved))
|
||||||
elif event_type == "loungeScreenDisconnected":
|
elif event_type == "loungeScreenDisconnected":
|
||||||
data = args[0]
|
data = args[0]
|
||||||
if data[
|
if data["reason"] == "disconnectedByUserScreenInitiated": # Short playing?
|
||||||
"reason"] == "disconnectedByUserScreenInitiated": # Short playing?
|
|
||||||
self.shorts_disconnected = True
|
self.shorts_disconnected = True
|
||||||
|
|
||||||
super()._process_event(event_id, event_type, args)
|
super()._process_event(event_id, event_type, args)
|
||||||
@@ -158,20 +162,17 @@ class YtLoungeApi(pyytlounge.YtLoungeApi):
|
|||||||
mute_str = "true"
|
mute_str = "true"
|
||||||
else:
|
else:
|
||||||
mute_str = "false"
|
mute_str = "false"
|
||||||
if override or not (
|
if override or not (self.volume_state.get("muted", "false") == mute_str):
|
||||||
self.volume_state.get("muted", "false") == mute_str):
|
|
||||||
self.volume_state["muted"] = mute_str
|
self.volume_state["muted"] = mute_str
|
||||||
# YouTube wants the volume when unmuting, so we send it
|
# YouTube wants the volume when unmuting, so we send it
|
||||||
await super()._command(
|
await super()._command(
|
||||||
"setVolume",
|
"setVolume",
|
||||||
{"volume": self.volume_state.get("volume", 100),
|
{"volume": self.volume_state.get("volume", 100), "muted": mute_str},
|
||||||
"muted": mute_str},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def set_auto_play_mode(self, enabled: bool):
|
async def set_auto_play_mode(self, enabled: bool):
|
||||||
await super()._command(
|
await super()._command(
|
||||||
"setAutoplayMode",
|
"setAutoplayMode", {"autoplayMode": "ENABLED" if enabled else "DISABLED"}
|
||||||
{"autoplayMode": "ENABLED" if enabled else "DISABLED"}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def play_video(self, video_id: str) -> bool:
|
async def play_video(self, video_id: str) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user