コード例 #1
0
    def _moveToThemeFolder(self, directory):
        log("moveToThemeFolder: path = %s" % directory)

        # Handle the case where we have a disk image
        if (os_path_split(directory)[1]
                == 'VIDEO_TS') or (os_path_split(directory)[1] == 'BDMV'):
            directory = os_path_split(directory)[0]

        dirs, files = list_dir(directory)
        for aFile in files:
            m = re.search(Settings.getThemeFileRegEx(directory), aFile,
                          re.IGNORECASE)
            if m:
                srcpath = os_path_join(directory, aFile)
                log("fetchAllMissingThemes: Found match: %s" % srcpath)
                targetpath = os_path_join(directory,
                                          Settings.getThemeDirectory())
                # Make sure the theme directory exists
                if not dir_exists(targetpath):
                    try:
                        xbmcvfs.mkdir(targetpath)
                    except:
                        log(
                            "fetchAllMissingThemes: Failed to create directory: %s"
                            % targetpath, True, LOGERROR)
                        break
                else:
                    log("moveToThemeFolder: directory already exists %s" %
                        targetpath)
                # Add the filename to the path
                targetpath = os_path_join(targetpath, aFile)
                if not xbmcvfs.rename(srcpath, targetpath):
                    log("moveToThemeFolder: Failed to move file from %s to %s"
                        % (srcpath, targetpath))
コード例 #2
0
    def _getAllFilesInDirectory(self, baseDir, includeSubDirs=True):
        videoFiles = []
        dirs, files = list_dir(baseDir)

        # Get the list of files that are to be excluded
        collectionCtrl = CollectSets()
        disabledVideos = collectionCtrl.getDisabledVideos()
        del collectionCtrl

        # Get all the files in the current directory
        for vidFile in files:
            # Check if this file is excluded
            if vidFile in disabledVideos:
                log("Ignoring disabled screensaver video %s" % vidFile)
                continue

            fullPath = os_path_join(baseDir, vidFile)
            videoFiles.append(fullPath)

        # Now check each directory
        if includeSubDirs and Settings.isFolderNested():
            for aDir in dirs:
                fullPath = os_path_join(baseDir, aDir)
                dirContents = self._getAllFilesInDirectory(fullPath)
                videoFiles = videoFiles + dirContents

        return videoFiles
コード例 #3
0
    def _getAllFilesInDirectory(self, baseDir, includeSubDirs=True):
        videoFiles = []
        dirs, files = list_dir(baseDir)

        # Get the list of files that are to be excluded
        collectionCtrl = CollectSets()
        disabledVideos = collectionCtrl.getDisabledVideos()
        del collectionCtrl

        # Get all the files in the current directory
        for vidFile in files:
            # Check if this file is excluded
            if vidFile in disabledVideos:
                log("Ignoring disabled screensaver video %s" % vidFile)
                continue

            fullPath = os_path_join(baseDir, vidFile)
            videoFiles.append(fullPath)

        # Now check each directory
        if includeSubDirs and Settings.isFolderNested():
            for aDir in dirs:
                fullPath = os_path_join(baseDir, aDir)
                dirContents = self._getAllFilesInDirectory(fullPath)
                videoFiles = videoFiles + dirContents

        return videoFiles
コード例 #4
0
ファイル: plugin.py プロジェクト: kodibrasil/KodiBrasil
    def _moveToThemeFolder(self, directory):
        log("moveToThemeFolder: path = %s" % directory)

        # Handle the case where we have a disk image
        if (os_path_split(directory)[1] == 'VIDEO_TS') or (os_path_split(directory)[1] == 'BDMV'):
            directory = os_path_split(directory)[0]

        dirs, files = list_dir(directory)
        for aFile in files:
            m = re.search(Settings.getThemeFileRegEx(directory), aFile, re.IGNORECASE)
            if m:
                srcpath = os_path_join(directory, aFile)
                log("fetchAllMissingThemes: Found match: %s" % srcpath)
                targetpath = os_path_join(directory, Settings.getThemeDirectory())
                # Make sure the theme directory exists
                if not dir_exists(targetpath):
                    try:
                        xbmcvfs.mkdir(targetpath)
                    except:
                        log("fetchAllMissingThemes: Failed to create directory: %s" % targetpath, True, xbmc.LOGERROR)
                        break
                else:
                    log("moveToThemeFolder: directory already exists %s" % targetpath)
                # Add the filename to the path
                targetpath = os_path_join(targetpath, aFile)
                if not xbmcvfs.rename(srcpath, targetpath):
                    log("moveToThemeFolder: Failed to move file from %s to %s" % (srcpath, targetpath))
コード例 #5
0
    def _doesThemeExist(self,
                        directory,
                        checkParent=False,
                        incAudioThemes=True,
                        incVideoThemes=True):
        log("doesThemeExist: Checking directory: %s" % directory)
        # Check for custom theme directory
        if Settings.isThemeDirEnabled():
            themeDir = os_path_join(directory, Settings.getThemeDirectory())
            # Check if this directory exists
            if not dir_exists(themeDir):
                workingPath = directory
                # If the path currently ends in the directory separator
                # then we need to clear an extra one
                if (workingPath[-1] == os.sep) or (workingPath[-1]
                                                   == os.altsep):
                    workingPath = workingPath[:-1]
                # If not check to see if we have a DVD VOB
                if (os_path_split(workingPath)[1]
                        == 'VIDEO_TS') or (os_path_split(workingPath)[1]
                                           == 'BDMV'):
                    # Check the parent of the DVD Dir
                    themeDir = os_path_split(workingPath)[0]
                    themeDir = os_path_join(themeDir,
                                            Settings.getThemeDirectory())
            directory = themeDir

        # Check to see if we need to check the parent directory
        if checkParent:
            directory = os_path_split(directory)[0]

        # check if the directory exists before searching
        if dir_exists(directory):
            # Generate the regex
            audioOnly = False
            videoOnly = False
            if not incAudioThemes:
                videoOnly = True
            if not incVideoThemes:
                audioOnly = True

            themeFileRegEx = Settings.getThemeFileRegEx(audioOnly=audioOnly,
                                                        videoOnly=videoOnly)

            dirs, files = list_dir(directory)
            for aFile in files:
                m = re.search(themeFileRegEx, aFile, re.IGNORECASE)
                if m:
                    log("doesThemeExist: Found match: " + aFile)
                    return True
        # Check if an NFO file exists
        nfoFileName = os_path_join(directory, "tvtunes.nfo")
        if xbmcvfs.exists(nfoFileName):
            log("doesThemeExist: Found match: " + nfoFileName)
            return True

        return False
コード例 #6
0
    def _getVideoLocation(self, folder, filename):
        log("VideoScreensaverPlugin: Checking if %s already downloaded to %s" % (filename, folder))
        videoLocation = os_path_join(folder, filename)
        if xbmcvfs.exists(videoLocation):
            return videoLocation

        # Check nested directories
        if Settings.isFolderNested():
            dirs, files = list_dir(folder)
            for aDir in dirs:
                fullPath = os_path_join(folder, aDir)
                filePath = self._getVideoLocation(fullPath, filename)
                if filePath not in [None, ""]:
                    return filePath
        return None
コード例 #7
0
ファイル: plugin.py プロジェクト: kodibrasil/KodiBrasil
    def _doesThemeExist(self, directory, checkParent=False, incAudioThemes=True, incVideoThemes=True):
        log("doesThemeExist: Checking directory: %s" % directory)
        # Check for custom theme directory
        if Settings.isThemeDirEnabled():
            themeDir = os_path_join(directory, Settings.getThemeDirectory())
            # Check if this directory exists
            if not dir_exists(themeDir):
                workingPath = directory
                # If the path currently ends in the directory separator
                # then we need to clear an extra one
                if (workingPath[-1] == os.sep) or (workingPath[-1] == os.altsep):
                    workingPath = workingPath[:-1]
                # If not check to see if we have a DVD VOB
                if (os_path_split(workingPath)[1] == 'VIDEO_TS') or (os_path_split(workingPath)[1] == 'BDMV'):
                    # Check the parent of the DVD Dir
                    themeDir = os_path_split(workingPath)[0]
                    themeDir = os_path_join(themeDir, Settings.getThemeDirectory())
            directory = themeDir

        # Check to see if we need to check the parent directory
        if checkParent:
            directory = os_path_split(directory)[0]

        # check if the directory exists before searching
        if dir_exists(directory):
            # Generate the regex
            audioOnly = False
            videoOnly = False
            if not incAudioThemes:
                videoOnly = True
            if not incVideoThemes:
                audioOnly = True

            themeFileRegEx = Settings.getThemeFileRegEx(audioOnly=audioOnly, videoOnly=videoOnly)

            dirs, files = list_dir(directory)
            for aFile in files:
                m = re.search(themeFileRegEx, aFile, re.IGNORECASE)
                if m:
                    log("doesThemeExist: Found match: " + aFile)
                    return True
        # Check if an NFO file exists
        nfoFileName = os_path_join(directory, "tvtunes.nfo")
        if xbmcvfs.exists(nfoFileName):
            log("doesThemeExist: Found match: " + nfoFileName)
            return True

        return False
コード例 #8
0
    def _getVideoLocation(self, folder, filename):
        log("VideoScreensaverPlugin: Checking if %s already downloaded to %s" %
            (filename, folder))
        videoLocation = os_path_join(folder, filename)
        if xbmcvfs.exists(videoLocation):
            return videoLocation

        # Check nested directories
        if Settings.isFolderNested():
            dirs, files = list_dir(folder)
            for aDir in dirs:
                fullPath = os_path_join(folder, aDir)
                filePath = self._getVideoLocation(fullPath, filename)
                if filePath not in [None, ""]:
                    return filePath
        return None
コード例 #9
0
    def _getThemeFiles(self, directory, extensionOnly=False):
        # First read from the NFO file if it exists
        nfoRead = NfoReader(directory, self.debug_logging_enabled)
        themeFiles = nfoRead.getThemeFiles()

        # Get the theme directories that are referenced and process the data in them
        for nfoDir in nfoRead.getThemeDirs():
            # Do not want the theme keyword if looking at an entire directory
            themeFiles = themeFiles + self._getThemeFiles(nfoDir, True)

        del nfoRead

        themeRegex = Settings.getThemeFileRegEx(directory, extensionOnly, self.audioOnly)
        log("ThemeFiles: Searching %s for %s" % (directory, themeRegex), self.debug_logging_enabled)

        # Make sure that the path does not point to a plugin, as we are checking the
        # file-system for themes, not plugins. This can be the case with Emby
        if "plugin://" in directory:
            log("ThemeFiles: Plugin paths do not support theme files: %s" % directory, self.debug_logging_enabled)
        else:
            # check if the directory exists before searching
            if dir_exists(directory):
                dirs, files = list_dir(directory)
                for aFile in files:
                    m = re.search(themeRegex, aFile, re.IGNORECASE)
                    if m:
                        path = os_path_join(directory, aFile)
                        log("ThemeFiles: Found match: %s" % path, self.debug_logging_enabled)
                        # Add the theme file to the list
                        themeFiles.append(path)
                # Check to see if any themes were found, and if not see if we should try
                # and use a trailer file instead
                if (len(themeFiles) < 1) and (not self.audioOnly) and (not extensionOnly) and Settings.useTrailers():
                    trailerRegEx = Settings.getTrailerFileRegEx()
                    for aFile in files:
                        m = re.search(trailerRegEx, aFile, re.IGNORECASE)
                        if m:
                            path = os_path_join(directory, aFile)
                            log("ThemeFiles: Found trailer match: %s" % path, self.debug_logging_enabled)
                            # Add the trailer file to the list
                            themeFiles.append(path)

        return themeFiles