yt-transcript-strapi-plugin 0.0.18 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,6 +25,7 @@ const FindTranscriptsSchema = zod.z.object({
25
25
  query: zod.z.string().optional(),
26
26
  videoId: zod.z.string().optional(),
27
27
  title: zod.z.string().optional(),
28
+ includeFullContent: zod.z.boolean().optional().default(false),
28
29
  page: zod.z.number().int().min(1).optional().default(1),
29
30
  pageSize: zod.z.number().int().min(1).max(100).optional().default(25),
30
31
  sort: zod.z.string().optional().default("createdAt:desc")
@@ -261,9 +262,10 @@ async function handleGetTranscript(strapi2, args) {
261
262
  ]
262
263
  };
263
264
  }
265
+ const TRANSCRIPT_PREVIEW_LENGTH = 244;
264
266
  const findTranscriptsTool = {
265
267
  name: "find_transcripts",
266
- description: "Search and filter transcripts based on query criteria. Returns multiple matching transcripts. Supports filtering by title, videoId, and full-text search in transcript content.",
268
+ description: "Search and filter transcripts based on query criteria. Returns multiple matching transcripts with truncated previews (244 chars). Use get_transcript for full content. Supports filtering by title, videoId, and full-text search.",
267
269
  inputSchema: {
268
270
  type: "object",
269
271
  properties: {
@@ -279,6 +281,10 @@ const findTranscriptsTool = {
279
281
  type: "string",
280
282
  description: "Filter by title (partial match, case-insensitive)"
281
283
  },
284
+ includeFullContent: {
285
+ type: "boolean",
286
+ description: "Set to true to include full transcript content. Default: false. Warning: may cause context overflow with multiple results."
287
+ },
282
288
  page: {
283
289
  type: "number",
284
290
  description: "Page number (starts at 1)",
@@ -298,9 +304,21 @@ const findTranscriptsTool = {
298
304
  required: []
299
305
  }
300
306
  };
307
+ function truncateText(text, maxLength) {
308
+ if (!text) return null;
309
+ if (text.length <= maxLength) return text;
310
+ return text.substring(0, maxLength) + "...";
311
+ }
312
+ function truncateTranscripts(transcripts) {
313
+ return transcripts.map((transcript2) => ({
314
+ ...transcript2,
315
+ fullTranscript: truncateText(transcript2.fullTranscript, TRANSCRIPT_PREVIEW_LENGTH),
316
+ readableTranscript: truncateText(transcript2.readableTranscript, TRANSCRIPT_PREVIEW_LENGTH)
317
+ }));
318
+ }
301
319
  async function handleFindTranscripts(strapi2, args) {
302
320
  const validatedArgs = validateToolInput("find_transcripts", args);
303
- const { query, videoId, title, page, pageSize, sort } = validatedArgs;
321
+ const { query, videoId, title, includeFullContent, page, pageSize, sort } = validatedArgs;
304
322
  const start = (page - 1) * pageSize;
305
323
  const filters = {};
306
324
  if (videoId) {
@@ -327,13 +345,14 @@ async function handleFindTranscripts(strapi2, args) {
327
345
  filters
328
346
  });
329
347
  const total = allMatching.length;
348
+ const processedTranscripts = includeFullContent ? transcripts : truncateTranscripts(transcripts);
330
349
  return {
331
350
  content: [
332
351
  {
333
352
  type: "text",
334
353
  text: JSON.stringify(
335
354
  {
336
- data: transcripts,
355
+ data: processedTranscripts,
337
356
  pagination: {
338
357
  page,
339
358
  pageSize,
@@ -344,7 +363,8 @@ async function handleFindTranscripts(strapi2, args) {
344
363
  query: query || null,
345
364
  videoId: videoId || null,
346
365
  title: title || null
347
- }
366
+ },
367
+ ...!includeFullContent && { note: "Transcript content truncated to 244 chars. Use get_transcript for full content or set includeFullContent=true." }
348
368
  },
349
369
  null,
350
370
  2
@@ -24,6 +24,7 @@ const FindTranscriptsSchema = z.object({
24
24
  query: z.string().optional(),
25
25
  videoId: z.string().optional(),
26
26
  title: z.string().optional(),
27
+ includeFullContent: z.boolean().optional().default(false),
27
28
  page: z.number().int().min(1).optional().default(1),
28
29
  pageSize: z.number().int().min(1).max(100).optional().default(25),
29
30
  sort: z.string().optional().default("createdAt:desc")
@@ -260,9 +261,10 @@ async function handleGetTranscript(strapi2, args) {
260
261
  ]
261
262
  };
262
263
  }
264
+ const TRANSCRIPT_PREVIEW_LENGTH = 244;
263
265
  const findTranscriptsTool = {
264
266
  name: "find_transcripts",
265
- description: "Search and filter transcripts based on query criteria. Returns multiple matching transcripts. Supports filtering by title, videoId, and full-text search in transcript content.",
267
+ description: "Search and filter transcripts based on query criteria. Returns multiple matching transcripts with truncated previews (244 chars). Use get_transcript for full content. Supports filtering by title, videoId, and full-text search.",
266
268
  inputSchema: {
267
269
  type: "object",
268
270
  properties: {
@@ -278,6 +280,10 @@ const findTranscriptsTool = {
278
280
  type: "string",
279
281
  description: "Filter by title (partial match, case-insensitive)"
280
282
  },
283
+ includeFullContent: {
284
+ type: "boolean",
285
+ description: "Set to true to include full transcript content. Default: false. Warning: may cause context overflow with multiple results."
286
+ },
281
287
  page: {
282
288
  type: "number",
283
289
  description: "Page number (starts at 1)",
@@ -297,9 +303,21 @@ const findTranscriptsTool = {
297
303
  required: []
298
304
  }
299
305
  };
306
+ function truncateText(text, maxLength) {
307
+ if (!text) return null;
308
+ if (text.length <= maxLength) return text;
309
+ return text.substring(0, maxLength) + "...";
310
+ }
311
+ function truncateTranscripts(transcripts) {
312
+ return transcripts.map((transcript2) => ({
313
+ ...transcript2,
314
+ fullTranscript: truncateText(transcript2.fullTranscript, TRANSCRIPT_PREVIEW_LENGTH),
315
+ readableTranscript: truncateText(transcript2.readableTranscript, TRANSCRIPT_PREVIEW_LENGTH)
316
+ }));
317
+ }
300
318
  async function handleFindTranscripts(strapi2, args) {
301
319
  const validatedArgs = validateToolInput("find_transcripts", args);
302
- const { query, videoId, title, page, pageSize, sort } = validatedArgs;
320
+ const { query, videoId, title, includeFullContent, page, pageSize, sort } = validatedArgs;
303
321
  const start = (page - 1) * pageSize;
304
322
  const filters = {};
305
323
  if (videoId) {
@@ -326,13 +344,14 @@ async function handleFindTranscripts(strapi2, args) {
326
344
  filters
327
345
  });
328
346
  const total = allMatching.length;
347
+ const processedTranscripts = includeFullContent ? transcripts : truncateTranscripts(transcripts);
329
348
  return {
330
349
  content: [
331
350
  {
332
351
  type: "text",
333
352
  text: JSON.stringify(
334
353
  {
335
- data: transcripts,
354
+ data: processedTranscripts,
336
355
  pagination: {
337
356
  page,
338
357
  pageSize,
@@ -343,7 +362,8 @@ async function handleFindTranscripts(strapi2, args) {
343
362
  query: query || null,
344
363
  videoId: videoId || null,
345
364
  title: title || null
346
- }
365
+ },
366
+ ...!includeFullContent && { note: "Transcript content truncated to 244 chars. Use get_transcript for full content or set includeFullContent=true." }
347
367
  },
348
368
  null,
349
369
  2
@@ -33,6 +33,7 @@ export declare const FindTranscriptsSchema: z.ZodObject<{
33
33
  query: z.ZodOptional<z.ZodString>;
34
34
  videoId: z.ZodOptional<z.ZodString>;
35
35
  title: z.ZodOptional<z.ZodString>;
36
+ includeFullContent: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
36
37
  page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
37
38
  pageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
38
39
  sort: z.ZodDefault<z.ZodOptional<z.ZodString>>;
@@ -43,6 +44,7 @@ export declare const FindTranscriptsSchema: z.ZodObject<{
43
44
  pageSize?: number;
44
45
  query?: string;
45
46
  title?: string;
47
+ includeFullContent?: boolean;
46
48
  }, {
47
49
  videoId?: string;
48
50
  sort?: string;
@@ -50,6 +52,7 @@ export declare const FindTranscriptsSchema: z.ZodObject<{
50
52
  pageSize?: number;
51
53
  query?: string;
52
54
  title?: string;
55
+ includeFullContent?: boolean;
53
56
  }>;
54
57
  export type FetchTranscriptInput = z.infer<typeof FetchTranscriptSchema>;
55
58
  export type ListTranscriptsInput = z.infer<typeof ListTranscriptsSchema>;
@@ -90,6 +93,7 @@ export declare const ToolSchemas: {
90
93
  query: z.ZodOptional<z.ZodString>;
91
94
  videoId: z.ZodOptional<z.ZodString>;
92
95
  title: z.ZodOptional<z.ZodString>;
96
+ includeFullContent: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
93
97
  page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
94
98
  pageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
95
99
  sort: z.ZodDefault<z.ZodOptional<z.ZodString>>;
@@ -100,6 +104,7 @@ export declare const ToolSchemas: {
100
104
  pageSize?: number;
101
105
  query?: string;
102
106
  title?: string;
107
+ includeFullContent?: boolean;
103
108
  }, {
104
109
  videoId?: string;
105
110
  sort?: string;
@@ -107,6 +112,7 @@ export declare const ToolSchemas: {
107
112
  pageSize?: number;
108
113
  query?: string;
109
114
  title?: string;
115
+ includeFullContent?: boolean;
110
116
  }>;
111
117
  };
112
118
  type ToolName = keyof typeof ToolSchemas;
@@ -17,6 +17,10 @@ export declare const findTranscriptsTool: {
17
17
  type: string;
18
18
  description: string;
19
19
  };
20
+ includeFullContent: {
21
+ type: string;
22
+ description: string;
23
+ };
20
24
  page: {
21
25
  type: string;
22
26
  description: string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.18",
2
+ "version": "0.0.19",
3
3
  "keywords": [
4
4
  "yt-transcript-strapi-plugin",
5
5
  "youtube",