Пример #1
0
    def _update_content_folders(self):
        """
        This updates media manager's content folders. This method is
        executed when content.conf has been updated. If folders are added
        we need to index them. If folders are removed, we need to remove
        them from the cache and also from FileSystemObeserver.
        """
        updated_video_folders = self.config.media_folders
        updated_music_folders = self.config.media_folders
        updated_image_folders = self.config.media_folders

        # Handle image folder changes
        current_images = set(self.image_folders)
        updated_images = set(updated_image_folders)
        removed_images = current_images - updated_images
        new_images = updated_images - current_images
        self.image_folders = updated_image_folders

        image_cache = ImageCache()
        for element in removed_images:
            image_cache.removeDirectory(element)

        self._index_images(list(new_images))

        # Handle music folder changes
        current_music = set(self.music_folders)
        updated_music = set(updated_music_folders)
        removed_music = current_music - updated_music
        new_music = updated_music - current_music
        self.music_folders = updated_music_folders

        music_cache = MusicCache()
        for element in removed_music:
            music_cache.removeDirectory(element)

        self._index_music(list(new_music))

        # Handle video folder changes
        current_videos = set(self.video_folders)
        updated_videos = set(updated_video_folders)
        removed_videos = current_videos - updated_videos
        new_videos = updated_videos - current_videos
        self.video_folders = updated_video_folders

        video_cache = VideoCache()
        for element in removed_videos:
            video_cache.removeDirectory(element)

        self._index_videos(list(new_videos))
Пример #2
0
    def _update_content_folders(self):
        """
        This updates media manager's content folders. This method is
        executed when content.conf has been updated. If folders are added
        we need to index them. If folders are removed, we need to remove
        them from the cache and also from FileSystemObeserver.
        """
        updated_video_folders = self.config.media_folders
        updated_music_folders = self.config.media_folders
        updated_image_folders = self.config.media_folders

        # Handle image folder changes
        current_images = set(self.image_folders)
        updated_images = set(updated_image_folders)
        removed_images = current_images - updated_images
        new_images = updated_images - current_images
        self.image_folders = updated_image_folders

        image_cache = ImageCache()
        for element in removed_images:
            image_cache.removeDirectory(element)

        self._index_images(list(new_images))

        # Handle music folder changes
        current_music = set(self.music_folders)
        updated_music = set(updated_music_folders)
        removed_music = current_music - updated_music
        new_music = updated_music - current_music
        self.music_folders = updated_music_folders

        music_cache = MusicCache()
        for element in removed_music:
            music_cache.removeDirectory(element)

        self._index_music(list(new_music))

        # Handle video folder changes
        current_videos = set(self.video_folders)
        updated_videos = set(updated_video_folders)
        removed_videos = current_videos - updated_videos
        new_videos = updated_videos - current_videos
        self.video_folders = updated_video_folders

        video_cache = VideoCache()
        for element in removed_videos:
            video_cache.removeDirectory(element)

        self._index_videos(list(new_videos))
Пример #3
0
    def run(self):
        """
        Walk root directories recursively and add all found files to the cache.
        """
        if self.cache_type == "image":
            cache = ImageCache()
        elif self.cache_type == "music":
            cache = MusicCache()
        elif self.cache_type == "video":
            cache = VideoCache()

        if self.root_folders == None:
            return

        for element in self.root_folders:
            cache.addDirectory(element)
Пример #4
0
 def rebuildMusicCache(self):
     """Destroy all current data and index everything from the scratch."""
     self.logger.info("Music cache rebuilding requested")
     music_cache = MusicCache()
     music_cache.clearCache()
     self._index_music(self.music_folders)
Пример #5
0
 def rebuildMusicCache(self):
     """Destroy all current data and index everything from the scratch."""
     self.logger.info("Music cache rebuilding requested")
     music_cache = MusicCache()
     music_cache.clearCache()
     self._index_music(self.music_folders)