domCreateMediaInfoData()

in source/webapp/src/lib/js/videoPreview.js [430:484]


  domCreateMediaInfoData(card) {
    const items = [];
    items.push(BasePreview.carouselLead('Technical metadata'));

    let tracks = (card.mediainfo || {}).media || (card.mediainfo || {}).file || {};
    tracks = tracks.track || [];

    const container = tracks.filter(x =>
      x.$.type.toLowerCase() === 'general').shift();
    if (container) {
      items.push(BasePreview.carouselLead(container.$.type));
      items.push('<dl class="row text-left">');
      Object.keys(container).filter(x => x !== '$').forEach((key) => {
        items.push(`<dt class="col-sm-6">${BasePreview.capitalize(key)}</dt><dd class="col-sm-6">${BasePreview.shorten(container[key], 50)}</dd>`);
      });
      items.push('</dl>');
    }

    [
      'video',
      'audio',
    ].forEach((type) => {
      const streams = tracks.filter(x =>
        x.$.type.toLowerCase() === type);
      if (streams.length) {
        items.push(BasePreview.carouselLead(`${BasePreview.capitalize(type)} (${streams.length})`));
        let idx = 0;
        while (streams.length) {
          const stream = streams.shift();
          items.push(BasePreview.carouselLead(`Stream #${idx++}`));
          items.push('<dl class="row text-left">');
          Object.keys(stream).filter(x => x !== '$').forEach((key) => {
            items.push(`<dt class="col-sm-6">${BasePreview.capitalize(key)}</dt><dd class="col-sm-6">${BasePreview.shorten(stream[key], 50)}</dd>`);
          });
          items.push('</dl>');
        }
      }
    });

    const others = tracks.filter(x =>
      x.$.type.toLowerCase() !== 'general'
      && x.$.type.toLowerCase() !== 'video'
      && x.$.type.toLowerCase() !== 'audio');

    while (others.length) {
      const other = others.shift();
      items.push(BasePreview.carouselLead(BasePreview.capitalize(other.$.type)));
      items.push('<dl class="row text-left">');
      Object.keys(other).filter(x => x !== '$').forEach((key) => {
        items.push(`<dt class="col-sm-6">${BasePreview.capitalize(key)}</dt><dd class="col-sm-6">${BasePreview.shorten(other[key], 50)}</dd>`);
      });
      items.push('</dl>');
    }
    return items;
  }