stigger / trakt-for-appletv

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

KeyError: 'netflix', KeyError: 'amazon' #6

Closed DeeeeLAN closed 4 years ago

DeeeeLAN commented 5 years ago

While working to resolve my hostname issues, I was able to get it successfully connected on a different machine. However, when watching things on Netflix and amazon, I get the following errors:

Exception in thread Thread-32:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pi/Documents/trakt-for-appletv/scrobbling.py", line 90, in <lambda>
    Thread(target=lambda: inner()).start()
  File "/home/pi/Documents/trakt-for-appletv/scrobbling.py", line 87, in inner
    self.app_handlers[self.valid_player](operation, progress)
  File "/home/pi/Documents/trakt-for-appletv/scrobbling.py", line 177, in handle_netflix
    title = self.get_netflix_title(self.now_playing_metadata.contentIdentifier)
  File "/home/pi/Documents/trakt-for-appletv/scrobbling.py", line 185, in get_netflix_title
    known = self.config['netflix']['titles'].get(contentIdentifier)
KeyError: 'netflix'
Exception in thread Thread-55:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pi/Documents/trakt-for-appletv/scrobbling.py", line 90, in <lambda>
    Thread(target=lambda: inner()).start()
  File "/home/pi/Documents/trakt-for-appletv/scrobbling.py", line 87, in inner
    self.app_handlers[self.valid_player](operation, progress)
  File "/home/pi/Documents/trakt-for-appletv/scrobbling.py", line 197, in handle_amazon
    title, season, episode = self.get_amazon_details(self.now_playing_metadata.contentIdentifier)
  File "/home/pi/Documents/trakt-for-appletv/scrobbling.py", line 204, in get_amazon_details
    known = self.config['amazon']['titles'].get(contentIdentifier)
KeyError: 'amazon'
DeeeeLAN commented 5 years ago

Adding empty dictionaries to the config seems to have fixed it:

netflix:
  titles: {}
amazon:
  titles: {}

After adding that, I started an episode on Netflix and it showed up in the dictionary and no errors printed in the shell. I still don't see it in my trakt history though.

stigger commented 5 years ago

Does it show up on trakt as “currently playing” during playback?

On 12. Jul 2019, at 05:50, DeeeeLAN notifications@github.com wrote:

Adding empty dictionaries to the config seems to have fixed it:

netflix: titles: {} amazon: titles: {} After adding that, I started an episode on Netflix and it showed up in the dictionary and no errors printed in the shell. I still don't see it in my trakt history though.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

DeeeeLAN commented 5 years ago

It looks like history updates when I complete an episode, but nothing gets sent to update the status during an episode. But completed episodes are indeed showing up in trakt.

stigger commented 5 years ago

Correct, during playback only the "Now playing" events are being set. When you're stopping the playback, the episode will be marked as watched if the current position is over a certain threshold.

DeeeeLAN commented 5 years ago

Okay great. It sounds like all you need to do is either add the empty dictionaries to the config file, or add code to check if they exist and create them if they don’t (probably the better choice).