Exporting Microsoft Stream Transcript — Prettier Output and Error Handling

Updated script available at https://www.rushworth.us/lisa/?p=6854 — and, since copy/paste doesn’t seem to work for everyone, the script is also available as a text file.

I had posted a one-liner to grab the text content of the Microsoft Stream transcript — there’s a good bit of cleanup required to make something professional looking, but I’ve been lazy about it & leave formatting up to the recipient. The one-liner approach fails when it doesn’t encounter a text element where it expects to find one. A more robust export approach creates a Node List containing all of the transcript-line classed elements, then iterates through that list and when the node has a textContent attribute appends that content to a running string value. Printing the running string value produces output that needs minimal reformatting.

Code:

var objTranscriptLines = window.document.querySelectorAll('.transcript-line');
var strRunningText = null;
for(var i = 0; i < objTranscriptLines.length; i++){
    if( objTranscriptLines[i].textContent ){
        var strLineText = objTranscriptLines[i].textContent;
        strRunningText = strRunningText + "\n" + strLineText.replace("Discard   Save","");
    }
}
console.log(strRunningText);

Results:

You *could* strip off the timestamps as well — instead of strLineText.replace(“Discard Save”,””) use (strLineText.replace(“Discard    Save”,””)).substr(8)

4 comments

  1. Avatar
    SHAMSULHADI BANDI says:

    Hi Lisa,

    Thank you for this wonderful script. Same as the previous commentor, I seem not able to copy the script, would it be possible for me to get a copy of the script as well? Many thanks Lisa

Leave a Reply

Your email address will not be published. Required fields are marked *