stigger / trakt-for-appletv

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

Python 3.8: Socket error via ScrobblingRemoteProtocol #16

Closed jensb89 closed 2 years ago

jensb89 commented 3 years ago

Just wanted to try out your script and got the following error. Authentification with trakt seemed to work, but then something seems wrong with the ScrobblingRemoteProtocol. There is also no pairing info on the appleTV.

I'm using python 3.8.5 via pyenv in a virtualenv on Mac OS 10.14.6 (Mojave). TvOs is 13.4.8

Here is the error:

$ python3 ./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('data/config.yml', 'r')) Navigate to https://trakt.tv/oauth/authorize?client_id=dc705f550f50706bdd7bd55db120235cc68899dbbfb4fbc171384c1c1d30d7d4&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code Authorization code: ****** 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 "/Users/jens/.pyenv/versions/3.8.5/lib/python3.8/asyncio/events.py", line 81, in _run self._context.run(self._callback, *self._args) File "/Users/jens/Desktop/traktatv/ta/scrobbling.py", line 59, in connection_made super().connection_made(transport) File "/Users/jens/Desktop/traktatv/ta/media_remote.py", line 42, in connection_made socket.setblocking(True) File "/Users/jens/.pyenv/versions/3.8.5/lib/python3.8/asyncio/trsock.py", line 197, in setblocking raise ValueError( ValueError: setblocking(): transport sockets cannot be blocking

I was also trying with Docker, but it seems in Docker python-zeroconf finds no services at all. There it just stops after the trakt connection...

"dns-sd -B _mediaremotetv._tcp local" on the host machine finds the appleTV. Also in Python the command print("\n".join(ZeroConfServiceTypes.find())) on the host machine shows a list of available services.

Any ideas? Would be awesome to get your script running :)

stigger commented 3 years ago

Hi, please try with python 3.7

jensb89 commented 3 years ago

With python 3.7.0 it seems to work. Paring seemed to work and it says "ready" now. Will try scrobbling some Netflix :) Thanks for your fast reply.

jensb89 commented 3 years ago

Update: Scrobbling works too, thanks for the script, awesome work!

Had to change the handle_netflix function though, because my aTV is in german. For anyone interested, in Germany the match function needs to be changed to: match = re.match('^St\. (\\d\\d?): Flg\. (\\d\\d?) (.*)', self.now_playing_metadata.title)

I guess I leave the issue open as the script does not work with python 3.8? Or close it, your choice ;)

stigger commented 3 years ago

Glad it worked. Yes, let's leave it open for now, I'll look at the compatibility problem at some point.

Regarding Netflix: keep in mind that currently the script uses Duckduckgo to look up Netflix tv show names, and Duckduckgo has quite aggressive rate limiting, so if you watch several relatively short episodes in a row, scrobbling might stop working for some time.

jensb89 commented 3 years ago

Good to know, thx 👍

intrepidsilence commented 3 years ago

Will this be fixed to work with the new python versions (3.8x)?

stigger commented 3 years ago

Probably.

stigger commented 2 years ago

This issue is obsolete.