Skip to content

Commit

Permalink
Merge branch 'harvest-ocr' of owi92/opencast into r/15.x
Browse files Browse the repository at this point in the history
Pull request opencast#5757

  Add slide text and segments to Tobira harvest API
  • Loading branch information
gregorydlogan committed May 6, 2024
2 parents 9c7dfc0 + a88cfd7 commit 40cd08e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ class Item {

final var captions = findCaptions(mp);

// Get the generated slide text.
final var slideText = Arrays.stream(mp.getElements())
.filter(mpe -> mpe.getFlavor().eq("mpeg-7/text"))
.map(element -> element.getURI())
.findFirst();

// Obtain duration from tracks, as that's usually more accurate (stores information from
// inspect operations). Fall back to `getDcExtent`.
final var duration = Arrays.stream(mp.getTracks())
Expand Down Expand Up @@ -158,6 +164,8 @@ class Item {
"created", "creator", "title", "extent", "isPartOf", "description", "identifier",
}))),
Jsons.p("captions", Jsons.arr(captions)),
Jsons.p("slideText", slideText.map(t -> t.toString()).orElse(null)),
Jsons.p("segments", Jsons.arr(findSegments(mp))),
Jsons.p("updated", event.getModified().getTime())
);
}
Expand Down Expand Up @@ -321,6 +329,17 @@ private static String findThumbnail(MediaPackage mp) {
.orElse(null);
}

private static List<Jsons.Val> findSegments(MediaPackage mp) {
return Arrays.stream(mp.getAttachments())
.filter(a -> a.getFlavor().getSubtype().equals("segment+preview"))
.map(s -> Jsons.obj(
Jsons.p("uri", s.toString()),
Jsons.p("startTime", s.getReference().getProperty("time"))
)
)
.collect(Collectors.toCollection(ArrayList::new));
}

private static Jsons.Val findTimelinePreview(MediaPackage mp) {
return Arrays.stream(mp.getAttachments())
.filter(a -> a.getFlavor().getSubtype().equals("timeline+preview"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class TobiraEndpoint {

// Versioning the Tobira API:
//
// Since both Tobira and this API are changing over time, we need some machanism for ensuring they
// Since both Tobira and this API are changing over time, we need some mechanism for ensuring they
// are compatible. We don't want to enforce a 1:1 thing, where a particular Tobira needs one
// exact API as that makes the update process harder (especially once this module is included in
// the community version). So instead we have some semver-like versioning here. Increase the
Expand All @@ -95,7 +95,7 @@ public class TobiraEndpoint {
// adding new JSON fields is a non-breaking change. You should also consider whether Tobira needs
// to resynchronize, i.e. to get new data.
private static final int VERSION_MAJOR = 1;
private static final int VERSION_MINOR = 5;
private static final int VERSION_MINOR = 6;
private static final String VERSION = VERSION_MAJOR + "." + VERSION_MINOR;

private SearchService searchService;
Expand Down

0 comments on commit 40cd08e

Please sign in to comment.