Allow checking for unsubmitted video files
This commit is contained in:
parent
95c8b982bf
commit
a55294e7e4
16
main.rb
16
main.rb
@ -83,11 +83,27 @@ post '/video' do
|
||||
{ status: 'ok' }.to_json
|
||||
end
|
||||
|
||||
post '/check' do
|
||||
content_type 'application/json'
|
||||
|
||||
ids = JSON.parse(request.body.read)
|
||||
|
||||
videos = Video
|
||||
.left_outer_joins(:downloads)
|
||||
.where(randname: ids)
|
||||
.pluck(:randname, :sha256, :size)
|
||||
.map { |v| %w[randname sha256 size].zip(v).to_h }
|
||||
|
||||
{ videos: videos }.to_json
|
||||
end
|
||||
|
||||
|
||||
get '/config.json' do
|
||||
content_type 'application/json'
|
||||
{
|
||||
videos_url: "https://sapo.pxto.pt/videos.json",
|
||||
upload_url: "https://sapo.pxto.pt/video",
|
||||
check_url: "https://sapo.pxto.pt/check",
|
||||
max_amount: 100_000,
|
||||
}.to_json
|
||||
end
|
||||
|
17
saca-sapos
17
saca-sapos
@ -80,6 +80,20 @@ download() {
|
||||
fi
|
||||
}
|
||||
|
||||
unknown() {
|
||||
CONFIG="$(get_config)"
|
||||
SAPO_CHECK_VIDEOS_URL="$(echo "$CONFIG" | jq -r .check_url)"
|
||||
|
||||
find videos/ -name "*.mp4" |
|
||||
sed -e 's|videos/\(.*\).mp4|\1|g' |
|
||||
xargs -n1000 |
|
||||
sed -e 's/ /","/g' -e 's/^/["/' -e 's/$/"]/' |
|
||||
while read body; do
|
||||
echo "$body" | curl --silent --json "@-" "$SAPO_CHECK_VIDEOS_URL"
|
||||
done |
|
||||
jq -rc '.videos[]|select(.sha256==null)|("videos/" + .randname + ".mp4")'
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"download")
|
||||
indexer "$2" "$3"
|
||||
@ -87,6 +101,9 @@ case "$1" in
|
||||
"single")
|
||||
download "$2"
|
||||
;;
|
||||
"unknown")
|
||||
unknown
|
||||
;;
|
||||
"stats")
|
||||
BYTES="$(du -b videos/ | awk '{print $1}')"
|
||||
NUM="$(ls -1 videos/ | wc -l)"
|
||||
|
Loading…
Reference in New Issue
Block a user