mirror of
https://github.com/dmunozv04/iSponsorBlockTV.git
synced 2025-12-08 04:46:44 +03:00
Change how playing app is detected
This commit is contained in:
7
main.py
7
main.py
@@ -34,7 +34,6 @@ class MyPushListener(pyatv.interface.PushListener):
|
|||||||
def __init__(self, apikey, atv, categories):
|
def __init__(self, apikey, atv, categories):
|
||||||
self.apikey = apikey
|
self.apikey = apikey
|
||||||
self.rc = atv.remote_control
|
self.rc = atv.remote_control
|
||||||
self.app = atv.metadata.app
|
|
||||||
self.web_session = aiohttp.ClientSession()
|
self.web_session = aiohttp.ClientSession()
|
||||||
self.categories = categories
|
self.categories = categories
|
||||||
self.atv = atv
|
self.atv = atv
|
||||||
@@ -45,15 +44,15 @@ class MyPushListener(pyatv.interface.PushListener):
|
|||||||
self.task.cancel()
|
self.task.cancel()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self.task = asyncio.create_task(process_playstatus(playstatus, self.apikey, self.rc, self.app, self.web_session, self.categories))
|
self.task = asyncio.create_task(process_playstatus(playstatus, self.apikey, self.rc, self.web_session, self.categories, self.atv))
|
||||||
def playstatus_error(self, updater, exception):
|
def playstatus_error(self, updater, exception):
|
||||||
print(exception)
|
print(exception)
|
||||||
print("stopped")
|
print("stopped")
|
||||||
# Error in exception
|
# Error in exception
|
||||||
|
|
||||||
|
|
||||||
async def process_playstatus(playstatus, apikey, rc, app, web_session, categories):
|
async def process_playstatus(playstatus, apikey, rc, web_session, categories, atv):
|
||||||
if playstatus.device_state == playstatus.device_state.Playing and app.identifier == "com.google.ios.youtube":
|
if playstatus.device_state == playstatus.device_state.Playing and atv.metadata.app.identifier == "com.google.ios.youtube":
|
||||||
vid_id = await get_vid_id(playstatus.title, playstatus.artist, apikey, web_session)
|
vid_id = await get_vid_id(playstatus.title, playstatus.artist, apikey, web_session)
|
||||||
print(vid_id)
|
print(vid_id)
|
||||||
segments, duration = await get_segments(vid_id, web_session, categories)
|
segments, duration = await get_segments(vid_id, web_session, categories)
|
||||||
|
|||||||
Reference in New Issue
Block a user