Dingmatt / AMSA

A Plex anime agent using TVDB and AniDB data
GNU General Public License v3.0
261 stars 7 forks source link

API Exception in `functions.py` #17

Closed tmartin357 closed 4 years ago

tmartin357 commented 4 years ago

AMSA crashes when a Plex API call is made

Log:

2020-09-05 07:02:22,280 (15d0) :  CRITICAL (core:574) - Exception in the search function of agent named 'Anime Multi Source Agent', called with keyword arguments {...} (most recent call last):
  File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-a78fef9a9\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\api\agentkit.py", line 1011, in _search
    agent.search(*f_args, **f_kwargs)
  File "C:\Users\user\AppData\Local\Plex Media Server\Plug-ins\Amsa_Test.bundle\Contents\Code\__init__.py", line 41, in search
    common.RefreshData()
  File "C:\Users\user\AppData\Local\Plex Media Server\Plug-ins\Amsa_Test.bundle\Contents\Code\common.py", line 63, in RefreshData
    scudlee.TitleTree()
  File "C:\Users\user\AppData\Local\Plex Media Server\Plug-ins\Amsa_Test.bundle\Contents\Code\scudlee.py", line 13, in TitleTree
    pTitleTree = XMLFromURL(constants.ANIDB_TITLES, os.path.splitext(os.path.basename(constants.ANIDB_TITLES))[0], "", CACHE_1HOUR * 24 * 2, 60)
  File "C:\Users\user\AppData\Local\Plex Media Server\Plug-ins\Amsa_Test.bundle\Contents\Code\functions.py", line 111, in XMLFromURL
    result = XML.ElementFromString(result)
  File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-a78fef9a9\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\api\parsekit.py", line 300, in ElementFromString
    check_size(string, max_size)
  File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-a78fef9a9\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\api\parsekit.py", line 23, in check_size
    raise Framework.exceptions.APIException("Data of size %d is greater than the maximum size %d" % (len(data), max_size))
APIException: (2103, 'Data of size 5248463 is greater than the maximum size 5242880')

Changing line 111 in Plug-ins\Amsa_Test.bundle\Contents\Code\functions.py to this seems to fix the problem: result = XML.ElementFromString(result, max_size=5248463)

tmartin357 commented 4 years ago

Correction: Changing the max_size to something like 9999999 seems to band-aid the problem.

Dingmatt commented 4 years ago

This issue was also addressed in the latest hotfix (v1.0.3 Hotfix), where we swapped to lxml for xml parsing. It's nice to think we've now got so much anime available that it's overflowing code