mirror of
https://github.com/dmunozv04/iSponsorBlockTV.git
synced 2025-12-06 11:56:45 +03:00
Attempt to fix the issue
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import asyncio
|
||||
import json
|
||||
import sys
|
||||
from typing import Any, List
|
||||
|
||||
import pyytlounge
|
||||
@@ -284,7 +285,12 @@ class YtLoungeApi(pyytlounge.YtLoungeApi):
|
||||
try:
|
||||
text = await resp.text()
|
||||
if resp.status == 401:
|
||||
self._lounge_token_expired()
|
||||
if "Connection denied" in text:
|
||||
self._logger.warning(
|
||||
"Connection denied, attempting to circumvent the issue"
|
||||
)
|
||||
await self.connect_as_screen()
|
||||
#self._lounge_token_expired()
|
||||
return False
|
||||
|
||||
if resp.status != 200:
|
||||
@@ -304,3 +310,45 @@ class YtLoungeApi(pyytlounge.YtLoungeApi):
|
||||
resp.reason,
|
||||
)
|
||||
raise
|
||||
|
||||
async def connect_as_screen(self) -> bool:
|
||||
"""Attempt to connect using the previously set tokens"""
|
||||
if not self.linked():
|
||||
raise NotLinkedException("Not linked")
|
||||
|
||||
connect_body = {
|
||||
"id": str(uuid4()),
|
||||
"mdx-version": "3",
|
||||
"TYPE": "xmlhttp",
|
||||
"theme": "cl",
|
||||
"sessionSource": "MDX_SESSION_SOURCE_UNKNOWN",
|
||||
"connectParams": "{\"setStatesParams\": \"{\"playbackSpeed\":0}\"}",
|
||||
"sessionNonce": str(uuid4()),
|
||||
"RID": "1",
|
||||
"CVER": "1",
|
||||
"capabilities": "que,dsdtr,atp,vsp",
|
||||
"ui": "false",
|
||||
"app": "ytios-phone-20.15.1",
|
||||
"pairing_type": "manual",
|
||||
"VER": "8",
|
||||
"loungeIdToken": self.auth.lounge_id_token,
|
||||
"device": "LOUNGE_SCREEN",
|
||||
"name": self.device_name,
|
||||
}
|
||||
connect_url = (
|
||||
f"{api_base}/bc/bind"
|
||||
)
|
||||
async with self.session.post(url=connect_url, data=connect_body) as resp:
|
||||
try:
|
||||
await resp.text()
|
||||
self.logger.error("Connected as screen: please force close the app on the device for iSponsorBlockTV to work properly")
|
||||
self.logger.warn("Exiting in 5 seconds")
|
||||
await asyncio.sleep(5)
|
||||
sys.exit(0)
|
||||
except:
|
||||
self._logger.exception(
|
||||
"Handle connect failed, status %s reason %s",
|
||||
resp.status,
|
||||
resp.reason,
|
||||
)
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user