Skip to content

Commit

Permalink
Duration and avilability
Browse files Browse the repository at this point in the history
  • Loading branch information
Mau Zsofia Abraham committed Jan 24, 2025
1 parent a461d1c commit 49aca31
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
18 changes: 18 additions & 0 deletions components/data-table-window-content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
createColumnHelper,
type Table,
} from "@tanstack/vue-table";
import { Volume2, VolumeX } from "lucide-vue-next";
import { h } from "vue";
import { useTEIHeaders } from "@/composables/use-tei-headers";
Expand Down Expand Up @@ -122,6 +123,23 @@ const columns = ref([
header: "Interviewer",
footer: (props) => props.column.id,
}),
columnHelper.accessor((row) => row.duration, {
id: "duration",
cell: (info) => info.getValue(),
header: "Duration",
footer: (props) => props.column.id,
}),
columnHelper.accessor((row) => row.audioAvailability, {
id: "audioAvailability",
cell: (info) =>
info.getValue() === "free"
? h(Volume2, { title: info.getValue() })
: h(VolumeX, { title: info.getValue() }),
header: "Avaiilability",
footer: (props) => props.column.id,
}),
]);
const tables: Ref<Table<Array<simpleTEIMetadata>> | null> = ref(null);
Expand Down
18 changes: 17 additions & 1 deletion composables/use-tei-headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const extractMetadata = function (
const template = {
id: "",
recordingDate: "",
audioAvailability: "restricted",
duration: "",
pubDate: "",
place: {
settlement: "",
Expand Down Expand Up @@ -107,6 +109,21 @@ const extractMetadata = function (
}
}

if (item.teiHeader.fileDesc.sourceDesc.recordingStmt?.recording) {
const duration = parseInt(
item.teiHeader.fileDesc.sourceDesc.recordingStmt.recording["@dur-iso"]
.replace("PT", "")
.replace(".0", ""),
);
const durHours = Math.floor(duration / 3600);
const durSeconds = Math.floor(duration % 60);
const durMinutes = Math.floor(((duration % 3600) - durSeconds) / 60);
template.duration = `${
durHours ? `${String(durHours).padStart(2, "0")}:` : ""
}${String(durMinutes).padStart(2, "0")}:${String(durSeconds).padStart(2, "0")}`;
template.audioAvailability = item.teiHeader.fileDesc.publicationStmt.availability["@status"];
}

if (
template.dataType === "CorpusText" &&
item.teiHeader.fileDesc.sourceDesc.recordingStmt?.recording.respStmt?.persName &&
Expand All @@ -122,7 +139,6 @@ const extractMetadata = function (
return false;
}
});
console.log(respPerson);
let name;
if (respPerson?.persName) {
const persName2 = respPerson.persName as PersName;
Expand Down
2 changes: 2 additions & 0 deletions types/teiCorpus.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export type simpleTEIMetadata = {
resp: string;
pubDate: string | TeiDate;
recordingDate?: string | TeiDate;
duration?: string;
audioAvailability: string;
place: {
settlement: string;
country: string;
Expand Down

0 comments on commit 49aca31

Please sign in to comment.