Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .woodpecker.star
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ docker_repo_slug = "opencloudeu/opencloud"

# images
ALPINE_GIT = "alpine/git:latest"
APACHE_TIKA = "apache/tika:4.1.0-SNAPSHOT"
APACHE_TIKA = "apache/tika:4.1.0-full"
CHKO_DOCKER_PUSHRM = "chko/docker-pushrm:1"
CODACY_COVERAGE_REPORTER = "codacy/codacy-coverage-reporter:14.1.3"
COLLABORA_CODE = "collabora/code:24.04.5.1.1"
Expand Down
8 changes: 4 additions & 4 deletions services/search/pkg/content/tika.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ func (t Tika) Extract(ctx context.Context, ri *provider.ResourceInfo) (Document,
doc.Title = strings.TrimSpace(fmt.Sprintf("%s %s", doc.Title, title))
}

// tika 4 renamed the meta prefix from X-TIKA: to tk:
if content, err := getFirstValue(meta, "tk:content"); err == nil {
doc.Content = strings.TrimSpace(fmt.Sprintf("%s %s", doc.Content, content))
} else if content, err := getFirstValue(meta, "X-TIKA:content"); err == nil {
if content, err := getFirstValue(meta,
"tk:content", // tika 4
"X-TIKA:content", // tika 3 legacy
); err == nil {
doc.Content = strings.TrimSpace(fmt.Sprintf("%s %s", doc.Content, content))
}
}
Expand Down
11 changes: 5 additions & 6 deletions services/search/pkg/content/tika_live_photo.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import (
func (t Tika) getLivePhoto(meta map[string][]string) *libregraph.LivePhoto {
// ContentId pairs the two halves, without it there is no live photo. The
// video carries it in the QuickTime item list, the still image in the Apple
// maker note, which tika surfaces as "Content Identifier". A file is only
// ever one half, so both keys are read.
contentID, err := getFirstValue(meta, "com.apple.quicktime.content.identifier", "Content Identifier")
// maker note. A file is only ever one half, so both keys are read.
contentID, err := getFirstValue(meta, "mp4:com.apple.quicktime.content.identifier", "img:Content Identifier")
if err != nil || contentID == "" {
return nil
}
Expand All @@ -25,19 +24,19 @@ func (t Tika) getLivePhoto(meta map[string][]string) *libregraph.LivePhoto {
}
}

if v, err := getFirstValue(meta, "com.apple.quicktime.live-photo.auto"); err == nil {
if v, err := getFirstValue(meta, "mp4:com.apple.quicktime.live-photo.auto"); err == nil {
if b, err := strconv.ParseBool(v); err == nil {
livePhoto.SetAuto(b)
}
}

if v, err := getFirstValue(meta, "com.apple.quicktime.live-photo.vitality-score"); err == nil {
if v, err := getFirstValue(meta, "mp4:com.apple.quicktime.live-photo.vitality-score"); err == nil {
if f, err := strconv.ParseFloat(v, 64); err == nil {
livePhoto.SetVitalityScore(f)
}
}

if v, err := getFirstValue(meta, "com.apple.quicktime.live-photo.vitality-scoring-version"); err == nil {
if v, err := getFirstValue(meta, "mp4:com.apple.quicktime.live-photo.vitality-scoring-version"); err == nil {
if i, err := strconv.ParseInt(v, 10, 64); err == nil {
livePhoto.SetVitalityScoringVersion(i)
}
Expand Down
32 changes: 16 additions & 16 deletions services/search/pkg/content/tika_live_photo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
var _ = Describe("getLivePhoto", func() {
It("maps the video half of a live photo", func() {
livePhoto := Tika{}.getLivePhoto(map[string][]string{
"Content-Type": {"video/quicktime"},
"com.apple.quicktime.content.identifier": {"6F1A2B3C-1234-4E5F-9A8B-0011223344CC"},
"quicktime:still-image-time": {"1500000"},
"com.apple.quicktime.live-photo.auto": {"1"},
"com.apple.quicktime.live-photo.vitality-score": {"0.75"},
"com.apple.quicktime.live-photo.vitality-scoring-version": {"4"},
"Content-Type": {"video/quicktime"},
"mp4:com.apple.quicktime.content.identifier": {"6F1A2B3C-1234-4E5F-9A8B-0011223344CC"},
"quicktime:still-image-time": {"1500000"},
"mp4:com.apple.quicktime.live-photo.auto": {"1"},
"mp4:com.apple.quicktime.live-photo.vitality-score": {"0.75"},
"mp4:com.apple.quicktime.live-photo.vitality-scoring-version": {"4"},
})
Expect(livePhoto).ToNot(BeNil())

Expand All @@ -27,8 +27,8 @@ var _ = Describe("getLivePhoto", func() {

It("maps the still half via the Apple maker-note content identifier", func() {
livePhoto := Tika{}.getLivePhoto(map[string][]string{
"Content-Type": {"image/heic"},
"Content Identifier": {"6F1A2B3C-1234-4E5F-9A8B-0011223344CC"},
"Content-Type": {"image/heic"},
"img:Content Identifier": {"6F1A2B3C-1234-4E5F-9A8B-0011223344CC"},
})
Expect(livePhoto).ToNot(BeNil())
Expect(livePhoto.ContentId).To(Equal("6F1A2B3C-1234-4E5F-9A8B-0011223344CC"))
Expand All @@ -39,25 +39,25 @@ var _ = Describe("getLivePhoto", func() {
"Content-Type": {"image/jpeg"},
})).To(BeNil())
Expect(Tika{}.getLivePhoto(map[string][]string{
"Content-Type": {"image/heic"},
"Content Identifier": {""},
"Content-Type": {"image/heic"},
"img:Content Identifier": {""},
})).To(BeNil(), "an empty pairing id is no live photo")
})

It("rounds a fractional still-image-time", func() {
livePhoto := Tika{}.getLivePhoto(map[string][]string{
"com.apple.quicktime.content.identifier": {"6F1A2B3C"},
"quicktime:still-image-time": {"1500000.7"},
"mp4:com.apple.quicktime.content.identifier": {"6F1A2B3C"},
"quicktime:still-image-time": {"1500000.7"},
})
Expect(livePhoto).ToNot(BeNil())
Expect(livePhoto.StillImageTimeUs).To(Equal(libregraph.PtrInt64(1500001)))
})

It("keeps the facet when optional values are malformed", func() {
livePhoto := Tika{}.getLivePhoto(map[string][]string{
"com.apple.quicktime.content.identifier": {"6F1A2B3C"},
"com.apple.quicktime.live-photo.auto": {"maybe"},
"com.apple.quicktime.live-photo.vitality-score": {"very"},
"mp4:com.apple.quicktime.content.identifier": {"6F1A2B3C"},
"mp4:com.apple.quicktime.live-photo.auto": {"maybe"},
"mp4:com.apple.quicktime.live-photo.vitality-score": {"very"},
})
Expect(livePhoto).ToNot(BeNil())
Expect(livePhoto.Auto).To(BeNil())
Expand All @@ -66,7 +66,7 @@ var _ = Describe("getLivePhoto", func() {

It("leaves the video-only fields empty on the still half", func() {
livePhoto := Tika{}.getLivePhoto(map[string][]string{
"Content Identifier": {"6F1A2B3C"},
"img:Content Identifier": {"6F1A2B3C"},
})
Expect(livePhoto).ToNot(BeNil())
Expect(livePhoto.StillImageTimeUs).To(BeNil())
Expand Down
2 changes: 1 addition & 1 deletion services/search/pkg/content/tika_photo.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (t Tika) getPhoto(meta map[string][]string) *libregraph.Photo {
}
}

if v, err := getFirstValue(meta, "Base ISO"); err == nil {
if v, err := getFirstValue(meta, "exif:IsoSpeedRatings"); err == nil {
if i, err := strconv.ParseInt(v, 0, 32); err == nil {
initPhoto()
photo.SetIso(int32(i))
Expand Down
12 changes: 11 additions & 1 deletion services/search/pkg/content/tika_photo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var _ = Describe("getPhoto", func() {
"exif:ExposureTime": {"0.001"},
"exif:FNumber": {"1.8"},
"exif:FocalLength": {"50"},
"Base ISO": {"100"},
"exif:IsoSpeedRatings": {"100"},
"tiff:Orientation": {"1"},
"exif:DateTimeOriginal": {"2018-01-01T12:34:56"},
})
Expand All @@ -32,6 +32,16 @@ var _ = Describe("getPhoto", func() {
Expect(photo.TakenDateTime).To(Equal(libregraph.PtrTime(time.Date(2018, 1, 1, 12, 34, 56, 0, time.UTC))))
})

It("takes the iso of the shot, not the canon maker note base iso", func() {
photo := Tika{}.getPhoto(map[string][]string{
"exif:IsoSpeedRatings": {"800"},
"Base ISO": {"256"},
"img:Base ISO": {"256"},
})
Expect(photo).ToNot(BeNil())
Expect(photo.Iso).To(Equal(libregraph.PtrInt32(800)))
})

It("returns nil when no photo metadata is present", func() {
Expect(Tika{}.getPhoto(map[string][]string{})).To(BeNil())
})
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/docker/src/tika.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ services:
- tika
command: tika:9998
tika:
image: apache/tika:4.0.0-full
image: apache/tika:4.1.0-full
Loading