-
Notifications
You must be signed in to change notification settings - Fork 0
/
seene-backup-set.sh
executable file
·60 lines (51 loc) · 1.81 KB
/
seene-backup-set.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
56
57
58
59
60
#!/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
#https://seene.co/a/QoUPEL/
user="$1"
id="$2"
set_title="$3"
if [ -z "$user" ]
then
echo "Usage: $0 user id set_title"
exit 1
fi
#https://seene.co/api/seene/-/albums/112/scenes?count=200
echo "$id $user $set_title"
last=2000
echo "Getting index of last $last seenes"
folder="$user/$set_title"
curl -# --create-dirs "https://seene.co/api/seene/-/albums/$id/scenes?count=$last" -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|.[0:200]|sub(" ";"_")), .poster_url, .model_url, .short_code]|@tsv'>"$folder/scenes.xls"
IFS=$'\t'
function download {
url="$1"
file="$2"
curl --progress-bar --continue-at - --create-dirs $url -o "$file"
}
echo "Preparing copy script for $last seenes (not ALL)"
rm -f $folder/cp.sh
rm -f $folder/cp.bat
echo "mkdir \"$set_title\"" >> $folder/cp.sh
echo "mkdir \"$set_title\"" >> $folder/cp.bat
echo "cd \"$set_title\"" >> $folder/cp.sh
echo "cd \"$set_title\"" >> $folder/cp.bat
cat "$folder/scenes.xls"|while read -r title poster_url model_url short_code
do
echo "cp ../*$short_code* ." >> $folder/cp.sh
echo "copy ..\*$short_code* ." >> $folder/cp.bat
done
echo see $folder/cp.sh
#exit 1
echo "Downloading last $last seenes (not ALL)"
cat "$folder/scenes.xls"|while read -r title poster_url model_url short_code
do
echo "$title"
title=$(echo "$title"|sed 's/\//~/g'|sed 's/[ \t]*$//')
download "$poster_url" "$folder/$title/poster.jpg"
download "$model_url" "$folder/$title/scene.oemodel"
done
echo "Done"