mirror of
https://github.com/dmunozv04/iSponsorBlockTV.git
synced 2025-12-11 22:46:44 +03:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c196e76205 | ||
|
|
863ec5e163 | ||
|
|
128e1f72cb | ||
|
|
fede94e973 | ||
|
|
0d62f69460 | ||
|
|
8d76bdd1c1 |
@@ -19,3 +19,6 @@ skip_categories = (
|
||||
)
|
||||
|
||||
youtube_client_blacklist = ["TVHTML5_FOR_KIDS"]
|
||||
|
||||
|
||||
config_file_blacklist_keys = ["config_file", "data_dir"]
|
||||
|
||||
@@ -8,6 +8,7 @@ import time
|
||||
from appdirs import user_data_dir
|
||||
|
||||
from . import config_setup, main, setup_wizard
|
||||
from .constants import config_file_blacklist_keys
|
||||
|
||||
|
||||
class Device:
|
||||
@@ -68,7 +69,8 @@ class Config:
|
||||
with open(self.config_file, "r") as f:
|
||||
config = json.load(f)
|
||||
for i in config:
|
||||
setattr(self, i, config[i])
|
||||
if i not in config_file_blacklist_keys:
|
||||
setattr(self, i, config[i])
|
||||
except FileNotFoundError:
|
||||
print("Could not load config file")
|
||||
# Create data directory if it doesn't exist (if we're not running in docker)
|
||||
@@ -93,9 +95,12 @@ class Config:
|
||||
config_dict = self.__dict__
|
||||
# Don't save the config file name
|
||||
config_file = self.config_file
|
||||
data_dir = self.data_dir
|
||||
del config_dict["config_file"]
|
||||
del config_dict["data_dir"]
|
||||
json.dump(config_dict, f, indent=4)
|
||||
self.config_file = config_file
|
||||
self.data_dir = data_dir
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, Config):
|
||||
|
||||
@@ -70,12 +70,16 @@ class YtLoungeApi(pyytlounge.YtLoungeApi):
|
||||
if self.mute_ads and data.get("state", "0") == "1":
|
||||
# print("Ad has ended, unmuting")
|
||||
create_task(self.mute(False, override=True))
|
||||
elif self.mute_ads and event_type == "onAdStateChange":
|
||||
elif event_type == "onAdStateChange":
|
||||
data = args[0]
|
||||
if data["adState"] == '0': # Ad is not playing
|
||||
# print("Ad has ended, unmuting")
|
||||
create_task(self.mute(False, override=True))
|
||||
else: # Seen multiple other adStates, assuming they are all ads
|
||||
elif self.skip_ads and data["isSkipEnabled"] == "true": # YouTube uses strings for booleans
|
||||
print("Ad can be skipped, skipping")
|
||||
create_task(self.skip_ad())
|
||||
create_task(self.mute(False, override=True))
|
||||
elif self.mute_ads: # Seen multiple other adStates, assuming they are all ads
|
||||
print("Ad has started, muting")
|
||||
create_task(self.mute(True, override=True))
|
||||
# Manages volume, useful since YouTube wants to know the volume when unmuting (even if they already have it)
|
||||
@@ -96,20 +100,15 @@ class YtLoungeApi(pyytlounge.YtLoungeApi):
|
||||
if vid_id := data["contentVideoId"]:
|
||||
print(f"Getting segments for next video: {vid_id}")
|
||||
create_task(self.api_helper.get_segments(vid_id))
|
||||
|
||||
if data["isSkippable"] == "true": # YouTube uses strings for booleans
|
||||
if self.skip_ads:
|
||||
create_task(self.skip_ad())
|
||||
create_task(self.mute(False, override=True))
|
||||
elif self.mute_ads:
|
||||
create_task(self.mute(True, override=True))
|
||||
if self.mute_ads:
|
||||
create_task(self.mute(True, override=True))
|
||||
|
||||
elif event_type == "loungeStatus":
|
||||
data = args[0]
|
||||
devices = json.loads(data["devices"])
|
||||
for device in devices:
|
||||
if device["type"] == "LOUNGE_SCREEN":
|
||||
device_info = json.loads(device.get("deviceInfo", ""))
|
||||
device_info = json.loads(device.get("deviceInfo", "{}"))
|
||||
if device_info.get("clientName", "") in youtube_client_blacklist:
|
||||
self._sid = None
|
||||
self._gsession = None # Force disconnect
|
||||
|
||||
Reference in New Issue
Block a user