-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseene-backup-privates.sh
executable file
·55 lines (44 loc) · 1.49 KB
/
seene-backup-privates.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# http://seene.co backuper
# Usage: ./seene-backup.sh your_seene_nick
# Author: Alexander Petrossian (PAF) <[email protected]>
# Repo: https://github.com/neopaf/seene-backup
if [ -z "$AUTHORIZATION" ]
then
echo "Contact author to learn how to get your authorisation in"
exit 1
fi
user=$1
if [ -z "$user" ]
then
echo "Usage: $0 your_seen_nick"
exit 1
fi
folder=$user.private
echo "Resolving name to id"
id=$(curl -s http://seene.co/api/seene/-/users/@$user|jq .id)
last=500
echo "Getting index of last $last private seenes"
curl -# \
-H "Authorization: $AUTHORIZATION" \
-H 'Accept: application/vnd.seene.co; version=3,application/json' \
--create-dirs \
"https://oecamera.herokuapp.com/api/users/$id/scenes?count=$last&only_private=1" \
-o "$folder/index.json"
echo "Converting index to seenes.xls"
cat "$folder/index.json"|sed 's/\\n/ /g'| jq -c -r '.scenes[] | .captured_at+" "+.caption+if .links|length>0 then " ("+([.links | .[] | .target] | join(" "))+")" else "" end + "\t" + .poster_url + "\t" + .model_url'>"$folder/scenes.xls"
IFS=$'\t'
function download {
url="$1"
file="$2"
curl --progress-bar --continue-at - --create-dirs $url -o "$file"
}
echo "Downloading last $last seenes (not ALL)"
cat "$folder/scenes.xls"|while read -r title poster_url model_url
do
echo "$title"
title=$(echo "$title"|sed 's/\//~/g')
download "$poster_url" "$folder/$title/poster.jpg"
download "$model_url" "$folder/$title/scene.oemodel"
done
echo "Done"