Skip to content

Instantly share code, notes, and snippets.

@naps62
Last active September 10, 2025 15:57
Show Gist options
  • Select an option

  • Save naps62/c1432c66f6c2e666b3feedc158dd57fb to your computer and use it in GitHub Desktop.

Select an option

Save naps62/c1432c66f6c2e666b3feedc158dd57fb to your computer and use it in GitHub Desktop.
post-processing script for translating subtitles to target lang after english download
#!/usr/bin/env bash
# Usage: translate.sh -p {{subtitles}} -s {{series_id}} -i {{episode_id}} -t {{target_lang}}
SUBTITLES="$1"
SERIES_ID="$2"
EPISODE_ID="$3"
TARGET_LANG="$4"
API_KEY="YOUR_API_KEY"
API_URL="http://localhost:6767/api/subtitles"
# if no arguments are passed, show help
if [ $# -eq 0 ]; then
echo "Usage: $0 -p pathReferenceSRT -i id -s seriesId"
exit 1
fi
if [[ "$1" == "--" ]]; then
shift
fi
echo args
echo $0
echo $1
echo $2
echo $3
echo end
while getopts p:s:t:i: flag
do
case "${flag}" in
p) pathReferenceSRT=${OPTARG};;
i) id=${OPTARG};;
s) seriesId=${OPTARG};;
t) targetLang=${OPTARG};;
esac
done
echo $targetLang
if [ -z "$seriesId" ]; then
type="movie"
else
type="episode"
fi
editedpathReferenceSRT=$(echo $pathReferenceSRT | sed 's/\//%2F/g' | sed 's/\ /%20/g')
url="http://localhost:6767/api/subtitles?action=translate&language=$targetLang&path=$editedpathReferenceSRT&type=$type&id=$id"
# Send request
response=$(curl -s -X PATCH "$url" -H 'accept: application/json' -H "X-API-KEY: $API_KEY")
# echo response and result code
echo $url
echo "Result code: $?"
echo $response#!/bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment