mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-09-13 20:04:45 +08:00
31 lines
779 B
Bash
Executable File
31 lines
779 B
Bash
Executable File
#!/bin/sh
|
|
|
|
ytdlp() {
|
|
url=$1
|
|
output=$2
|
|
/usr/bin/yt-dlp $url -o $output
|
|
}
|
|
|
|
handleRequest() {
|
|
action=$1
|
|
|
|
if [ "$action" = "list" ]; then
|
|
echo "{\"download\":{\"description\":\"Download video\",\"params\":{\"url\":{\"type\":\"string\",\"description\":\"Video URL\"}}}}"
|
|
elif [ "$action" = "call" ]; then
|
|
method=$2
|
|
|
|
if [ "$method" = "download" ]; then
|
|
output="/tmp/yt-dlp-output.mp4"
|
|
read url
|
|
ytdlp "$url" "$output"
|
|
result="{\"result\":\"ok\",\"data\":{\"url\":\"$url\",\"output\":\"$output\"}}"
|
|
echo "$result"
|
|
else
|
|
errorResult="{\"result\":\"error\",\"message\":\"Unknown method\"}"
|
|
echo "$errorResult"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
handleRequest "$@"
|