mirror of
https://github.com/dmunozv04/iSponsorBlockTV.git
synced 2026-01-31 14:51:15 +03:00
Merge pull request #49 from Shraymonks/tvOS-detect
Check tvOS instead of specific atv models
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import pyatv
|
||||
import json
|
||||
import asyncio
|
||||
from pyatv.const import DeviceModel
|
||||
from pyatv.const import OperatingSystem
|
||||
import sys
|
||||
import aiohttp
|
||||
import asyncio
|
||||
@@ -28,32 +28,28 @@ async def find_atvs(loop):
|
||||
atvs = []
|
||||
for i in devices:
|
||||
# Only get Apple TV's
|
||||
if i.device_info.model in [
|
||||
DeviceModel.Gen4,
|
||||
DeviceModel.Gen4K,
|
||||
DeviceModel.AppleTV4KGen2,
|
||||
]:
|
||||
# if i.device_info.model in [DeviceModel.AppleTV4KGen2]: #FOR TESTING
|
||||
if input("Found {}. Do you want to add it? (y/n) ".format(i.name)) == "y":
|
||||
if (
|
||||
i.device_info.operating_system == OperatingSystem.TvOS
|
||||
and input(f"Found {i.name}. Do you want to add it? (y/n) ") == "y"
|
||||
):
|
||||
identifier = i.identifier
|
||||
|
||||
identifier = i.identifier
|
||||
pairing = await pyatv.pair(
|
||||
i, loop=loop, protocol=pyatv.Protocol.AirPlay
|
||||
)
|
||||
await pairing.begin()
|
||||
if pairing.device_provides_pin:
|
||||
pin = await _read_input(loop, "Enter PIN on screen: ")
|
||||
pairing.pin(pin)
|
||||
|
||||
pairing = await pyatv.pair(
|
||||
i, loop=loop, protocol=pyatv.Protocol.AirPlay
|
||||
await pairing.finish()
|
||||
if pairing.has_paired:
|
||||
creds = pairing.service.credentials
|
||||
atvs.append(
|
||||
{"identifier": identifier, "airplay_credentials": creds}
|
||||
)
|
||||
await pairing.begin()
|
||||
if pairing.device_provides_pin:
|
||||
pin = await _read_input(loop, "Enter PIN on screen: ")
|
||||
pairing.pin(pin)
|
||||
|
||||
await pairing.finish()
|
||||
if pairing.has_paired:
|
||||
creds = pairing.service.credentials
|
||||
atvs.append(
|
||||
{"identifier": identifier, "airplay_credentials": creds}
|
||||
)
|
||||
print("Pairing successful")
|
||||
await pairing.close()
|
||||
print("Pairing successful")
|
||||
await pairing.close()
|
||||
return atvs
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user