ZeroQI / YouTube-Agent.bundle

Plex Metadata Agent for Movies and TV Series libraries
463 stars 44 forks source link

Error in Update Function #35

Closed Fribb closed 4 years ago

Fribb commented 4 years ago

The Agent is downloading date, description and title fine but seems to have troubles downloading the video thumbnail.

2019-12-12 01:07:06,552 (147ef37fb700) : INFO (init:290) - thumb: "https://i.ytimg.com/vi/u4DKKDS4k20/default.jpg" 2019-12-12 01:07:06,553 (147ef37fb700) : CRITICAL (agentkit:1091) - Exception in the update function of agent named 'YouTubeMovie', called with guid 'com.plexapp.agents.youtube://youtube|u4DKKDS4k20|youtube?lang=xn' (most recent call last): File "/usr/lib/plexmediaserver/Resources/Plug-ins-41af4e729/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/agentkit.py", line 1089, 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 484, in update def update (self, metadata, media, lang, force ): Update (metadata, media, lang, force, True) File "/config/Library/Application Support/Plex Media Server/Plug-ins/YouTube-Agent.bundle/Contents/Code/init.py", line 290, in Update Log.Info('[ ] summary: "{}"'.format(Dict(json_channel_details, 'snippet', 'description').replace('\n', '. '))) # File "/usr/lib/plexmediaserver/Resources/Plug-ins-41af4e729/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 108, in getitem = lambda x, y: x.getitem(y), KeyError: 'standard'

ZeroQI commented 4 years ago

After the displaying of the thumb line [199] it seems a call is done to tge same dict using 'standard' key line [200] for the poster and 'standard' is not defined in the JSON. I would need the content of that log and/or the full log as this is all i can do on my phone at tge moment.

Fribb commented 4 years ago

I uploaded the full log file here

Tripletap007 commented 4 years ago

I've noticed this happening every once in a while too...can't find any rhyme or reason to it though. Whenever it fails on the video thumbnail, it also fails on the rating, tags, "director", genres and the year. However the title, summary and originally_available_at do manage to get pulled successfully.

ZeroQI commented 4 years ago

https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&id=u4DKKDS4k20&key=AIzaSyA0Y8hht4n4kvvq9Q_D0KSCwbPxPG_X_lc

"thumbnails": {
 "default": {
  "url": "https://i.ytimg.com/vi/u4DKKDS4k20/default.jpg",
  "width": 120,
  "height": 90
 },
 "medium": {
  "url": "https://i.ytimg.com/vi/u4DKKDS4k20/mqdefault.jpg",
  "width": 320,
  "height": 180
 },
 "high": {
  "url": "https://i.ytimg.com/vi/u4DKKDS4k20/hqdefault.jpg",
  "width": 480,
  "height": 360
 }
},

Need to use Dict(video_details, 'snippet', 'thumbnails', 'default', 'url') or Dict(video_details, 'snippet', 'thumbnails', 'high', 'url') or Dict(video_details, 'snippet', 'thumbnails', 'standard', 'url') on the line calling the 'standard' dict key on thumbnail or powter

Tripletap007 commented 4 years ago

The rest of my stuff matched up now...thanks for the fix!

Fribb commented 4 years ago

changed that in line 445 but still get the error in a different line

Line 200: poster = video_details['snippet']['thumbnails']['standard']['url']; Log('poster: "{}"'.format(thumb))

ZeroQI commented 4 years ago

@Fribb which line?

Fribb commented 4 years ago

While looking through the log files, it seems that happens in different lines

__init__.py, line 257

2020-01-08 00:08:02,020 (149f8a639700) :  CRITICAL (agentkit:1091) - Exception in the update function of agent named 'YouTubeMovie', called with guid 'com.plexapp.agents.youtube://youtube|Toa3Kk1fQkE|youtube?lang=xn' (most recent call last):
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-ac2afe5f8/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/agentkit.py", line 1089, 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 484, in update
    def update (self, metadata, media, lang, force ):  Update (metadata, media, lang, force,  True)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/YouTube-Agent.bundle/Contents/Code/__init__.py", line 257, in Update
    else:  Log.Info("Grouping folder not found or single folder, root: {}, path: {}, Grouping folder: {}, subdirs: {}, reverse_path: {}".format(root, path, os.path.basename(series_root_folder), subfolder_count, reverse_path))
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-ac2afe5f8/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 108, in <lambda>
    _getitem_           = lambda x, y: x.__getitem__(y),
KeyError: 'standard'

__init__.py, line 200

2020-01-07 20:16:13,069 (148bf3bfd700) :  CRITICAL (agentkit:1091) - Exception in the update function of agent named 'YouTubeMovie', called with guid 'com.plexapp.agents.youtube://youtube|_xoMt4H4jjQ|youtube?lang=xn' (most recent call last):
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-ac2afe5f8/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/agentkit.py", line 1089, 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 484, in update
    def update (self, metadata, media, lang, force ):  Update (metadata, media, lang, force,  True)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/YouTube-Agent.bundle/Contents/Code/__init__.py", line 200, in Update
    poster                           = video_details['snippet']['thumbnails']['standard']['url'];                   Log('poster: "{}"'.format(thumb))
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-ac2afe5f8/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 108, in <lambda>
    _getitem_           = lambda x, y: x.__getitem__(y),
KeyError: 'standard'

__init__.py, line 249

2020-01-07 17:07:18,929 (14bbcc85e700) :  CRITICAL (agentkit:1091) - Exception in the update function of agent named 'YouTubeMovie', called with guid 'com.plexapp.agents.youtube://youtube|_xoMt4H4jjQ|youtube?lang=xn' (most recent call last):
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-ac2afe5f8/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/agentkit.py", line 1089, 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 484, in update
    def update (self, metadata, media, lang, force ):  Update (metadata, media, lang, force,  True)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/YouTube-Agent.bundle/Contents/Code/__init__.py", line 249, in Update
    if rx!=SEASON_RX[-1] and len(reverse_path)>=2 and folder==reverse_path[-2]:  season_folder_first = True
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-ac2afe5f8/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 108, in <lambda>
    _getitem_           = lambda x, y: x.__getitem__(y),
KeyError: 'standard'
ZeroQI commented 4 years ago

Plex in unreliable when reporting offending lines.

You need to use Dict(video_details, 'snippet', 'thumbnails', 'default', 'url') or Dict(video_details, 'snippet', 'thumbnails', 'high', 'url') or Dict(video_details, 'snippet', 'thumbnails', 'standard', 'url') on the lines calling the 'standard' dict key (lines 200, 336, 421, 444) instead of video_details['snippet']['thumbnails']['standard']['url'] line 200.

I have submitted a fix to solve. Please reply if issue not resolved.

Fribb commented 4 years ago

You have committed a syntax error on that line.

You added

poster = Dict(video_details, 'snippet', 'thumbnails', 'default', 'url') or Dict(video_details, 'snippet', 'thumbnails', 'high', 'url') or Dict(video_details, 'snippet', 'thumbnails', 'standard', 'url') on the lines calling the 'standard' dict key (lines 200, 336, 421, 444) instead of video_details['snippet']['thumbnails']['standard']['url']; Log('poster: "{}"'.format(thumb))

while it should have been

poster = Dict(video_details, 'snippet', 'thumbnails', 'default', 'url') or Dict(video_details, 'snippet', 'thumbnails', 'high', 'url') or Dict(video_details, 'snippet', 'thumbnails', 'standard', 'url'); Log('poster: "{}"'.format(thumb))

with that, I have no errors. Yet. I will monitor this and let you know if I get anything else.

ZeroQI commented 4 years ago

Thanks for letting me know. That should be fixed now