Fribb / MyAnimeList.bundle

Plex Media Server Metadata Agent for MyAnimeList.net
148 stars 15 forks source link

unknown url type while the main Cover should be requested. #15

Closed Fribb closed 4 years ago

Fribb commented 4 years ago

when the Agent is trying to get the main cover from the show from the API the following exception occurs

2020-01-11 22:54:42,968 (7f5e5cfb9700) :  CRITICAL (agentkit:1091) - Exception in the update function of agent named 'MyAnimeList.net Agent', called with guid 'net.fribbtastic.coding.plex.myanimelist://38481?lang=en' (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 "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/MyAnimeList.bundle/Contents/Code/__init__.py", line 171, in update
    self.updateTvShow(metadata, media, lang)
  File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/MyAnimeList.bundle/Contents/Code/__init__.py", line 87, in updateTvShow
    AGENT_MYANIMELIST.getData(metadata, "tvshow", media)
  File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/MyAnimeList.bundle/Contents/Code/myanimelist.py", line 163, in getData
    response = urllib2.urlopen(request, context=ssl.SSLContext(ssl.PROTOCOL_SSLv23))
  File "/usr/lib/plexmediaserver/Resources/Python/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/plexmediaserver/Resources/Python/lib/python2.7/urllib2.py", line 421, in open
    protocol = req.get_type()
  File "/usr/lib/plexmediaserver/Resources/Python/lib/python2.7/urllib2.py", line 283, in get_type
    raise ValueError, "unknown url type: %s" % self.__original
ValueError: unknown url type: 

It seems that the API has an image_url JSONValue but is an empty string. The Agent only checks for availability and NoneType and therefore thinks it is a valid URL and tries to get a response through urllib2 which then creates the exception.