Apktool 2.9.2
[opengapps/opengapps.git] / get_speechfiles.sh
blob16cdfb7099d4d134a7ea75ea52b9687027694324
1 #!/bin/bash
2 #This file is part of The Open GApps script of @mfonville.
4 # The Open GApps scripts are free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # These scripts are distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
15 a="/$0"; a=${a%/*}; a=${a#/}; a=${a:-.}; TOP=$(cd "$a"; pwd -P) || exit 1
16 SOURCES="$TOP/sources"
17 SCRIPTS="$TOP/scripts"
18 SPEECHFOLDER="$SOURCES/all/usr/srec/en-US"
19 # shellcheck source=scripts/inc.buildhelper.sh
20 . "$SCRIPTS/inc.buildhelper.sh"
21 # shellcheck source=scripts/inc.tools.sh
22 . "$SCRIPTS/inc.tools.sh"
24 # Check tools
25 checktools coreutils gunzip wget
27 manifesturl="https://www.gstatic.com/android/voicesearch/production_2016_04_08_14_33_37_6f706ca387f0e3cce36bb34e19fa76338283fb206c10da9a9f90426e"
28 fileurls="$(wget -q -O - "$manifesturl" | grep -a en-US | grep -a -o -E "http.*en-US[^.]*.zip")"
29 versions="$(echo "$fileurls" | grep -o -E "/v[0-9]+/")"
30 useversion="0"
31 for version in $versions; do
32 if [ "${version:2:-1}" -gt "$useversion" ]; then
33 useversion="${version:2:-1}"
35 done
36 if [ "$useversion" -gt "0" ]; then
37 tmpfile="$(mktemp)"
38 wget -q -O "$tmpfile" "$(echo "$fileurls" | grep "$useversion" | head -n 1)"
39 install -d "$SPEECHFOLDER"
40 unzip "$tmpfile" -d "$SPEECHFOLDER"
41 rm "$tmpfile"
42 else
43 echo "No valid en-US version found in online manifest"