Recently I developed a plugin and I'm a complete noob in Python, but it still kinda works, but some users get errors that I can not reproduce.
So, in my plugin I am creating a VideoClipObject and filling its arguments I pass thumb a url to the file, or a resource, to determine which is which i have this procedure:
def GetThumb(thumb = ''):
if thumb.startswith('http'):
return thumb
elif thumb <> '':
return R(thumb)
else:
return R('icon-default.png')
and then another procedure thats is repsosible for VideoClipObjects looks like that:
@route(PREFIX + '/createvideoclipobject')
def CreateVideoClipObject(url, title, thumb, container = False):
vco = VideoClipObject(
key = Callback(CreateVideoClipObject, url = url, title = title, thumb = thumb, container = True),
url = url,
title = title,
thumb = GetThumb(thumb),
items = [...]
)
...
where thumb is a string argument with value like 'image.png' or 'http://somewhere.com/image.png' or just empty string ('').
Full source code is accessible on github.
Anyone has any ideas why is the error occurring?
2013-12-10 21:52:22,177 (130c) : CRITICAL (core:561) - Exception (most recent call last):
File "C:\Users\PlexServerUser\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\components\runtime.py", line 840, in handle_request
result = f(**d)
File "C:\Users\PlexServerUser\AppData\Local\Plex Media Server\Plug-ins\IPTV.bundle\Contents\Code\__init__.py", line 106, in CreateVideoClipObject
thumb = GetThumb(thumb),
File "C:\Users\PlexServerUser\AppData\Local\Plex Media Server\Plug-ins\IPTV.bundle\Contents\Code\__init__.py", line 157, in GetThumb
if thumb.startswith('http'):
AttributeError: 'NoneType' object has no attribute 'startswith'