Aves_mio0.88/copy_progressive_ts_output.sh
2026-10-03 12:51:15 +02:00

99 lines
2 KiB
Bash
Executable file

#!/usr/bin/env bash
set -u
output_directory="progressive_ts_output"
package_name="deckers.thibault.aves.debug"
remote_directory="cache/fmp4_progressive_ts_test"
rm -rf "$output_directory"
mkdir -p "$output_directory"
echo "Attendo l'installazione del package..."
while ! adb shell pm path "$package_name" >/dev/null 2>&1; do
sleep 1
done
echo "Package disponibile."
echo "Attendo la playlist completa..."
while true; do
if ! adb shell run-as "$package_name" \
test -s "$remote_directory/master.m3u8" \
>/dev/null 2>&1
then
sleep 1
continue
fi
playlist=$(
adb exec-out run-as "$package_name" \
cat "$remote_directory/master.m3u8" \
2>/dev/null
)
if ! printf '%s\n' "$playlist" |
grep -qF '#EXT-X-ENDLIST'
then
echo "Playlist presente ma non ancora completa..."
sleep 1
continue
fi
echo "Playlist completa trovata, avvio copia..."
copy_failed=0
for name in \
master.m3u8 \
segment_00000.ts \
segment_00001.ts \
segment_00002.ts \
segment_00003.ts \
segment_00004.ts
do
temporary="$output_directory/$name.tmp"
final="$output_directory/$name"
rm -f "$temporary" "$final"
if ! adb exec-out run-as "$package_name" \
cat "$remote_directory/$name" \
>"$temporary" 2>/dev/null
then
echo "Copia ADB fallita: $name"
rm -f "$temporary"
copy_failed=1
continue
fi
bytes=$(wc -c <"$temporary" | tr -d ' ')
if [ "$name" = "master.m3u8" ]; then
minimum_bytes=100
else
minimum_bytes=1000000
fi
if [ "$bytes" -lt "$minimum_bytes" ]; then
echo "File non valido: $name, $bytes byte"
rm -f "$temporary"
copy_failed=1
continue
fi
mv "$temporary" "$final"
echo "Copiato $name: $bytes byte"
done
if [ "$copy_failed" -eq 0 ]; then
echo
echo "Tutti i file sono stati copiati:"
ls -lh "$output_directory"
exit 0
fi
echo "Copia incompleta, nuovo tentativo..."
sleep 1
done