XBMC Community Forum
"script.watchlist failed" on every entry to home screen - Printable Version

+- XBMC Community Forum (http://forum.xbmc.org)
+-- Forum: Help and Support (/forumdisplay.php?fid=33)
+--- Forum: Skin Help and Support (/forumdisplay.php?fid=67)
+---- Forum: XeeBo (/forumdisplay.php?fid=140)
+---- Thread: "script.watchlist failed" on every entry to home screen (/showthread.php?tid=125424)



"script.watchlist failed" on every entry to home screen - lkraav - 2012-03-13 10:52

I'm seeing this in logs:

Code:
20:14:53 T:2844781424    INFO: -->Python script returned the following error<--
20:14:53 T:2844781424   ERROR: Error Type: <type 'exceptions.KeyError'>
20:14:53 T:2844781424   ERROR: Error Contents: ('fanart',)
20:14:53 T:2844781424   ERROR: Traceback (most recent call last):
                                              File "/secure/home/media/.xbmc/addons/script.watchlist/default.py", line 588, in <module>
                                                Main()
                                              File "/secure/home/media/.xbmc/addons/script.watchlist/default.py", line 33, in __init__
                                                self._fetch_info()
                                              File "/secure/home/media/.xbmc/addons/script.watchlist/default.py", line 58, in _fetch_info
                                                self._fetch_tvshows()
                                              File "/secure/home/media/.xbmc/addons/script.watchlist/default.py", line 127, in _fetch_tvshows
                                                item = [tvshow['tvshowid'], tvshow['thumbnail'], tvshow['studio'], tvshow['label'], tvshow['fanart'], []]
                                            KeyError: ('fanart',)
20:14:53 T:2844781424    INFO: -->End of Python script error report<--

Running xbmc-pvr-odk68 build from 14 days ago. Who is the culprit here, Xeebo or watchlist?


RE: "script.watchlist failed" on every entry to home screen - Martijn - 2012-03-13 10:59

Wacthlist.

Can you check what version of watchlists you have and post here including full Debug Log


RE: "script.watchlist failed" on every entry to home screen - petpetpet - 2012-05-13 11:48

Code:
def _fetch_tvshows( self ):
        self.tvshows = []
        # fetch all episodes in one query
        json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"properties": ["title", "playcount", "plot", "season", "episode", "showtitle", "thumbnail", "file", "lastplayed", "rating"], "sort": {"method": "episode"} }, "id": 1}' )
        json_query = unicode(json_query, 'utf-8', errors='ignore')
        json_response = simplejson.loads(json_query)
        if json_response['result'].has_key('episodes'):
            json_response = json_response['result']['episodes']
            # our list is sorted by episode number, secondary we sort by tvshow title (itertools.groupy needs contiguous items) and split it into seperate lists for each tvshow
            [b]episodes = [list(group) for key,group in itertools.groupby(sorted(json_response, key=itemgetter('showtitle')), key=itemgetter('showtitle'))][/b]
        # fetch all tvshows, sorted by title
        json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": {"properties": ["title", "studio", "thumbnail", "fanart"], "sort": {"method": "title"}}, "id": 1}')
        json_query = unicode(json_query, 'utf-8', errors='ignore')
        json_response = simplejson.loads(json_query)
        if json_response['result'].has_key('tvshows'):
            for count, tvshow in enumerate(json_response['result']['tvshows']):
                item = [tvshow['tvshowid'], tvshow['thumbnail'], tvshow['studio'], tvshow['title'], tvshow['fanart'], []]
                [b]for episodelist in episodes:[/b]
                    if episodelist[0]['showtitle'] == item[3]:
                        item[5] = episodelist
                        break
                self.tvshows.append(item)
        log("tv show list: %s items" % len(self.tvshows))

The 'episodes' variable is only created inside the
if json_response['result'].has_key('episodes'):
binding, while it's being referenced in the for loop later on in the function.

Im not terribly familiar with python's variable binding scope, but I am quite sure that if the JSON response doesn't have a key called 'episodes' then this function is going to break when it gets to the for loop.

This can be syntactically fixed by simply putting
episodes = []
near the top of the function, however I'm not sure if that's a valid use case.


RE: "script.watchlist failed" on every entry to home screen - Martijn - 2012-05-13 12:04

and if your JSON request doesn't have any episodes that means your library is empty.

On the other hand it shouldn't create any failure so perhaps best to catch those errors.
Never had any problem with this so far


RE: "script.watchlist failed" on every entry to home screen - petpetpet - 2012-05-13 12:32

right, so it probably wasn't tested against a fresh install with an empty TV Show library.


Re: RE: "script.watchlist failed" on every entry to home screen - Martijn - 2012-05-13 12:41

(2012-05-13 12:32)petpetpet Wrote:  right, so it probably wasn't tested against a fresh install with an empty TV Show library.

Nope Big Grin
Will get that looked at.


RE: "script.watchlist failed" on every entry to home screen - ronie - 2012-05-13 14:03

(2012-05-13 11:48)petpetpet Wrote:  The 'episodes' variable is only created inside the
if json_response['result'].has_key('episodes'):
binding, while it's being referenced in the for loop later on in the function.

cheer mate, i'll fix that right away :-)

though technically speaking, if you don't have any episodes, you won't have any tv shows either,
so you'll never get to the for loop, i think?

either way, it won't hurt to define an empty episodes list at the start.


RE: "script.watchlist failed" on every entry to home screen - petpetpet - 2012-05-13 14:44

Not sure. I got the error when I upgraded from 11.0 stable to the latest nightly this morning. There appears to either be something wrong with that nightly, or something wrong with the way I upgraded because it seems to be unable to query my episodes from the DB (so my tv shows show up as empty) even though it can clearly find the files and downloads the artwork etc for them. Therefore, I didn't really have an empty fresh install. So it may well be the case that this function doesn't get called at all with an empty library, but it looks to me like it would.

Regardless, it's usually a bad idea™ to put the first declaration of a variable inside a conditional binding if it being used outside of that binding.


RE: "script.watchlist failed" on every entry to home screen - Chris! - 2012-10-22 21:29

Sorry to thread resurrect but i'm having trouble since upgrading to openelec 2.0
I'm using the latest xeebo in hitcher's repository and get the "watchlist.script" failed.

I'm sure it's something simple that i've done but I can't figure it out, can someone help?

debug log: http://pastebin.com/vZ8BEgra

Thanks
Chris!


RE: "script.watchlist failed" on every entry to home screen - Martijn - 2012-10-22 21:31

(2012-10-22 21:29)Chris! Wrote:  Sorry to thread resurrect but i'm having trouble since upgrading to openelec 2.0
I'm using the latest xeebo in hitcher's repository and get the "watchlist.script" failed.

I'm sure it's something simple that i've done but I can't figure it out, can someone help?

debug log: http://pastebin.com/vZ8BEgra

Thanks
Chris!

That's because you couldn't read.

You installed 12.0.1 which isn't for Eden *which was clearly stated)
Remove the script from the Addons folder and install the correct one
http://mirrors.xbmc.org/addons/eden/script.watchlist/


RE: "script.watchlist failed" on every entry to home screen - Chris! - 2012-10-22 22:02

Sorry, when I re-installed xeebo from the repo watchlist didn't work.
Then I couldn't find the new watch list script (probably more stupidity on my part) so I used the one I had from before - then forgot where I got that from.

All makes sense now, thanks for pointing me to the right script.
I don't always do the cleverest of things.