ZeroQI / YouTube-Agent.bundle

Plex Metadata Agent for Movies and TV Series libraries
452 stars 43 forks source link

Handle no dislike count in video data #91

Closed micahmo closed 2 years ago

micahmo commented 2 years ago

As announced here, YouTube video dislikes will be removed from API responses started 13 Dec. Sure enough, today I started noticing failures in YouTube-Agent due to this change.

2021-12-14 12:43:17,798 (14ff9da3fb38) :  CRITICAL (agentkit:1095) - Exception in the update function of agent named 'YouTubeSeries', called with guid 'com.plexapp.agents.youtube://youtube|[REDACTED]?lang=xn' (most recent call last):
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-c43dc0277/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/agentkit.py", line 1093, in _update
    agent.update(obj, media, lang, **kwargs)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/YouTube-Agent.bundle/Contents/Code/__init__.py", line 556, in update
    def update (self, metadata, media, lang, force ):  Update (metadata, media, lang, force,  False)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/YouTube-Agent.bundle/Contents/Code/__init__.py", line 531, in Update
    episode.rating                = 10*float(json_video_details['statistics']['likeCount'])/(float(json_video_details['statistics']['dislikeCount'])+float(json_video_details['statistics']['likeCount']));  Log('[ ] rating:   "{}"'.format(episode.rating))
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-c43dc0277/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 108, in <lambda>
    _getitem_           = lambda x, y: x.__getitem__(y),
KeyError: 'dislikeCount'

This PR attempts to handle the cases where the dislike count is no longer available.