Skip to main content
Glama

SRT Translation MCP Server

by omd0
srt-parser.test.ts2.26 kB
/** * Tests for SRT parser */ import { describe, it, expect } from 'vitest'; import { parseSRTFile, writeSRTFile } from './srt-parser.js'; describe('SRT Parser', () => { describe('parseSRTFile', () => { it('should parse valid SRT content', () => { const srtContent = `1 00:00:01,000 --> 00:00:04,000 Hello world 2 00:00:05,000 --> 00:00:08,000 This is a test`; const result = parseSRTFile(srtContent); expect(result.success).toBe(true); expect(result.file?.subtitles).toHaveLength(2); expect(result.file?.subtitles[0].index).toBe(1); expect(result.file?.subtitles[0].text).toBe('Hello world'); }); it('should handle invalid timing', () => { const srtContent = `1 00:00:04,000 --> 00:00:01,000 Invalid timing`; const result = parseSRTFile(srtContent); expect(result.success).toBe(false); expect(result.errors).toHaveLength(1); expect(result.errors?.[0].type).toBe('timing'); }); it('should handle style tags', () => { const srtContent = `1 00:00:01,000 --> 00:00:04,000 <b>Bold text</b> and <i>italic text</i>`; const result = parseSRTFile(srtContent); expect(result.success).toBe(true); expect(result.file?.subtitles[0].text).toBe('<b>Bold text</b> and <i>italic text</i>'); }); }); describe('writeSRTFile', () => { it('should write SRT file correctly', () => { const srtFile = { subtitles: [ { index: 1, startTime: { hours: 0, minutes: 0, seconds: 1, milliseconds: 0 }, endTime: { hours: 0, minutes: 0, seconds: 4, milliseconds: 0 }, text: 'Hello world', rawText: 'Hello world', }, { index: 2, startTime: { hours: 0, minutes: 0, seconds: 5, milliseconds: 0 }, endTime: { hours: 0, minutes: 0, seconds: 8, milliseconds: 0 }, text: 'This is a test', rawText: 'This is a test', }, ], }; const result = writeSRTFile(srtFile); expect(result).toContain('1\n00:00:01,000 --> 00:00:04,000\nHello world'); expect(result).toContain('2\n00:00:05,000 --> 00:00:08,000\nThis is a test'); }); }); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/omd0/srt-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server