-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetTranscript
executable file
·39 lines (32 loc) · 928 Bytes
/
getTranscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Ensure jq is available for JSON formatting (optional)
format_json=false
if command -v jq &>/dev/null; then
format_json=true
fi
# Function to print usage
usage() {
echo "Usage: $0 <video_url>"
exit 1
}
# Check if a URL is provided as an argument
[ -z "$1" ] && usage
# Input parameters
VIDEO_URL="$1"
API_URL="https://tactiq-apps-prod.tactiq.io/transcript"
# Make the POST request using curl
response=$(curl -s -X POST "$API_URL" \
-H "Content-Type: application/json" \
-d "{\"videoUrl\": \"$VIDEO_URL\", \"langCode\": \"en\"}")
# Check for errors in the response
if [ -z "$response" ]; then
echo "Error: No response from the server. Please check your internet connection or API URL."
exit 1
fi
# Print the response
echo "Transcript Response copied !"
if $format_json; then
echo "$response" | jq -r '.captions[].text' | xclip -selection clipboard
else
echo "$response"
fi