photoprism/internal/photoprism/convert_worker.go
Michael Mayer 92e6c4fe1e Download: Add Disabled, Originals, MediaRaw & MediaSidecar Flags #2234
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)
2022-04-15 09:42:07 +02:00

44 lines
1.1 KiB
Go

package photoprism
import (
"strings"
"github.com/photoprism/photoprism/pkg/clean"
)
type ConvertJob struct {
force bool
file *MediaFile
convert *Convert
}
func ConvertWorker(jobs <-chan ConvertJob) {
logError := func(err error, job ConvertJob) {
fileName := job.file.RelName(job.convert.conf.OriginalsPath())
log.Errorf("convert: %s for %s", strings.TrimSpace(err.Error()), clean.Log(fileName))
}
for job := range jobs {
switch {
case job.file == nil:
continue
case job.convert == nil:
continue
case job.file.IsAnimated():
_, _ = job.convert.ToJson(job.file)
// Create JPEG preview and AVC encoded version for videos.
if _, err := job.convert.ToJpeg(job.file, job.force); err != nil {
logError(err, job)
} else if metaData := job.file.MetaData(); metaData.CodecAvc() {
continue
} else if _, err := job.convert.ToAvc(job.file, job.convert.conf.FFmpegEncoder(), false, false); err != nil {
logError(err, job)
}
default:
if _, err := job.convert.ToJpeg(job.file, job.force); err != nil {
logError(err, job)
}
}
}
}