Esempio n. 1
0
def recyclefile(filename):
    firstdir = utils.parent_dir(filename)
    directory = TEMP_DIR
    pathsep = utils.get_pathsep(directory)
    if firstdir in ('extrafanart', 'extrathumbs'):
        directory += utils.parent_dir(os.path.dirname(filename)) + pathsep
    directory += firstdir
    if not xbmcvfs.exists(directory):
        xbmcvfs.mkdirs(directory)
    recycled_filename = directory + pathsep + os.path.basename(filename)
    if not xbmcvfs.copy(filename, recycled_filename):
        raise FileError(L(CANT_WRITE_TO_FILE).format(recycled_filename))
Esempio n. 2
0
    def get_exact_images(self, mediaitem):
        paths = (mediaitem.file, find_central_infodir(mediaitem))
        if settings.albumartwithmediafiles:
            paths = (paths[1], paths[0])
        result = {}
        for path in paths:
            if not path:
                continue
            _, files = xbmcvfs.listdir(path)
            for filename in files:
                check_filename = filename.lower()
                if not check_filename.endswith(ARTWORK_EXTS):
                    continue
                arttype = os.path.splitext(check_filename)[0]
                if not arttype.isalnum() or len(arttype) > ARTTYPE_MAXLENGTH:
                    continue
                if settings.identify_alternatives and arttype in self.alttypes.keys(
                ):
                    arttype = self.alttypes[arttype]
                    if arttype in result.keys():
                        continue
                result[arttype] = self.buildimage(path + filename, filename,
                                                  path != mediaitem.file)

        for disc in sorted(mediaitem.discfolders.keys()):
            path = mediaitem.discfolders[disc]
            _, files = xbmcvfs.listdir(path)
            for filename in files:
                check_filename = filename.lower()
                if not check_filename.endswith(ARTWORK_EXTS):
                    continue
                arttype = os.path.splitext(check_filename)[0]
                if not arttype.isalnum() or len(arttype) > ARTTYPE_MAXLENGTH:
                    continue
                if settings.identify_alternatives and arttype in self.alttypes.keys(
                ):
                    arttype = self.alttypes[arttype]
                parentdir = parent_dir(path) + get_pathsep(path)
                if arttype == 'discart':
                    if 'discart' not in result:
                        result['discart'] = self.buildimage(
                            path + filename, parentdir + filename)
                    if not disc:
                        continue
                    arttype += str(disc)
                if arttype in result:
                    continue
                result[arttype] = self.buildimage(path + filename,
                                                  parentdir + filename)

        return result
Esempio n. 3
0
def extrafanart_name_used(path, localfiles):
    return utils.parent_dir(path) == 'extrafanart' and path in localfiles