@@ -34,6 +34,7 @@ export class WizardService {
3434 private readonly processors : Record < string , Processor > ;
3535 readonly streamService : StreamService ;
3636 readonly wizardApiService : WizardAPIService ;
37+ private readonly videoPrefixes : string [ ] ;
3738
3839 private readonly gzipHtmlFolder : string = 'collect/html/gzip' ;
3940
@@ -60,6 +61,10 @@ export class WizardService {
6061 this . tagService ,
6162 ) ,
6263 generate_title : new GenerateTitleProcessor ( namespaceResourcesService ) ,
64+ generate_video_note : new CollectProcessor (
65+ this . namespaceResourcesService ,
66+ this . tagService ,
67+ ) ,
6368 } ;
6469 const baseUrl = this . configService . get < string > ( 'OBB_WIZARD_BASE_URL' ) ;
6570 if ( ! baseUrl ) {
@@ -71,12 +76,30 @@ export class WizardService {
7176 this . namespaceResourcesService ,
7277 ) ;
7378 this . wizardApiService = new WizardAPIService ( baseUrl ) ;
79+ const videoPrefixes : string =
80+ this . configService . get < string > ( 'OB_VIDEO_PREFIXES' ) || '' ;
81+ if ( isEmpty ( videoPrefixes ) ) {
82+ this . videoPrefixes = [ ] ;
83+ } else {
84+ this . videoPrefixes = videoPrefixes
85+ . split ( ',' )
86+ . map ( ( prefix ) => prefix . trim ( ) ) ;
87+ }
7488 }
7589
7690 async create ( partialTask : Partial < Task > ) {
7791 return await this . wizardTaskService . create ( partialTask ) ;
7892 }
7993
94+ isVideoUrl ( url : string ) : boolean {
95+ for ( const prefix of this . videoPrefixes ) {
96+ if ( url . startsWith ( prefix ) ) {
97+ return true ;
98+ }
99+ }
100+ return false ;
101+ }
102+
80103 async collectZ (
81104 userId : string ,
82105 data : CollectZRequestDto ,
@@ -113,13 +136,23 @@ export class WizardService {
113136 } ,
114137 ) ;
115138
116- const task = await this . wizardTaskService . createCollectTask (
117- userId ,
118- namespace_id ,
119- resource . id ,
120- { html : [ this . gzipHtmlFolder , id ] . join ( '/' ) , url, title } ,
121- ) ;
122- return { task_id : task . id , resource_id : resource . id } ;
139+ if ( this . isVideoUrl ( url ) ) {
140+ const task = await this . wizardTaskService . createGenerateVideoNoteTask (
141+ userId ,
142+ namespace_id ,
143+ resource . id ,
144+ { html : [ this . gzipHtmlFolder , id ] . join ( '/' ) , url, title } ,
145+ ) ;
146+ return { task_id : task . id , resource_id : resource . id } ;
147+ } else {
148+ const task = await this . wizardTaskService . createCollectTask (
149+ userId ,
150+ namespace_id ,
151+ resource . id ,
152+ { html : [ this . gzipHtmlFolder , id ] . join ( '/' ) , url, title } ,
153+ ) ;
154+ return { task_id : task . id , resource_id : resource . id } ;
155+ }
123156 }
124157
125158 async collect (
@@ -194,7 +227,9 @@ export class WizardService {
194227
195228 // Trigger extract_tags after collect or file_reader tasks finish
196229 if (
197- ( task . function === 'collect' || task . function === 'file_reader' ) &&
230+ [ 'collect' , 'file_reader' , 'generate_video_note' ] . includes (
231+ task . function ,
232+ ) &&
198233 ! isEmpty ( task . output ?. markdown ) &&
199234 isEmpty ( result . tagIds )
200235 ) {
@@ -360,7 +395,7 @@ export class WizardService {
360395 const newTask = await this . wizardTaskService . taskRepository . save ( task ) ;
361396 // Fetch HTML content from S3 for collect tasks
362397 if (
363- newTask . function === 'collect' &&
398+ [ 'collect' , 'generate_video_note' ] . includes ( newTask . function ) &&
364399 newTask . input . html ?. startsWith ( this . gzipHtmlFolder ) &&
365400 newTask . input . html ?. length === this . gzipHtmlFolder . length + 36 // 1 + 32 + 3
366401 ) {
0 commit comments