-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (76 loc) · 3.17 KB
/
release.yml
File metadata and controls
85 lines (76 loc) · 3.17 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Create Release
on:
push:
branches:
- master
jobs:
restore:
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.FTOKEN }}
with:
tag_name: v${{ github.run_number }}
release_name: Release v${{ github.run_number }}
draft: false
prerelease: false
- name: File Restorer
env:
GITHUB_TOKEN: ${{ secrets.FTOKEN }}
UPLOAD_URL: ${{ steps.create_release.outputs.upload_url }}
run: |
pip install -q tqdm
sudo apt install -qq ffmpeg -y
git clone --filter=blob:none --no-checkout --depth 1 https://github.com/intlect/FileStore.git
cd FileStore
DIRS=$(git ls-tree -d HEAD | awk '{print $4}' | grep -v github)
cd .. && rm -rf FileStore
for dir in $DIRS; do
echo $dir
git clone --filter=blob:none --no-checkout --depth 1 https://github.com/intlect/FileStore.git
cd FileStore
git sparse-checkout init --cone
git sparse-checkout set $dir
git checkout
if [[ "$dir" == *mkv* ]]; then
ext="mkv"
python main.py restore --file "../$dir.mkv" --dir "$dir"
else
ext="mp4"
python main.py restore --file "../$dir.mp4" --dir "$dir"
fi
cd .. && rm -rf FileStore
FILE="$dir.$ext"
FILE_SIZE=$(stat -c%s "$FILE")
MAX_SIZE=$((2 * 1024 * 1024 * 1024))
FILENAME=$(basename "$FILE")
CONTENT_TYPE=$(file --mime-type -b "$FILE")
FILE_UPLOAD_URL="${UPLOAD_URL/\{\?name,label\}/?name=$(basename "$FILE")}"
if [ "$FILE_SIZE" -le "$MAX_SIZE" ]; then
curl -s \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: $CONTENT_TYPE" \
--upload-file "$FILE" \
"${FILE_UPLOAD_URL}"
else
DURATION=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$FILE")
HALF_DURATION=$(echo "$DURATION / 2" | bc)
ffmpeg -i "$FILE" -c copy -t "$HALF_DURATION" "${FILE}.part1.$ext"
ffmpeg -i "$FILE" -c copy -ss "$HALF_DURATION" "${FILE}.part2.$ext"
for part in "${FILE}.part"*.${ext}; do
PART_NAME=$(basename "$part")
PART_CONTENT_TYPE=$(file --mime-type -b "$part")
PART_UPLOAD_URL="${UPLOAD_URL/\{\?name,label\}/?name=$PART_NAME}"
curl -s \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: $PART_CONTENT_TYPE" \
--upload-file "$part" \
"${PART_UPLOAD_URL}"
rm -f "$part"
done
fi
rm -f "$FILE"
done