Initial
This commit is contained in:
10
tools/check_error_no_plist.sh
Executable file
10
tools/check_error_no_plist.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
# Will print all ids where error is set to permanent but a plist exists.
|
||||
cd "$(dirname "$0")" || exit
|
||||
|
||||
while read -r uid; do
|
||||
fname="data/$((uid/1000))/$uid"
|
||||
if [ -f "../$fname.plist" ]; then echo "$fname.plist"; fi
|
||||
if [ -f "../$fname.png" ]; then echo "$fname.png"; fi
|
||||
if [ -f "../$fname.jpg" ]; then echo "$fname.jpg"; fi
|
||||
done < <(sqlite3 ../data/ipa_cache.db 'SELECT pk FROM idx WHERE done=4;')
|
||||
10
tools/check_missing_img.sh
Executable file
10
tools/check_missing_img.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
# Find files where a plist exists but an image is missing (should be run after image_optim).
|
||||
cd "$(dirname "$0")" || exit
|
||||
|
||||
for file in ../data/*/*.plist; do
|
||||
if [ ! -f "${file%.plist}.jpg" ]; then
|
||||
idx=${file##*/}
|
||||
echo "${idx%.*}";
|
||||
fi;
|
||||
done
|
||||
21
tools/convert_plist.sh
Executable file
21
tools/convert_plist.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
# Some Info.plist files are in a json-like format. This will convert them to XML.
|
||||
cd "$(dirname "$0")" || exit
|
||||
|
||||
if [ $# = 0 ]; then
|
||||
echo 'Missing uid(s) parameter'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for uid in "$@"; do
|
||||
fname=data/$((uid/1000))/$uid.plist
|
||||
if [ -f "$fname" ]; then
|
||||
res=$(/usr/libexec/PlistBuddy -x -c print "../$fname")
|
||||
if [ $? ]; then
|
||||
echo "overwrite $fname"
|
||||
echo "$res" > "../$fname"
|
||||
fi
|
||||
else
|
||||
echo "does not exist: $fname"
|
||||
fi
|
||||
done
|
||||
52
tools/image_optim.sh
Executable file
52
tools/image_optim.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
# Convert images from .png to .jpg + reduce resolution + shrink filesize.
|
||||
MAX_SIZE=128
|
||||
BATCH_SIZE=50
|
||||
tmp=()
|
||||
|
||||
cd "$(dirname "$0")" || exit
|
||||
|
||||
|
||||
imageOptim() {
|
||||
open --new --wait-apps --background -b net.pornel.ImageOptim --args "$@"
|
||||
}
|
||||
|
||||
optimize() {
|
||||
if [ "${#tmp[@]}" -ge "$1" ]; then
|
||||
echo "imageOptim on ${#tmp[@]} files"
|
||||
imageOptim "${tmp[@]}"
|
||||
tmp=()
|
||||
fi
|
||||
}
|
||||
|
||||
downscale() {
|
||||
IN_FILE=$1
|
||||
OUT_FILE=${IN_FILE%.png}.jpg
|
||||
w=$(sips -g pixelWidth "$IN_FILE" | cut -d: -f2 | tail -1)
|
||||
if [ "$w" -gt $MAX_SIZE ]; then w=$MAX_SIZE; fi
|
||||
sips -Z "$w" "$IN_FILE" -s format jpeg -o "$OUT_FILE" 1> /dev/null
|
||||
tmp+=("$PWD/$OUT_FILE")
|
||||
optimize $BATCH_SIZE
|
||||
}
|
||||
|
||||
# using glob is fine because filenames do not contain spaces
|
||||
total=$(echo ../data/*/*.png | wc -w)
|
||||
total=${total##* }
|
||||
if [ "$total" -lt 2 ]; then
|
||||
if [ "$(echo ../data/*/*.png)" = '../data/*/*.png' ]; then
|
||||
echo "Nothing to do."
|
||||
exit 0;
|
||||
fi
|
||||
fi
|
||||
|
||||
i=0
|
||||
for file in ../data/*/*.png; do
|
||||
i=$((i+1))
|
||||
echo "[$i/$total] sips $file"
|
||||
downscale "$file"
|
||||
if [ -f "${file%.png}.jpg" ]; then
|
||||
rm "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
optimize 1
|
||||
59
tools/plist_server.py
Executable file
59
tools/plist_server.py
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python3
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
from base64 import b64decode
|
||||
import socket
|
||||
import json
|
||||
|
||||
|
||||
def generatePlist(data: dict) -> str:
|
||||
return f'''<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0"><dict><key>items</key><array><dict><key>assets</key><array><dict>
|
||||
<key>kind</key><string>software-package</string>
|
||||
<key>url</key><string>{data.get('u')}</string>
|
||||
</dict><dict>
|
||||
<key>kind</key><string>display-image</string>
|
||||
<key>needs-shine</key><false/>
|
||||
<key>url</key><string>{data.get('i')}</string>
|
||||
</dict></array><key>metadata</key><dict>
|
||||
<key>bundle-identifier</key><string>{data.get('b')}</string>
|
||||
<key>bundle-version</key><string>{data.get('v')}</string>
|
||||
<key>kind</key><string>software</string>
|
||||
<key>title</key><string>{data.get('n')}</string>
|
||||
</dict></dict></array></dict></plist>''' # noqa: E501
|
||||
|
||||
|
||||
class PlistServer(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
try:
|
||||
b64 = self.path.split('?d=')[-1] + '=='
|
||||
print(b64decode(b64))
|
||||
data = json.loads(b64decode(b64)) # type: dict
|
||||
rv = generatePlist(data)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
rv = ''
|
||||
self.send_response(200)
|
||||
self.send_header('Access-Control-Allow-Origin', '*')
|
||||
if rv:
|
||||
self.send_header('Content-type', 'application/xml')
|
||||
self.end_headers()
|
||||
self.wfile.write(bytes(rv, 'utf-8') if rv else b'Parsing error')
|
||||
|
||||
|
||||
def getLocalIp():
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.connect(('10.255.255.255', 80))
|
||||
ip = s.getsockname()[0]
|
||||
s.close()
|
||||
return ip
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
webServer = HTTPServer(('0.0.0.0', 8026), PlistServer)
|
||||
print('Server started http://%s:%s' % (getLocalIp(), 8026))
|
||||
try:
|
||||
webServer.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
webServer.server_close()
|
||||
24
tools/plist_server/index.php
Normal file
24
tools/plist_server/index.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
$X = json_decode(base64_decode($_GET['d']));
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
if ($X->u) {
|
||||
header('Content-Type: application/xml');
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0"><dict><key>items</key><array><dict><key>assets</key><array><dict>
|
||||
<key>kind</key><string>software-package</string>
|
||||
<key>url</key><string>'.$X->u.'</string>
|
||||
</dict><dict>
|
||||
<key>kind</key><string>display-image</string>
|
||||
<key>needs-shine</key><false/>
|
||||
<key>url</key><string>'.$X->i.'</string>
|
||||
</dict></array><key>metadata</key><dict>
|
||||
<key>bundle-identifier</key><string>'.$X->b.'</string>
|
||||
<key>bundle-version</key><string>'.$X->v.'</string>
|
||||
<key>kind</key><string>software</string>
|
||||
<key>title</key><string>'.$X->n.'</string>
|
||||
</dict></dict></array></dict></plist>';
|
||||
} else {
|
||||
echo 'Parsing error.';
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user