Example #1
0
def getopentypes(existingtypes, arttype):
    keys = [exact for exact in sorted(existingtypes, key=natural_sort)
        if arttype_matches_base(arttype, exact)]
    missing = []
    nextstart = 0
    for count in xrange(100):
        if not keys:
            nextstart = count
            break
        exact = format_arttype(arttype, count)
        if exact in keys:
            keys.remove(exact)
        else:
            missing.append(exact)
    return missing, nextstart
Example #2
0
 def getextra(self, path, exacttypes, thumbs=False):
     arttype = 'thumb' if thumbs else 'fanart'
     extradir = 'extrathumbs' if thumbs else 'extrafanart'
     sep = '\\' if '\\' in path else '/'
     missing, nextno = getopentypes(exacttypes, arttype)
     path += extradir + sep
     _, files = xbmcvfs.listdir(path)
     files.sort(key=natural_sort)
     result = {}
     for filename in files:
         check_filename = filename.lower()
         if not check_filename.endswith(('.jpg', '.png', '.gif')):
             continue
         popped = missing.pop(0) if missing else None
         nexttype = popped if popped else format_arttype(arttype, nextno)
         result[nexttype] = self.buildimage(path + filename, extradir + sep + filename)
         if not popped:
             nextno += 1
     return result