stigger / trakt-for-appletv

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

Hostname issues #5

Closed DeeeeLAN closed 4 years ago

DeeeeLAN commented 4 years ago

Hi,

I can successfully authenticate with trakt, but immediately after, I get this error. I also get it on subsequent launches when it is loading the saved authentication. I made sure my /etc/hosts file had $HOSTNAME assigned to 127.0.0.1. Any other suggestions?

# python3.6 ./tvscrobbler.py 
./tvscrobbler.py:20: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  config = yaml.load(open('config.yml', 'r'))
Task exception was never retrieved
future: <Task finished coro=<BaseEventLoop.create_connection() done, defined at /usr/local/lib/python3.6/asyncio/base_events.py:697> exception=gaierror(8, 'hostname nor servname provided, or not known')>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/base_events.py", line 750, in create_connection
    infos = f1.result()
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] hostname nor servname provided, or not known

Here is the output of the dns-sd command:

$ dns-sd -B _mediaremotetv._tcp local
Browsing for _mediaremotetv._tcp.local
DATE: ---Wed 10 Jul 2019---
21:55:47.076  ...STARTING...
Timestamp     A/R    Flags  if Domain               Service Type         Instance Name
21:55:47.077  Add        2   5 local.               _mediaremotetv._tcp. Living Room

Additionally, nmap shows the Apple TV host/port as open.

stigger commented 4 years ago

Pushed a new commit, could you please check, whether it fixes the problem for you?

DeeeeLAN commented 4 years ago

That looks like it worked. It asked for a code and displayed on the Apple TV. I hit a few errors after that step though. The first time I ran:

# python tvscrobbler.py 
tvscrobbler.py:21: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  config = yaml.load(open('config.yml', 'r'))
Enter code displayed by Apple TV: 6631
Exception in callback ScrobblingRemoteProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)
handle: <Handle ScrobblingRemoteProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/events.py", line 145, in _run
    self._callback(*self._args)
  File "/root/trakt-for-appletv/scrobbling.py", line 51, in connection_made
    super().connection_made(transport)
  File "/root/trakt-for-appletv/media_remote.py", line 48, in connection_made
    pairing(socket, self.config['device_info'])
  File "/root/trakt-for-appletv/pairing.py", line 137, in pairing
    proof = parsed[kTLVType_Proof]
KeyError: b'\x04'
Exception in callback _SelectorSocketTransport._read_ready()
handle: <Handle _SelectorSocketTransport._read_ready()>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/events.py", line 145, in _run
    self._callback(*self._args)
  File "/usr/local/lib/python3.6/asyncio/selector_events.py", line 721, in _read_ready
    self._protocol.data_received(data)
  File "/root/trakt-for-appletv/media_remote.py", line 75, in data_received
    decrypted = self.decrypt(data)
  File "/root/trakt-for-appletv/media_remote.py", line 35, in decrypt
    res, self.input_nonce = self.do_encryption_operation(self.input_key.decrypt, data, self.input_nonce)
AttributeError: 'NoneType' object has no attribute 'decrypt'

Then I killed it and tried again. They are different the second time for some reason:

# python tvscrobbler.py 
tvscrobbler.py:21: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  config = yaml.load(open('config.yml', 'r'))
Enter code displayed by Apple TV: 2753
Exception in callback ScrobblingRemoteProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)
handle: <Handle ScrobblingRemoteProtocol.connection_made(<_SelectorSoc...e, bufsize=0>>)>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/events.py", line 145, in _run
    self._callback(*self._args)
  File "/root/trakt-for-appletv/scrobbling.py", line 51, in connection_made
    super().connection_made(transport)
  File "/root/trakt-for-appletv/media_remote.py", line 48, in connection_made
    pairing(socket, self.config['device_info'])
  File "/root/trakt-for-appletv/pairing.py", line 157, in pairing
    cha_cha_poly = ChaCha20Poly1305(x)
  File "/root/trakt-for-appletv/lib/python3.6/site-packages/cryptography/hazmat/primitives/ciphers/aead.py", line 21, in __init__
    exceptions._Reasons.UNSUPPORTED_CIPHER
cryptography.exceptions.UnsupportedAlgorithm: ChaCha20Poly1305 is not supported by this version of OpenSSL
Exception in callback _SelectorSocketTransport._read_ready()
handle: <Handle _SelectorSocketTransport._read_ready()>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/events.py", line 145, in _run
    self._callback(*self._args)
  File "/usr/local/lib/python3.6/asyncio/selector_events.py", line 721, in _read_ready
    self._protocol.data_received(data)
  File "/root/trakt-for-appletv/media_remote.py", line 75, in data_received
    decrypted = self.decrypt(data)
  File "/root/trakt-for-appletv/media_remote.py", line 35, in decrypt
    res, self.input_nonce = self.do_encryption_operation(self.input_key.decrypt, data, self.input_nonce)
AttributeError: 'NoneType' object has no attribute 'decrypt'