home-assistant-libs / pychromecast

Library for Python 3 to communicate with the Google Chromecast.
MIT License
2.52k stars 378 forks source link

Not working with updated modules ('str' object has no attribute 'cast_type') #743

Closed Entretoize closed 12 months ago

Entretoize commented 1 year ago

I'm trying this simple code:

import time
import pychromecast

cast = pychromecast.Chromecast('192.168.1.86')
# Start worker thread and wait for cast device to be ready
cast.wait()
print(cast.device)

print(cast.status)

mc = cast.media_controller
mc.play_media('http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4', 'video/mp4')
mc.block_until_active()

print(mc.status)

mc.pause()
time.sleep(1)
mc.play()

If I run it on a up to date python I get:

Traceback (most recent call last):
  File "/home/pi/welcome.py", line 5, in <module>
    cast = pychromecast.Chromecast('192.168.1.86')
  File "/home/pi/.local/lib/python3.9/site-packages/pychromecast/__init__.py", line 269, in __init__
    if not cast_info.cast_type:
AttributeError: 'str' object has no attribute 'cast_type'

But if I do:

pip install PyChromecast==1.0.3 zeroconf==0.19.1 protobuf==3.20.0

Then everything works fine.

Entretoize commented 12 months ago

Updating everything (pip, libs...) solved the issue, not a bug.