diff --git a/src/media.ts b/src/media.ts index df21d41..5ecc5aa 100644 --- a/src/media.ts +++ b/src/media.ts @@ -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; }); @@ -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()])]; diff --git a/src/resources/common.ts b/src/resources/common.ts index 14a85fe..2a1b5ed 100644 --- a/src/resources/common.ts +++ b/src/resources/common.ts @@ -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 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'); diff --git a/src/utils/xml.ts b/src/utils/xml.ts index f392a8d..0e70888 100644 --- a/src/utils/xml.ts +++ b/src/utils/xml.ts @@ -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) {