-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathimages.sh
executable file
·180 lines (122 loc) · 3.89 KB
/
images.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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/bash
ORIPATH=$PWD
addToSyncedFile () {
DIRZ=${1::-1}
DIRZ=${DIRZ%%\ -steam*}
DIRZ=${DIRZ%%\ -oculus*}
DIRZ=${DIRZ%%\ -versionCode*}
DIRZ=${DIRZ%%\ -packageName*}
DIRZ=${DIRZ%%\ -MP-*}
DIRZ=${DIRZ%%\ -NA-*}
echo "$DIRZ/**" | cut -c 3- >> "$ORIPATH/../blacklist.txt"
}
cd /tmp/mnt
COUNT=0
FAILCOUNT=0
ALLCOUNT=$(ls -l -d */ | grep "^d" | wc -l)
for d in ./*/; do
((COUNT++))
if [[ ! ($d =~ .*\ -steam-.*) ]] && [[ ! ($d =~ .*\ -oculus-.*) ]] && [[ ! ($d =~ .*\ -NA-.*) ]]; then
cd "$d"
SEARCH=${d%%v1.*}
SEARCH=$(echo "$SEARCH" | cut -c 3- | tr -s '_' ' ')
SEARCH=${SEARCH%%v2.*}
SEARCH=${SEARCH%%v3.*}
SEARCH=${SEARCH%%v4.*}
SEARCH=${SEARCH%%v6.*}
SEARCH=${SEARCH%%\[*}
SEARCH=${SEARCH%%v[0-9].*}
SEARCH=${SEARCH%%[0-9].[0-9].*}
SEARCH=${SEARCH%%v[0-9][0-9]*}
SEARCH=${SEARCH%%v[0-9][0-9].*}
SEARCH=${SEARCH%%v1*}
SEARCH=${SEARCH%% - Untethered*}
SEARCH=${SEARCH%%v1*}
echo "Generating $SEARCH for $d"
regex="-packageName-([a-zA-Z\d\_.]*)"
if [[ $d =~ $regex ]]; then
name="${BASH_REMATCH[1]}"
#echo "packagename in map: ${name}"
existingDir=''
existingDir=$(find ../ -maxdepth 1 -type d -name "*${name}*" -print)
if [[ "$existingDir" != "" ]]; then
echo "existingDir found: ${existingDir}"
idregex="-steam-([0-9]*)"
if [[ $existingDir =~ $idregex ]]; then
foundif="${BASH_REMATCH[1]}"
echo "REUSING foundid found: ${foundif}"
DIRZ=${d::-1}
cd ../
mv "$DIRZ" "${d::-1} -steam-${foundif}"
addToSyncedFile "$d"
continue
fi
idregex="-oculus-([0-9]*)"
if [[ $existingDir =~ $idregex ]]; then
foundif="${BASH_REMATCH[1]}"
echo "REUSING foundid found: ${foundif}"
DIRZ=${d::-1}
cd ../
mv "$DIRZ" "${d::-1} -oculus-${foundif}"
addToSyncedFile "$d"
continue
fi
idregex="-NA-"
if [[ $existingDir == *"-NA-"* ]]; then
echo "-NA- found:"
DIRZ=${d::-1}
cd ../
mv "$DIRZ" "${d::-1} -NA-"
addToSyncedFile "$d"
continue
fi
# if [[ "$existingDir" != *"-NA-"* ]]; then
# foundif="${BASH_REMATCH[1]}"
# echo "REUSING foundid found: ${foundif}"
# DIRZ=${d::-1}
# cd ../
# mv "$DIRZ" "${d::-1} -oculus-${foundif}"
# addToSyncedFile "$d"
# continue
# fi
fi
fi
# if compgen -G "${PROJECT_DIR}/*.png" > /dev/null; then
# echo "pattern exists!"
# fi
#sleep 1
# cd ..
# continue
# sleep 19
# exit
link=$(curl -G --silent --data-urlencode "vrsupport=1" --data-urlencode "term=$SEARCH" -L "https://store.steampowered.com/search/" | sed -En '/search_capsule"><img/s/.*src="([^"]*)".*/\1/p' | head -n 1)
link=${link%%\?*}
echo "$link\n"
if [[ "$link" != *".jpg" ]] || [[ "$link" == *"/bundles/"* ]] || [[ "$link" == "" ]] || [[ "$link" != *"jpg" ]] ;then
echo "NOT A REAL IMAGE -> $link"
((FAILCOUNT++))
cd ..
mv "${d::-1}" "${d::-1} -NA-"
continue
fi
if [[ "$link" != "" ]] && [[ "$link" == *"jpg" ]];then
ID=${link%%/capsule_*}
ID=${ID##*apps/}
echo "ID FOUND: $ID"
DIRZ=${d::-1}
#echo "d: $DIRZ"
cd ../
mv "$DIRZ" "${d::-1} -steam-$ID"
else
cd ../
fi
fi
addToSyncedFile "$d"
done
sort -u "$ORIPATH/../blacklist.txt" > "$ORIPATH/../blacklistUNIQUE.txt"
mv "$ORIPATH/../blacklistUNIQUE.txt" "$ORIPATH/../blacklist.txt"
echo "$COUNT items looped"
echo "$FAILCOUNT items failed"
#echo "$(cat $ORIPATH/../quotesynced.txt | wc -l) from quotesynced.txt"
paplay /usr/share/sounds/ubuntu/ringtones/Bliss.ogg
sleep 99