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
10 changes: 9 additions & 1 deletion src/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ export function transformToFlatDirectory(
} else {
$(elem).attr('src', url);
}
} else console.log('Referenced file not found: ' + assetReference);
} else
console.log(
`Referenced file not found: ${assetReference} elem=${$(
paths[assetReference]
).prop('tagName')}`
);
});
modified = true;
});
Expand Down Expand Up @@ -579,6 +584,9 @@ function findFromDOM(
$('video source').each((i: any, elem: any) => {
paths[$(elem).attr('src')] = [elem, ...$(paths[$(elem).attr('src')])];
});
$('video track').each((i: any, elem: any) => {
paths[$(elem).attr('src')] = [elem, ...$(paths[$(elem).attr('src')])];
});

$('embed_activity source').each((i: any, elem: any) => {
paths[$(elem).text()] = [elem, ...$(paths[$(elem).text()])];
Expand Down
3 changes: 3 additions & 0 deletions src/resources/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ export function standardContentManipulations($: any) {
DOM.renameAttribute($, 'video source', 'src', 'url');
DOM.renameAttribute($, 'video', 'type', 'contenttype');
DOM.renameAttribute($, 'audio', 'type', 'audioType');
// video <track> subelement with .vtt subtitle file => torus captions child
DOM.rename($, 'video track[kind="subtitles"]', 'captions');
DOM.renameAttribute($, 'video captions', 'srclang', 'language_code');

DOM.rename($, 'extra', 'popup');

Expand Down
11 changes: 11 additions & 0 deletions src/utils/xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,17 @@ export function toJSON(
} else {
top().src = getAllOfType(top().children, 'source');
}
// video may carry vtt subtitle file(s) in captions children
const captions = getAllOfType(top().children, 'captions');
if (captions != null && captions.length > 0) {
top().captions = captions.map((c: any) => {
return {
label: c.label,
language_code: c.language_code,
src: c.src,
};
});
}

top().children = [{ text: ' ' }];
if (top().width !== undefined) {
Expand Down
Loading