92e6c4fe1e
Extends DownloadSettings with 4 additional options: - Name: File name pattern for downloaded files (existed) - Disabled: Disables downloads - Originals: Only download files stored in "originals" folder - MediaRaw: Include RAW image files - MediaSidecar: Include metadata sidecar files (JSON, XMP, YAML)
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package meta
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/photoprism/photoprism/pkg/projection"
|
|
|
|
"github.com/photoprism/photoprism/pkg/txt"
|
|
)
|
|
|
|
const (
|
|
KeywordFlash = "flash"
|
|
KeywordHdr = "hdr"
|
|
KeywordBurst = "burst"
|
|
KeywordPanorama = "panorama"
|
|
KeywordEquirectangular = string(projection.Equirectangular)
|
|
)
|
|
|
|
// Keywords represents a list of metadata keywords.
|
|
type Keywords []string
|
|
|
|
// String returns a string containing all keywords.
|
|
func (w Keywords) String() string {
|
|
return strings.Join(w, ", ")
|
|
}
|
|
|
|
var AutoKeywords = []string{KeywordHdr, KeywordBurst, KeywordPanorama, KeywordEquirectangular}
|
|
|
|
// AddKeywords appends keywords.
|
|
func (data *Data) AddKeywords(w string) {
|
|
w = strings.ToLower(SanitizeMeta(w))
|
|
|
|
if len(w) < 1 {
|
|
return
|
|
}
|
|
|
|
data.Keywords = txt.AddToWords(data.Keywords, w)
|
|
}
|
|
|
|
// AutoAddKeywords automatically appends relevant keywords from a string (e.g. description).
|
|
func (data *Data) AutoAddKeywords(s string) {
|
|
s = strings.ToLower(SanitizeMeta(s))
|
|
|
|
if len(s) < 1 {
|
|
return
|
|
}
|
|
|
|
for _, w := range AutoKeywords {
|
|
if strings.Contains(s, w) {
|
|
data.AddKeywords(w)
|
|
if w == KeywordHdr {
|
|
data.ImageType = ImageTypeHDR
|
|
}
|
|
}
|
|
}
|
|
}
|