The SRT Parser API is a web service that accepts SubRip Text (SRT) format data and returns the parsed content in JSON format. It is designed to be used by applications that need to process subtitle files and extract timing and textual data.
To parse SRT content, send a POST request to /parse_srt
with the SRT file content as plain text in the body of the request. You can optionally include char_limit
and millis_limit
as query parameters to combine captions based on character count or milliseconds. You must include an X-API-KEY
in the header for authentication.
Example using curl
:
curl -X POST http://<cloud_run_url>/parse_srt \
-H "X-API-KEY: YourAPIKey" \
-H "Content-Type: text/plain" \
--data-binary @yourfile.srt
The response will be a JSON array of subtitle entries, potentially combined based on the specified limits. Each entry contains the content and start/end timings in milliseconds.
Example response:
[
{
"index": 1,
"content": "Subtitle text here",
"start": 1000,
"end": 5000
},
...
]
After deploying the application, you can access the auto-generated Swagger API documentation at /apidocs
endpoint.
The default authentication method is an API key sent as a header (X-API-KEY
). The key must match the one set in the environment variable API_KEY
.
The application uses Python's logging module to log information to standard error (stderr). After each request, it logs the IP address, the request method, URL scheme, path, and the response status. Logging helps monitor the application's usage and troubleshoot issues.
- Create a new project on Google Cloud Platform (GCP).
- Enable the Cloud Run and Cloud Build APIs for your project.
- Install and initialize the Google Cloud SDK on your local machine.
- Authenticate with GCP:
gcloud auth login
- Submit a build to Cloud Build and deploy to Cloud Run:
gcloud builds submit --tag gcr.io/your-project-id/your-app-name
gcloud run deploy --image gcr.io/your-project-id/your-app-name --platform managed
- Connect your GitHub repository to Cloud Build.
- Set up a trigger on Cloud Build to automatically build and deploy your application to Cloud Run whenever changes are pushed to your repository.
SRT (SubRip Subtitle) is a file format used to store subtitles for video content. It contains the sequence of subtitles with their corresponding start and end times, allowing video players to display subtitles in sync with the video.
X-API-KEY
: A secret key that verifies the user is authorized to use the API.- SRT Content: The actual subtitle text that you want to convert to JSON.
index
: A number that represents the order of the subtitle in the video.content
: The text of the subtitle that should appear on the screen.start
: The time (in milliseconds) when the subtitle should appear.end
: The time (in milliseconds) when the subtitle should disappear.
The API takes the SRT content, reads through it, and breaks it down into a list where each item is a chunk of text with its timing information. This allows other applications to use subtitle data in various ways, such as displaying them on different media players or analyzing the text for further processing.
For more details and updates, please visit our GitHub repository or contact our support team.