cache

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cobra.Command{
	Use:   "cache [flags] ...<image|video|directory>",
	Short: "Generate color cache from a image/video",
	Args:  cobra.MinimumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		paths := make(chan string)

		go ScanPaths(args, paths)
		for path := range paths {
			if cache.IsCached(path) {
				slog.Info("Skipping", "path", path, "reason", "already cached")
				continue
			}

			frames, _ := cmd.Flags().GetInt("frames")
			pixels, err := ffmpeg.GetPixels(path, frames)
			if err != nil {
				slog.Error("Failed to get pixels from media", "path", path, "error", err)
				continue
			}

			quantized := material.Quantize(pixels)
			if err := cache.SaveCache(path, quantized); err != nil {
				slog.Error("Failed to save cache", "path", path, "error", err)
				continue
			}

			slog.Info("Successfully cached media", "path", path)
		}
	},
}

Command is cache command

Functions

func ScanPaths

func ScanPaths(paths []string, out chan<- string)

ScanPaths scans the given paths and sends absolute paths of image/video files to the provided channel

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL