stigger / trakt-for-appletv

Trakt.tv scrobbler for Apple TV
49 stars 7 forks source link

'MrpProtocol' object has no attribute 'add_listener' #21

Open avnigo opened 2 years ago

avnigo commented 2 years ago

Hi @stigger, I was excited to come across your repo, thanks for sharing!

After pairing on tvOS 15, I get an AttributeError as follows when I try to run ./tvscrobbler.py:

ready!
Traceback (most recent call last):
  File "trakt-for-appletv/./tvscrobbler.py", line 32, in <module>
    asyncio.run(launch(ScrobblingRemoteProtocol(load_config())))
  File "miniconda3/envs/pipes/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "miniconda3/envs/pipes/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
    return future.result()
  File "trakt-for-appletv/./tvscrobbler.py", line 25, in launch
    await tv_protocol.connect(atv)
  File "trakt-for-appletv/scrobbling.py", line 61, in connect
    protocol.add_listener(self.message_received, ProtocolMessage.SET_STATE_MESSAGE)
AttributeError: 'MrpProtocol' object has no attribute 'add_listener'

At first I thought it had to do with tvOS 15 tunneling AirPlay over MRP, but it looks like it's authenticated correctly, and I see you had already added support for tvOS 15.

After actually looking at the error, it really does seem that MrpProtocol found below has no add_listener attribute in pyatv.protocols.mrp.protocol.MrpProtocol:

https://github.com/stigger/trakt-for-appletv/blob/40817b0dc251cbddc21618e53bbe3eae901c35fc/scrobbling.py#L58-L64

Am I missing something obvious? I'm not sure if the pyatv dependency requires a more specific version than you listed, but I also haven't found anything including add_listener in their commit history either.

After spending a while on this, I figured the solution might be very simple, but I'm not that familiar with pyatv, so I'd very much appreciate any help. Thanks!

stigger commented 2 years ago

Indeed, looks like pyatv introduced an incompatibility in the version 0.9.7. Please try some older versions, 0.9.1 works fine for me.

avnigo commented 2 years ago

Just tried pyatv v0.9.1 and can confirm it works great! I'll add that to my requirements.txt for future reference. Thanks for the help!

postlund commented 2 years ago

These are private APIs and thus can change at any time as FYI.