예제 #1
0
    def _getExtrasDirFiles(self,
                           basepath,
                           exitOnFirst=False,
                           noExtrasDirNeeded=False):
        # If a custom path, then don't looks for the Extras directory
        if noExtrasDirNeeded or Settings.isCustomPathEnabled():
            extrasDir = basepath
        else:
            # Add the name of the extras directory to the end of the path
            extrasDir = os_path_join(basepath, Settings.getExtrasDirName())
        log("VideoExtrasFinder: Checking existence for %s" % extrasDir)
        extras = []
        # Check if the extras directory exists
        if dir_exists(extrasDir):
            # list everything in the extras directory
            dirs, files = xbmcvfs.listdir(extrasDir)
            for filename in files:
                log("VideoExtrasFinder: found file: %s" % filename)
                # Check each file in the directory to see if it should be skipped
                if not self._shouldSkipFile(filename):
                    extrasFile = os_path_join(extrasDir, filename)
                    extraItem = ExtrasItem(extrasDir,
                                           extrasFile,
                                           extrasDb=self.extrasDb,
                                           defaultFanArt=self.defaultFanArt)
                    extras.append(extraItem)
                    # Check if we are only looking for the first entry
                    if exitOnFirst is True:
                        break
            # Now check all the directories in the "Extras" directory
            # Need to see if they contain a DVD image
            for dirName in dirs:
                log("VideoExtrasFinder: found directory: %s" % dirName)
                # Check each directory to see if it should be skipped
                if not self._shouldSkipFile(dirName):
                    extrasSubDir = os_path_join(extrasDir, dirName)
                    # Check to see if this sub-directory is a DVD directory by checking
                    # to see if there is VIDEO_TS directory
                    videoTSDir = os_path_join(extrasSubDir, 'VIDEO_TS')
                    # Also check for Bluray
                    videoBluRayDir = os_path_join(extrasSubDir, 'BDMV')
                    if dir_exists(videoTSDir) or dir_exists(videoBluRayDir):
                        extraItem = ExtrasItem(
                            extrasDir,
                            extrasSubDir,
                            extrasDb=self.extrasDb,
                            defaultFanArt=self.defaultFanArt)
                        extras.append(extraItem)

                    # Check if we are only looking for the first entry
                    if exitOnFirst is True:
                        break

        return extras
예제 #2
0
    def _getExtrasFiles(self, filepath, filename, exitOnFirst=False):
        extras = []
        extrasTag = Settings.getExtrasFileTag()

        # If there was no filename given, nothing to do
        if (filename is None) or (filename == "") or (extrasTag == ""):
            return extras
        directory = filepath
        dirs, files = xbmcvfs.listdir(directory)

        for aFile in files:
            if not self._shouldSkipFile(aFile) and (
                    extrasTag in aFile
            ) and aFile.startswith(os.path.splitext(filename)[0] + extrasTag):
                extrasFile = os_path_join(directory, aFile)
                extraItem = ExtrasItem(directory,
                                       extrasFile,
                                       True,
                                       extrasDb=self.extrasDb,
                                       defaultFanArt=self.defaultFanArt)
                extras.append(extraItem)
                # Check if we are only looking for the first entry
                if exitOnFirst is True:
                    break
        return extras
예제 #3
0
    def loadExtras(self, path, filename, exitOnFirst=False):
        # First check to see if there is a videoextras.nfo file
        extradirs, extras = self._getNfoInfo(path)

        if (len(extradirs) > 0) or (len(extras) > 0):
            # There are some extras defined via an NFO file
            extrasList = []
            # Read the extras files from the directories
            for aDir in extradirs:
                extrasList = extrasList + self.findExtras(
                    aDir, filename, exitOnFirst, noExtrasDirNeeded=True)
                # Don't look for more than one if we are only checking for existence of an extra
                if exitOnFirst:
                    break

            # For each of the files, get the directory and filename split
            # and create the extrasItem
            for anExtraFile in extras:
                extraItem = ExtrasItem(os_path_split(anExtraFile)[0],
                                       anExtraFile,
                                       extrasDb=self.extrasDb,
                                       defaultFanArt=self.defaultFanArt)
                extrasList.append(extraItem)
                # Don't look for more than one if we are only checking for existence of an extra
                if exitOnFirst:
                    break

            # Sort the list before returning
            extrasList.sort()
            return extrasList

        # Check if the files are stored in a custom path
        if Settings.isCustomPathEnabled():
            filename = None
            path = self._getCustomPathDir(path)

            if path is None:
                return []
            else:
                log("VideoExtrasFinder: Searching in custom path %s" % path)
        return self.findExtras(
            path,
            filename,
            exitOnFirst,
            noExtrasDirNeeded=Settings.isCustomPathEnabled())