MilhouseVH / texturecache.py

Utility script to manage the XBMC texture cache
http://forum.xbmc.org/showthread.php?tid=158373
GNU General Public License v2.0
181 stars 34 forks source link

Crash when trying to Prune #52

Closed ifschleife closed 6 years ago

ifschleife commented 6 years ago

Hi there. I'm using the script from the AUR package, version 2.4.5. When trying to run texturecache P I get this back trace:

Traceback (most recent call last):1...                              
  File "/usr/bin/texturecache", line 8622, in <module>
    main(sys.argv[1:])
  File "/usr/bin/texturecache", line 8452, in main
    pruneCache(remove_nonlibrary_artwork=True)
  File "/usr/bin/texturecache", line 6542, in pruneCache
    (libraryFiles, mediaFiles) = getAllFiles(keyFunction=getKeyFromFilename)
  File "/usr/bin/texturecache", line 6851, in getAllFiles
    episodedata = jcomms.getDataProxy("episodes", REQUEST, uniquecast=UCAST)
  File "/usr/bin/texturecache", line 3252, in getDataProxy
    data = self.chunkedLoad(mediatype, request, trim_cast_thumbs, idname=idname, silent=silent, uniquecast=uniquecast)
  File "/usr/bin/texturecache", line 3291, in chunkedLoad
    data = self.sendJSON(request, idname)
  File "/usr/bin/texturecache", line 2298, in sendJSON
    for m in self.parseResponse(udata):
  File "/usr/bin/texturecache", line 2391, in parseResponse
    idx = _w(data, 0).end()
TypeError: cannot use a string pattern on a bytes-like object

I'm running kodi via the kodi-standalone-service, so my kodi home is at /var/lib/kodi. I've copied the example config to ~/.config/texturecache.cfg and set the userdata folder accordingly (/var/lib/kodi/.kodi/userdata). When I run texturecache config I see the userdata folder is correct but when I try texturecache P I can see that the script parses through my library but then crashes with the trace I pasted.

Let me know if there is more info I can supply. Thanks.

MilhouseVH commented 6 years ago

Can you run

texturecache P @logfile=/tmp/tc.log @logfile.verbose=yes

and then - once it fails - upload /tmp/tc.log to a pastebin site, or if it's too large, zip it and upload it to a download site (Dropbox, Google Drive etc.), then paste the link so I can try and reproduce?

I'm not sure what the example config is on Arch but the script should work without one, so it might be worth trying without it.

You only need to set the userdata property when the script needs direct file system access (which isn't the case, most of the time - and certainly not for P) and the userdata folder is in a non-standard location (your location is supported, so should be found automatically without any setting).

What version of Kodi is the client?

ifschleife commented 6 years ago

I tried w/o a config file and it breaks with the same error. So at least I didn't configure it incorrectly. I generated the log which has a size of 7.5MB but it seems to contain some sensitive data, so I don't really want to upload that (I'm not the only user of Kodi). But the last chunk before it fails seems to parse through the tv shows and judging by the links to the thumbnails in the log, the last one before it crashes is MacGyver, of all people. That's kinda funny.

2018-09-23 12:33:24.652767:MainThread: libSeasons.JSON SOCKET REQUEST: [{"method": "VideoLibrary.GetSeasons", "params": {"tvshowid": 10, "sort": {"order": "ascending", "method": "season"}, "properties": ["season", "art"], "limits": {"start": 0, "end": 400}}, "jsonrpc": "2.0", "id": "libSeasons"}]
2018-09-23 12:33:24.691371:MainThread: libSeasons.BUFFER RECEIVED (len 3513)
2018-09-23 12:33:24.691561:MainThread: libSeasons.PARSING JSON DATA: {"id":"libSeasons","jsonrpc":"2.0","result":{"limits":{"end":7,"start":0,"total":7},"seasons":[{"art":{"poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fseasons%2f77847-1.jpg/","season.poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fseasons%2f77847-1.jpg/","tvshow.banner":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fgraphical%2f706-g2.jpg/","tvshow.fanart":"image://http%3a%2f%2fthetvdb.com%2fbanners%2ffanart%2foriginal%2f77847-3.jpg/","tvshow.poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fposters%2f77847-1.jpg/"},"label":"Season 1","season":1,"seasonid":70},{"art":{"poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fseasons%2f77847-2.jpg/","season.poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fseasons%2f77847-2.jpg/","tvshow.banner":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fgraphical%2f706-g2.jpg/","tvshow.fanart":"image://http%3a%2f%2fthetvdb.com%2fbanners%2ffanart%2foriginal%2f77847-3.jpg/","tvshow.poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fposters%2f77847-1.jpg/"},"label":"Season 2","season":2,"seasonid":71},{"art":{"poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fseasons%2f77847-3.jpg/","season.poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fseasons%2f77847-3.jpg/","tvshow.banner":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fgraphical%2f706-g2.jpg/","tvshow.fanart":"image://http%3a%2f%2fthetvdb.com%2fbanners%2ffanart%2foriginal%2f77847-3.jpg/","tvshow.poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fposters%2f77847-1.jpg/"},"label":"Season 3","season":3,"seasonid":72},{"art":{"poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fseasons%2f77847-4.jpg/","season.poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fseasons%2f77847-4.jpg/","tvshow.banner":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fgraphical%2f706-g2.jpg/","tvshow.fanart":"image://http%3a%2f%2fthetvdb.com%2fbanners%2ffanart%2foriginal%2f77847-3.jpg/","tvshow.poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fposters%2f77847-1.jpg/"},"label":"Season 4","season":4,"seasonid":73},{"art":{"poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fseasons%2f77847-5.jpg/","season.poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fseasons%2f77847-5.jpg/","tvshow.banner":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fgraphical%2f706-g2.jpg/","tvshow.fanart":"image://http%3a%2f%2fthetvdb.com%2fbanners%2ffanart%2foriginal%2f77847-3.jpg/","tvshow.poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fposters%2f77847-1.jpg/"},"label":"Season 5","season":5,"seasonid":74},{"art":{"poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fseasons%2f77847-6.jpg/","season.poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fseasons%2f77847-6.jpg/","tvshow.banner":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fgraphical%2f706-g2.jpg/","tvshow.fanart":"image://http%3a%2f%2fthetvdb.com%2fbanners%2ffanart%2foriginal%2f77847-3.jpg/","tvshow.poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fposters%2f77847-1.jpg/"},"label":"Season 6","season":6,"seasonid":75},{"art":{"poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fseasons%2f77847-7.jpg/","season.poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fseasons%2f77847-7.jpg/","tvshow.banner":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fgraphical%2f706-g2.jpg/","tvshow.fanart":"image://http%3a%2f%2fthetvdb.com%2fbanners%2ffanart%2foriginal%2f77847-3.jpg/","tvshow.poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fposters%2f77847-1.jpg/"},"label":"Season 7","season":7,"seasonid":76}]}}
2018-09-23 12:33:24.691644:MainThread: libSeasons.PARSING COMPLETE, elapsed time: 0.000183 seconds
2018-09-23 12:33:24.691687:MainThread: libSeasons.RECEIVED LIMITS: {'end': 7, 'start': 0, 'total': 7}
2018-09-23 12:33:24.691715:MainThread: libSeasons.FINISHED, elapsed time: 0.038914 seconds
2018-09-23 12:33:24.691744:MainThread: Chunk processing: found 7 seasons, retrieving in chunks of 400
2018-09-23 12:33:24.692276:MainThread: libEpisodes.JSON SOCKET REQUEST: [{"method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": 10, "season": 1, "properties": ["cast", "art", "file"], "limits": {"start": 0, "end": 400}}, "jsonrpc": "2.0", "id": "libEpisodes"}]
2018-09-23 12:33:24.714917:MainThread: libEpisodes.BUFFER RECEIVED (len 32768)
2018-09-23 12:33:24.715024:MainThread: libEpisodes.BUFFER RECEIVED (len 2871)
2018-09-23 12:33:24.715133:MainThread: libEpisodes.GENERAL EXCEPTION: cannot use a string pattern on a bytes-like object
ERROR:root:** Terminating due to unexpected exception **
Traceback (most recent call last):
  File "/usr/bin/texturecache", line 8622, in <module>
    main(sys.argv[1:])
  File "/usr/bin/texturecache", line 8452, in main
    pruneCache(remove_nonlibrary_artwork=True)
  File "/usr/bin/texturecache", line 6542, in pruneCache
    (libraryFiles, mediaFiles) = getAllFiles(keyFunction=getKeyFromFilename)
  File "/usr/bin/texturecache", line 6851, in getAllFiles
    episodedata = jcomms.getDataProxy("episodes", REQUEST, uniquecast=UCAST)
  File "/usr/bin/texturecache", line 3252, in getDataProxy
    data = self.chunkedLoad(mediatype, request, trim_cast_thumbs, idname=idname, silent=silent, uniquecast=uniquecast)
  File "/usr/bin/texturecache", line 3291, in chunkedLoad
    data = self.sendJSON(request, idname)
  File "/usr/bin/texturecache", line 2298, in sendJSON
    for m in self.parseResponse(udata):
  File "/usr/bin/texturecache", line 2391, in parseResponse
    idx = _w(data, 0).end()
TypeError: cannot use a string pattern on a bytes-like object

This is the end of the log. Looks like it tries to GetEpisodes but can't parse the result. Is there a way to log the buffer it gets or am I on the wrong track? Anyway, thanks for looking into it. My Kodi version is 17.6 btw.

MilhouseVH commented 6 years ago

Can you email me your MyVideos107.db to neil at nmacleod dot com? Or email me a download link. Thanks.

ifschleife commented 6 years ago

That's very kind of you to offer but I can't send the database around, for the same reason I don't want to upload the full log. It seems pretty much every video/stream ever watched is in that database, crazy. I understand that this makes it probably impossible for you to reproduce and debug the problem. Sorry for making this difficult but thanks for wanting to help :) I have solved my immediate problem (disk full because of 5gb image cache) by moving the cache to a different disk...

MilhouseVH commented 6 years ago

OK, I'm going to close this. If anyone else has the same problem and can provide a database or reproducible test case then I'll investigate further.