当前位置: 首页>>代码示例>>Python>>正文


Python Settings.getScreensaverFolder方法代码示例

本文整理汇总了Python中resources.lib.settings.Settings.getScreensaverFolder方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.getScreensaverFolder方法的具体用法?Python Settings.getScreensaverFolder怎么用?Python Settings.getScreensaverFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在resources.lib.settings.Settings的用法示例。


在下文中一共展示了Settings.getScreensaverFolder方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _getContextMenu

# 需要导入模块: from resources.lib.settings import Settings [as 别名]
# 或者: from resources.lib.settings.Settings import getScreensaverFolder [as 别名]
    def _getContextMenu(self, videoItem):
        ctxtMenu = []

        # Check if the file has already been downloaded
        if self._getVideoLocation(Settings.getScreensaverFolder(), videoItem['filename']) in [None, ""]:
            # If not already exists, add a download option
            cmd = self._build_url({'mode': 'download', 'name': videoItem['name'], 'filename': videoItem['filename'], 'primary': videoItem['primary']})
            ctxtMenu.append((ADDON.getLocalizedString(32013), 'RunPlugin(%s)' % cmd))
            # If not already exists, add a download option
            cmd = self._build_url({'mode': 'play', 'name': videoItem['name'], 'filename': videoItem['primary']})
            ctxtMenu.append((ADDON.getLocalizedString(32019), 'RunPlugin(%s)' % cmd))
        else:
            # If already exists then add a play option
            cmd = self._build_url({'mode': 'play', 'name': videoItem['name'], 'filename': videoItem['filename']})
            ctxtMenu.append((ADDON.getLocalizedString(32015), 'RunPlugin(%s)' % cmd))
            # If already exists then add a delete option
            cmd = self._build_url({'mode': 'delete', 'name': videoItem['name'], 'filename': videoItem['filename']})
            ctxtMenu.append((ADDON.getLocalizedString(32014), 'RunPlugin(%s)' % cmd))

            # Check if we need a menu item to enable and disable the videos
            if videoItem['enabled']:
                cmd = self._build_url({'mode': 'enable', 'disable': 'true', 'filename': videoItem['filename']})
                ctxtMenu.append((ADDON.getLocalizedString(32017), 'RunPlugin(%s)' % cmd))
            else:
                cmd = self._build_url({'mode': 'enable', 'disable': 'false', 'filename': videoItem['filename']})
                ctxtMenu.append((ADDON.getLocalizedString(32018), 'RunPlugin(%s)' % cmd))

        return ctxtMenu
开发者ID:one9howard,项目名称:screensaver.video,代码行数:30,代码来源:plugin.py

示例2: removeCollection

# 需要导入模块: from resources.lib.settings import Settings [as 别名]
# 或者: from resources.lib.settings.Settings import getScreensaverFolder [as 别名]
    def removeCollection(self, name, link):
        if name in [None, ""]:
            return

        collectionCtrl = CollectSets()
        collectionDetails = collectionCtrl.loadCollection(link)

        filesToDelete = []
        # If the file was not processed just don't display anything
        if collectionDetails not in [None, ""]:
            screensaverFolder = Settings.getScreensaverFolder()

            for videoItem in collectionDetails['videos']:
                # If theme exists we need to check if we want to delete it
                if screensaverFolder not in [None, ""]:
                    videoLocation = os_path_join(screensaverFolder, videoItem['filename'])

                    log("VideoScreensaverPlugin: Checking if %s already downloaded to %s" % (videoItem['filename'], videoLocation))
                    if xbmcvfs.exists(videoLocation):
                        filesToDelete.append(videoLocation)

        # If there are possible files to delete, then prompt the user to see if we should
        if len(filesToDelete) > 0:
            needDelete = xbmcgui.Dialog().yesno(ADDON.getLocalizedString(32005), ADDON.getLocalizedString(32086))

            if needDelete:
                for vidFile in filesToDelete:
                    xbmcvfs.delete(vidFile)

        # Now remove the actual collection
        collectionCtrl.removeCustomCollection(name)
        del collectionCtrl

        # Now reload the screen to reflect the change
        xbmc.executebuiltin("Container.Refresh")
开发者ID:one9howard,项目名称:screensaver.video,代码行数:37,代码来源:plugin.py

示例3: play

# 需要导入模块: from resources.lib.settings import Settings [as 别名]
# 或者: from resources.lib.settings.Settings import getScreensaverFolder [as 别名]
    def play(self, name, filename):
        log("VideoScreensaverPlugin: Playing %s" % name)

        destination = filename
        if not filename.startswith('http'):
            screensaverFolder = Settings.getScreensaverFolder()
            destination = self._getVideoLocation(screensaverFolder, filename)

        # Check to see if there is already a file present
        if destination not in [None, ""]:
            player = xbmc.Player()
            player.play(destination)
            del player
        else:
            log("VideoScreensaverPlugin: Files does not exists %s" % destination)
开发者ID:one9howard,项目名称:screensaver.video,代码行数:17,代码来源:plugin.py

示例4: delete

# 需要导入模块: from resources.lib.settings import Settings [as 别名]
# 或者: from resources.lib.settings.Settings import getScreensaverFolder [as 别名]
    def delete(self, name, filename):
        log("VideoScreensaverPlugin: Deleting %s" % name)

        screensaverFolder = Settings.getScreensaverFolder()
        destination = self._getVideoLocation(screensaverFolder, filename)

        # Check to see if there is already a file present
        if destination not in [None, ""]:
            deleteFile = xbmcgui.Dialog().yesno(ADDON.getLocalizedString(32005), ADDON.getLocalizedString(32014), name)
            if deleteFile:
                log("VideoScreensaverPlugin: Removing existing file %s" % destination)
                xbmcvfs.delete(destination)
                # Now reload the screen to reflect the change
                xbmc.executebuiltin("Container.Refresh")
        else:
            log("VideoScreensaverPlugin: Files does not exists %s" % destination)
开发者ID:one9howard,项目名称:screensaver.video,代码行数:18,代码来源:plugin.py

示例5: viewCollection

# 需要导入模块: from resources.lib.settings import Settings [as 别名]
# 或者: from resources.lib.settings.Settings import getScreensaverFolder [as 别名]
    def viewCollection(self, name, link):
        log("VideoScreensaverPlugin: %s (%s)" % (name, link))

        collectionCtrl = CollectSets()
        collectionDetails = collectionCtrl.loadCollection(link)
        del collectionCtrl

        # If the file was not processed just don't display anything
        if collectionDetails in [None, ""]:
            return

        screensaverFolder = Settings.getScreensaverFolder()

        for videoItem in collectionDetails['videos']:
            displayName = videoItem['name']
            if videoItem['enabled'] is False:
                displayName = "%s %s" % (ADDON.getLocalizedString(32016), displayName)

            # Create the list-item for this video
            li = xbmcgui.ListItem(displayName, iconImage=videoItem['image'])
            if videoItem['duration'] not in [None, "", 0]:
                li.setInfo('video', {'Duration': videoItem['duration']})

            # Set the background image
#             if videoItem['fanart'] is not None:
#                 li.setProperty("Fanart_Image", videoItem['fanart'])

            # If theme already exists flag it using the play count
            # This will normally put a tick on the GUI
            if screensaverFolder not in [None, ""]:
                if self._getVideoLocation(screensaverFolder, videoItem['filename']) not in [None, ""]:
                    li.setInfo('video', {'PlayCount': 1})

            li.addContextMenuItems(self._getContextMenu(videoItem), replaceItems=True)

            url = self._build_url({'mode': 'download', 'name': videoItem['name'], 'filename': videoItem['filename'], 'primary': videoItem['primary']})

            xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=url, listitem=li, isFolder=False)

        xbmcplugin.endOfDirectory(self.addon_handle)
开发者ID:one9howard,项目名称:screensaver.video,代码行数:42,代码来源:plugin.py

示例6: _getPlaylist

# 需要导入模块: from resources.lib.settings import Settings [as 别名]
# 或者: from resources.lib.settings.Settings import getScreensaverFolder [as 别名]
    def _getPlaylist(self):
        playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
        # Note: The playlist clear option seems to impact all playlist settings,
        # so will remove the repeat settings on a playlist that is currently playing,
        # not just this instance - a bit nasty, but not much we can do about it
        playlist.clear()

        # Check to see if we should be using a video from the schedule
        scheduleEntry = self.scheduler.getScheduleEntry()

        if scheduleEntry != -1:
            # There is an item scheduled, so check to see if the item has actually changed
            if scheduleEntry == self.currentScheduleItem:
                return None
            # Set the entry we are about to play
            self.currentScheduleItem = scheduleEntry
            # Get the actual video file that should be played
            scheduledVideo = self.scheduler.getScheduleVideo(scheduleEntry)
            # Do a quick check to see if the video exists
            if xbmcvfs.exists(scheduledVideo):
                log("Screensaver video for scheduled item %d is: %s" % (scheduleEntry, scheduledVideo))
                playlist.add(scheduledVideo)

        # Check if we are showing all the videos in a given folder
        elif Settings.isFolderSelection():
            videosFolder = Settings.getScreensaverFolder()

            # Check if we are dealing with a Folder of videos
            if videosFolder not in [None, ""]:
                if dir_exists(videosFolder):
                    self.currentScheduleItem = -1
                    files = self._getAllFilesInDirectory(videosFolder)

                    # Check if we are limiting to a single folder per session
                    if Settings.isLimitSessionToSingleCollection():
                        # Select just one file at random
                        singleVideo = random.choice(files)

                        # Check if this file is part of a collection
                        justFilename = (os_path_split(singleVideo))[-1]
                        collectionCtrl = CollectSets()
                        collectionVideos = collectionCtrl.getFilesInSameCollection(justFilename)
                        del collectionCtrl

                        # If it is part of a collection, then limit to only files in
                        # this collection
                        if len(collectionVideos) > 0:
                            log("Screensaver restricting to collection containing %s" % singleVideo)
                            # Check each of the videos to see which are in the collection
                            collectionFileList = []
                            for aFile in files:
                                # Get just the filename
                                aFilename = (os_path_split(aFile))[-1]
                                if aFilename in collectionVideos:
                                    log("Screensaver including collection video %s" % aFile)
                                    collectionFileList.append(aFile)
                                else:
                                    log("Screensaver excluding non collection video %s" % aFile)
                        else:
                            log("Screensaver restricting to directory containing %s" % singleVideo)
                            # Not in a collection, so just gather the files in the same directory
                            # Get the directory that file was part of
                            parentPath = (os_path_split(singleVideo))[0]

                            # Now only select videos from that directory
                            files = self._getAllFilesInDirectory(parentPath, False)

                    # Now shuffle the playlist to ensure that if there are more
                    # than one video a different one starts each time
                    random.shuffle(files)
                    for vidFile in files:
                        log("Screensaver video in directory is: %s" % vidFile)
                        playlist.add(vidFile)
        else:
            # Must be dealing with a single file
            videoFile = Settings.getScreensaverVideo()

            # Check to make sure the screensaver video file exists
            if videoFile not in [None, ""]:
                if xbmcvfs.exists(videoFile):
                    self.currentScheduleItem = -1
                    log("Screensaver video is: %s" % videoFile)
                    playlist.add(videoFile)

        # If there are no videos in the playlist yet, then display an error
        if playlist.size() < 1:
            errorLocation = Settings.getScreensaverVideo()
            if Settings.isFolderSelection():
                errorLocation = Settings.getScreensaverFolder()

            log("No Screensaver file set or not valid %s" % errorLocation)
            cmd = 'Notification("{0}", "{1}", 3000, "{2}")'.format(ADDON.getLocalizedString(32300).encode('utf-8'), errorLocation, ADDON.getAddonInfo('icon'))
            xbmc.executebuiltin(cmd)
            return None

        return playlist
开发者ID:robwebset,项目名称:screensaver.video,代码行数:98,代码来源:screensaver.py

示例7: download

# 需要导入模块: from resources.lib.settings import Settings [as 别名]
# 或者: from resources.lib.settings.Settings import getScreensaverFolder [as 别名]
    def download(self, name, filename, downloadURL):
        log("VideoScreensaverPlugin: Downloading %s" % name)

        tmpdestination = os_path_join(Settings.getTempFolder(), filename)
        destination = os_path_join(Settings.getScreensaverFolder(), filename)

        # Check to see if there is already a file present
        if xbmcvfs.exists(destination):
            useExisting = xbmcgui.Dialog().yesno(ADDON.getLocalizedString(32005), ADDON.getLocalizedString(32301), name, ADDON.getLocalizedString(32302))
            if useExisting:
                # Don't want to overwrite, so nothing to do
                log("Download: Reusing existing video file %s" % destination)
                return
            else:
                log("Download: Removing existing file %s ready for fresh download" % destination)
                xbmcvfs.delete(destination)

        # Create a progress dialog for the  download
        downloadProgressDialog = xbmcgui.DialogProgress()
        downloadProgressDialog.create(ADDON.getLocalizedString(32303), name, filename, destination)

        # Callback method to report progress
        def _report_hook(count, blocksize, totalsize):
            percent = int(float(count * blocksize * 100) / totalsize)
            downloadProgressDialog.update(percent, name, filename, destination)
            if downloadProgressDialog.iscanceled():
                log("Download: Operation cancelled")
                raise ValueError('Download Cancelled')

        try:
            log("Download: Using server: %s" % downloadURL)

            # Now retrieve the actual file
            fp, h = urllib.urlretrieve(downloadURL, tmpdestination, _report_hook)
            log(h)

            # Check to make sure that the file created downloaded correctly
            st = xbmcvfs.Stat(tmpdestination)
            fileSize = st.st_size()
            log("Download: Size of file %s is %d" % (tmpdestination, fileSize))
            # Check for something that has a size greater than zero (in case some OSs do not
            # support looking at the size), but less that 1,000,000 (As all our files are
            # larger than that
            if (fileSize > 0) and (fileSize < 1000000):
                log("Download: Detected that file %s did not download correctly as file size is only %d" % (downloadURL, fileSize))
                xbmcgui.Dialog().ok(ADDON.getLocalizedString(32005), ADDON.getLocalizedString(32306))
            else:
                log("Download: Copy from %s to %s" % (tmpdestination, destination))
                copy = xbmcvfs.copy(tmpdestination, destination)
                if copy:
                    log("Download: Copy Successful")
                else:
                    log("Download: Copy Failed")
            xbmcvfs.delete(tmpdestination)
        except ValueError:
            # This was a cancel by the user, so remove any file that may be part downloaded
            if xbmcvfs.exists(tmpdestination):
                xbmcvfs.delete(tmpdestination)
        except:
            log("Download: Theme download Failed!!!", xbmc.LOGERROR)
            log("Download: %s" % traceback.format_exc(), xbmc.LOGERROR)

        # Make sure the progress dialog has been closed
        downloadProgressDialog.close()
        # Now reload the screen to reflect the change
        xbmc.executebuiltin("Container.Refresh")
开发者ID:one9howard,项目名称:screensaver.video,代码行数:68,代码来源:plugin.py


注:本文中的resources.lib.settings.Settings.getScreensaverFolder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。