JordyAlkema / Youtube-DL-Agent.bundle

A plex metadata agent for Youtube-DL downloads
119 stars 14 forks source link

Removal of dislikes appears to have broken the "average rating" key in the metadata. #12

Open jacksonbrink opened 2 years ago

jacksonbrink commented 2 years ago

Symptom: When adding new videos, the metadata was not being matched properly, even on refresh

Logs When checking the com.plexapp.agents.youtube-dl.log, I was seeing the following error: 2021-12-30 20:13:12,367 (7f36b7868b38) : CRITICAL (agentkit:1095) - Exception in the update function of agent named 'Youtube-DL', called with guid 'com.plexapp.agents.youtube-dl://youtube-dl|%2Fdata%2Fmedia%2Fyoutube%2FWendover%20Productions%2FSeason%2001%2FWendover%20Productions_S01E00027_The%20News%20You%20Missed%20in%202021%2C%20From%20Every%20Country%20in%20the%20World%20%28Part%201%29%2Emkv|7963fd455125d10d?lang=en' (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-DL-Agent.bundle/Contents/Code/__init__.py", line 60, in update def UpdateEpisodes(): File "/usr/lib/plexmediaserver/Resources/Plug-ins-c43dc0277/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/threadkit.py", line 233, in _parallelize_decorator f(*args, **kwargs) File "/config/Library/Application Support/Plex Media Server/Plug-ins/Youtube-DL-Agent.bundle/Contents/Code/__init__.py", line 98, in UpdateEpisodes if data['average_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: 'average_rating'

I knew I had seen that error before when a video I downloaded had no dislikes, so I commented out the lines:

if data['average_rating']: episode.rating = (data['average_rating'] * 2)

The scanner is now able to retrieve the metadata (albeit without a rating, but that's YouTube's fault.

Suggested Fix: Removal of average rating, or modifying it to reflect whatever value YouTube actually provides now.