Skip to content

Commit 4942746

Browse files
committed
fix: get transcript video
1 parent 435291d commit 4942746

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/services/transcript.service.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ class TranscriptService {
1717
return url?.includes('youtube.com');
1818
}
1919

20-
async transcriptionVideo(): Promise<string | undefined> {
20+
async textTranscriptionVideo(): Promise<string | null> {
2121
if (!(await this.isYoutubeTab())) {
22-
return;
22+
return null;
2323
}
24-
await this.browser.executeScript(async () => {
24+
25+
const textTranscription = await this.browser.executeScript(async () => {
2526
// DOM tab selectors
2627
const ytTranscriptSectionStyle =
2728
'style-scope ytd-video-description-transcript-section-renderer';
@@ -31,7 +32,7 @@ class TranscriptService {
3132
const transcriptSectionAviable = document.getElementsByClassName(ytTranscriptSectionStyle);
3233

3334
if (!transcriptSectionAviable) {
34-
return;
35+
return null;
3536
}
3637

3738
const trasncriptSectionContent = [...transcriptSectionAviable];
@@ -49,7 +50,7 @@ class TranscriptService {
4950
const transcriptSegmentsContainer = document.getElementById(transcriptSegmentsContainerID);
5051

5152
if (!transcriptSegmentsContainer) {
52-
return;
53+
return null;
5354
}
5455

5556
const transcriptSegments = [...transcriptSegmentsContainer.children];
@@ -66,7 +67,8 @@ class TranscriptService {
6667
const transcript = transcriptSegmentsText.join(' ');
6768
return transcript;
6869
});
69-
return;
70+
71+
return textTranscription;
7072
}
7173
}
7274

0 commit comments

Comments
 (0)