postlund / pyatv

A client library for Apple TV and AirPlay devices
https://pyatv.dev
MIT License
827 stars 87 forks source link

my computer c'ant Authentificate #2348

Open ShadowHedgehog76 opened 3 months ago

ShadowHedgehog76 commented 3 months ago

What do you need help with?

i writed this code but its retuning this

code : `import asyncio import sys from pyatv import connect, scan from pyatv.const import Protocol import asyncio import pyautogui from PIL import Image import io import numpy as np import pyatv

async def print_what_is_playing(): print("Discovering devices on network...") loop = asyncio.get_event_loop() atvs = await scan(loop=loop)

if not atvs:
    print("No devices found")
    return

for i in atvs:
    print(i.name, " : ", i.address)

# Connect to the first device found
atv = await connect(atvs[0], protocol=Protocol.DMAP, loop=loop)

screenshot = pyautogui.screenshot()

# Convert the screenshot to a NumPy array
screenshot_np = np.array(screenshot)

# Convert the NumPy array to a PIL Image object
screenshot_pil = Image.fromarray(screenshot_np)

buffer = io.BytesIO()
screenshot_pil.save(buffer, format='JPEG')
buffer.seek(0)
metadata = {'title': 'Screenshot'}

try:
    # Play the YouTube video
    url = "/home/user/BigBuckBunny.mp4"
    await atv.stream.play_url(url)
    await asyncio.sleep(60)
finally:
    # Always close the connection
    atv.close()

if name == "main":

Setup event loop and connect

loop = asyncio.get_event_loop()
loop.run_until_complete(print_what_is_playing())`

result : Traceback (most recent call last): File "c:\Users\kaeli\Bureau\bordel\code\python\apple.py", line 52, in <module> loop.run_until_complete(print_what_is_playing()) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2032.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "c:\Users\kaeli\Bureau\bordel\code\python\apple.py", line 43, in print_what_is_playing await atv.stream.play_url(url) File "C:\Users\kaeli\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pyatv\core\facade.py", line 356, in play_url await self.relay("play_url")(url, **kwargs) File "C:\Users\kaeli\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pyatv\protocols\airplay\__init__.py", line 136, in play_url return await self._play_task ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\kaeli\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pyatv\protocols\airplay\player.py", line 66, in play_url raise exceptions.AuthenticationError(f"status code: {resp.code}") pyatv.exceptions.AuthenticationError: status code: 404