-
Notifications
You must be signed in to change notification settings - Fork 2
Description
DeepSRT - SRT Provider
Abstract
This document proposes a flexible "SRT Provider" system for DeepSRT that enables users to access subtitle files from multiple sources beyond just YouTube's native API. This approach would allow for a modular and extensible way to retrieve SRT files from various providers, including curated SRT stores, proxies, or any custom source that implements the provider interface.
Problem Statement
Currently, the DeepSRT Chrome extension can only access subtitles through YouTube's native API. However, many videos lack built-in CC (closed caption) subtitles. DeepSRT should implement support for user-defined SRT providers to enable subtitle functionality for videos that don't offer official caption support.
問題陳述
目前,DeepSRT Chrome 擴充功能只能通過 YouTube 原生 API 獲取字幕。然而,許多影片缺乏內建的 CC(關閉式字幕)。DeepSRT 應該實現對使用者自定義 SRT 提供者的支持,為沒有官方字幕支持的影片提供字幕功能。
Architecture
flowchart TD
A[DeepSRT Extension] --> B[YouTube API]
B -->|No subtitles| C[SRT Provider System]
C --> D[Default Provider: YouTube]
C --> E[User-defined Provider 1]
C --> F[User-defined Provider 2]
C --> G[...]
style A fill:#2d2d2d,stroke:#6c6c6c,color:#fff
style B fill:#2d2d2d,stroke:#6c6c6c,color:#fff
style C fill:#2d2d2d,stroke:#6c6c6c,color:#fff
style D fill:#2d2d2d,stroke:#6c6c6c,color:#fff
style E fill:#2d2d2d,stroke:#6c6c6c,color:#fff
style F fill:#2d2d2d,stroke:#6c6c6c,color:#fff
style G fill:#2d2d2d,stroke:#6c6c6c,color:#fff
Loading Process
- DeepSRT first attempts to load subtitles from YouTube's native API
- If no subtitles are available, DeepSRT falls back to the configured SRT providers in priority order
- Each provider is queried until subtitles are found or all providers have been tried
Provider Types
SRT Providers can be implemented in various ways:
- Local Server Provider - A lightweight server running on the user's machine that serves local SRT files
- Remote API Provider - A remote service that provides subtitles via an API
- Curated SRT Store Provider - A repository of curated and verified SRT files
- Custom Provider - Any custom implementation that conforms to the provider interface
Technical Specifications for a Reference Provider Implementation
- Node.js based server (
deepsrt-provider-server) - Zero external dependencies
- Cross-platform support
- CORS enabled
- Optional HTTPS support
Implementation of Reference Provider
NPM Package
npm install -g deepsrt-provider-server
CLI Commands
# Start provider server
deepsrt-provider start [options]
# Show version
deepsrt-provider --version
# Show help
deepsrt-provider --helpFile Structure
/deepsrt-provider/
/subtitles
/{language_code}
/{video_id}.srt
API Endpoint
GET http(s)://{host}:{port}/subtitles/{language_code}/{video_id}.srt
Configuration
{
"host": "0.0.0.0",
"port": 3000,
"subtitlesPath": "./subtitles",
"cors": {
"origin": "*",
"methods": ["GET"]
},
"ssl": {
"enabled": false,
"cert": "path/to/cert.pem",
"key": "path/to/key.pem"
}
}Provider Interface Specification
For a service to act as an SRT Provider, it should implement this interface:
interface SRTProvider {
// Unique identifier for the provider
id: string;
// Display name of the provider
name: string;
// Priority (lower number = higher priority)
priority: number;
// Base URL for the provider (if applicable)
baseUrl?: string;
// Fetch subtitles for a given video ID and language
fetchSubtitles(videoId: string, language: string): Promise<string>;
// Check if this provider supports a given video ID and language
supportsVideo(videoId: string, language: string): Promise<boolean>;
}Extension Integration
- Add SRT Provider management in settings
- Allow adding, removing, and prioritizing providers
- Fallback priority:
- YouTube API (default provider)
- User-defined providers (in priority order)
User Guide for Reference Provider
-
Installation
npm install -g deepsrt-provider-server
-
Directory Setup
mkdir -p ./deepsrt-provider/subtitles/en
-
Add Subtitles
- Name format:
{video_id}.srt - Place in language folder
- Example:
./subtitles/en/dQw4w9WgXcQ.srt
- Name format:
-
Start Server
# Local usage deepsrt-provider start # Remote usage with custom host/port deepsrt-provider start --host 0.0.0.0 --port 8080 # With HTTPS deepsrt-provider start --ssl --cert ./cert.pem --key ./key.pem
-
Configure Extension
- Open DeepSRT settings
- Add provider URL to your server address
- Set provider priority