{"id":6649,"date":"2020-06-23T15:38:01","date_gmt":"2020-06-23T20:38:01","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=6649"},"modified":"2022-09-21T11:57:22","modified_gmt":"2022-09-21T16:57:22","slug":"exporting-microsoft-stream-transcript-prettier-output-and-error-handling","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=6649","title":{"rendered":"Exporting Microsoft Stream Transcript &#8212; Prettier Output and Error Handling"},"content":{"rendered":"<p>Updated script available at <a href=\"https:\/\/www.rushworth.us\/lisa\/?p=6854\">https:\/\/www.rushworth.us\/lisa\/?p=6854<\/a> &#8212; and, since copy\/paste doesn&#8217;t seem to work for everyone, the <a href=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2022\/09\/ExportingMSStreamTranscript.txt\" target=\"_blank\" rel=\"noopener\">script is also available as a text file<\/a>.<\/p>\n<p>I had posted a one-liner to grab the text content of the Microsoft Stream transcript &#8212; there&#8217;s a good bit of cleanup required to make something professional looking, but I&#8217;ve been lazy about it &amp; leave formatting up to the recipient. The one-liner approach fails when it doesn&#8217;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 <em>when the node has a textContent attribute<\/em> appends that content to a running string value. Printing the running string value produces output that needs minimal reformatting.<\/p>\n<p>Code:<\/p>\n<pre>var objTranscriptLines = window.document.querySelectorAll('.transcript-line');\r\nvar strRunningText = null;\r\nfor(var i = 0; i &lt; objTranscriptLines.length; i++){\r\n    if( objTranscriptLines[i].textContent ){\r\n        var strLineText = objTranscriptLines[i].textContent;\r\n        strRunningText = strRunningText + \"\\n\" + strLineText.replace(\"Discard   Save\",\"\");\r\n    }\r\n}\r\nconsole.log(strRunningText);<\/pre>\n<p>Results:<\/p>\n<p><a href=\"https:\/\/www.rushworth.us\/lisa\/?attachment_id=6650\" rel=\"attachment wp-att-6650\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6650\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/exportingStreamTranscriptPrettyVersion.png\" alt=\"\" width=\"706\" height=\"423\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/exportingStreamTranscriptPrettyVersion.png 706w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/exportingStreamTranscriptPrettyVersion-300x180.png 300w\" sizes=\"auto, (max-width: 706px) 100vw, 706px\" \/><\/a><\/p>\n<p>You *could* strip off the timestamps as well &#8212; instead of <em><strong>strLineText.replace(&#8220;Discard Save&#8221;,&#8221;&#8221;) <\/strong><\/em>use <em><strong>(strLineText.replace(&#8220;Discard \u00a0\u00a0 Save&#8221;,&#8221;&#8221;)).substr(8)<\/strong><\/em><\/p>\n<p><a href=\"https:\/\/www.rushworth.us\/lisa\/?attachment_id=6651\" rel=\"attachment wp-att-6651\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6651\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/exportingStreamTranscriptPrettyVersionWithoutTimestamp.png\" alt=\"\" width=\"840\" height=\"428\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/exportingStreamTranscriptPrettyVersionWithoutTimestamp.png 840w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/exportingStreamTranscriptPrettyVersionWithoutTimestamp-300x153.png 300w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/exportingStreamTranscriptPrettyVersionWithoutTimestamp-768x391.png 768w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/06\/exportingStreamTranscriptPrettyVersionWithoutTimestamp-750x382.png 750w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Updated script available at https:\/\/www.rushworth.us\/lisa\/?p=6854 &#8212; and, since copy\/paste doesn&#8217;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 &#8212; there&#8217;s a good bit of cleanup required to make something professional looking, but I&#8217;ve been &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[677],"tags":[854,713,1034],"class_list":["post-6649","post","type-post","status-publish","format-standard","hentry","category-office-365","tag-jquery","tag-microsoft-stream","tag-stream"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/6649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6649"}],"version-history":[{"count":3,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/6649\/revisions"}],"predecessor-version":[{"id":9365,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/6649\/revisions\/9365"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}