예제 #1
0
 def get_exact_images(self, mediaitem):
     if not mediatypes.generatethumb(mediaitem.mediatype):
         return {}
     path = get_movie_path_list(mediaitem.file)[0]
     if path.endswith('.iso'):
         return {}
     return {'thumb': self.build_video_thumbnail(path)}
예제 #2
0
def can_saveartwork(mediaitem):
    if not (settings.albumartwithmediafiles and mediaitem.file \
            and mediaitem.mediatype in (mediatypes.ALBUM, mediatypes.SONG)):
        if find_central_infodir(mediaitem):
            return True
    if not mediaitem.file:
        return False
    path = utils.get_movie_path_list(mediaitem.file)[0] \
        if mediaitem.mediatype == mediatypes.MOVIE else mediaitem.file
    if path.startswith(blacklisted_protocols) or mediaitem.borked_filename:
        return False
    return True
예제 #3
0
    def get_exact_images(self, mediaitem):
        path = mediaitem.file
        paths = get_movie_path_list(path)
        result = {}
        sep = get_pathsep(path)
        path = os.path.dirname(paths[0]) + sep
        havespecific = []
        for dirname, moviefile in (os.path.split(p) for p in paths):
            dirname += sep
            check_moviebase = os.path.splitext(moviefile)[0].lower()
            dirs, files = xbmcvfs.listdir(dirname)
            for filename in files:
                check_filename = filename.lower()
                if not check_filename.endswith(ARTWORK_EXTS):
                    continue
                imagefile = os.path.splitext(check_filename)[0]
                specific = False
                if '-' in imagefile:
                    firstbit, imagefile = imagefile.rsplit('-', 1)
                    if firstbit != check_moviebase:
                        continue
                    specific = True
                if not imagefile.isalnum() or len(
                        imagefile) > ARTTYPE_MAXLENGTH:
                    continue
                arttype = imagefile
                if settings.identify_alternatives and arttype in self.alttypes.keys(
                ):
                    arttype = self.alttypes[arttype]
                    if arttype in result.keys():
                        continue
                if specific or arttype not in havespecific:
                    result[arttype] = self.buildimage(dirname + filename,
                                                      filename)
                if specific:
                    havespecific.append(arttype)

            if dirs:
                if 'extrafanart' in dirs:
                    result.update(self.getextra(path, result.keys()))
                if 'extrathumbs' in dirs:
                    result.update(self.getextra(path, result.keys(), True))

        return result
예제 #4
0
def build_artwork_basepath(mediaitem, arttype):
    if settings.albumartwithmediafiles and mediaitem.file \
            and mediaitem.mediatype in (mediatypes.ALBUM, mediatypes.SONG):
        path = os.path.splitext(mediaitem.file)[0]
    else:
        path = find_central_infodir(mediaitem)
    if not path:
        if not mediaitem.file:
            return ''
        path = utils.get_movie_path_list(mediaitem.file)[0] \
            if mediaitem.mediatype == mediatypes.MOVIE else mediaitem.file
        if path.startswith(blacklisted_protocols):
            return ''
        path = os.path.splitext(path)[0]

    sep = utils.get_pathsep(path)
    path, basename = os.path.split(path)
    path += sep
    use_basefilename = mediaitem.mediatype in (mediatypes.EPISODE, mediatypes.SONG) \
        or mediaitem.mediatype == mediatypes.MOVIE and settings.savewith_basefilename \
        or mediaitem.mediatype == mediatypes.MUSICVIDEO and settings.savewith_basefilename_mvids \
        or mediaitem.mediatype == mediatypes.MOVIESET and basename and not settings.setartwork_subdirs
    if settings.identify_alternatives and _saveextrafanart(
            mediaitem.mediatype, arttype):
        path += 'extrafanart' + sep
    elif use_basefilename:
        path += basename + '-'

    def snum(num):
        return '-specials' if num == 0 else '-all' if num == -1 else '{0:02d}'.format(
            num)

    if mediaitem.mediatype == mediatypes.SEASON:
        path += 'season{0}-{1}'.format(snum(mediaitem.season), arttype)
    elif arttype.startswith('season.'):
        _, num, sarttype = arttype.split('.')
        path += 'season{0}-{1}'.format(snum(int(num)), sarttype)
    else:
        path += arttype
    return path
예제 #5
0
    def get_exact_images(self, mediaitem):
        paths = get_movie_path_list(mediaitem.file)
        paths = [os.path.splitext(p)[0] + '.nfo' for p in paths]
        paths.append(os.path.dirname(paths[0]) + '/movie.nfo')

        artlist = None
        for nfopath in paths:
            root = read_nfofile(nfopath)
            if root is not None and root.find('art') is not None:
                artlist = root.find('art')
                break

        if artlist is None:
            return {}

        result = {}
        for artelement in artlist:
            arttype = artelement.tag.lower()
            url = artelement.text.strip()
            if arttype.isalnum() and url:
                result[arttype] = self.build_resultimage(url, arttype)
        return result