From bc7e7108359dd0c4b38befc58c27221a4ef68f48 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 11 Jun 2024 10:55:56 +0800 Subject: [PATCH] open youtube transcript to public --- .../api/src/jobs/process-youtube-video.ts | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/packages/api/src/jobs/process-youtube-video.ts b/packages/api/src/jobs/process-youtube-video.ts index 916f7fdb0..339657203 100644 --- a/packages/api/src/jobs/process-youtube-video.ts +++ b/packages/api/src/jobs/process-youtube-video.ts @@ -4,7 +4,6 @@ import { parseHTML } from 'linkedom' import showdown from 'showdown' import { Chapter, Client as YouTubeClient } from 'youtubei' import { LibraryItem, LibraryItemState } from '../entity/library_item' -import { FeatureName, findGrantedFeatureByName } from '../services/features' import { findLibraryItemById, updateLibraryItem, @@ -282,30 +281,23 @@ export const processYouTubeVideo = async ( updatedLibraryItem.publishedAt = new Date(video.uploadDate) } - if ( - await findGrantedFeatureByName( - FeatureName.YouTubeTranscripts, - jobData.userId + if ('getTranscript' in video && duration > 0 && duration < 1801) { + // If the video has a transcript available, put a placehold in and + // enqueue a job to process the full transcript + const updatedContent = await addTranscriptToReadableContent( + libraryItem.originalUrl, + libraryItem.readableContent, + TRANSCRIPT_PLACEHOLDER_TEXT ) - ) { - if ('getTranscript' in video && duration > 0 && duration < 1801) { - // If the video has a transcript available, put a placehold in and - // enqueue a job to process the full transcript - const updatedContent = await addTranscriptToReadableContent( - libraryItem.originalUrl, - libraryItem.readableContent, - TRANSCRIPT_PLACEHOLDER_TEXT - ) - if (updatedContent) { - updatedLibraryItem.readableContent = updatedContent - } - - await enqueueProcessYouTubeTranscript({ - videoId, - ...jobData, - }) + if (updatedContent) { + updatedLibraryItem.readableContent = updatedContent } + + await enqueueProcessYouTubeTranscript({ + videoId, + ...jobData, + }) } if (updatedLibraryItem !== {}) {