Finally a working dvdbackup parser
This commit is contained in:
parent
f739a18c23
commit
5d0c35e78c
|
@ -13,52 +13,30 @@ totalSize=$(dvdbackup -I | awk '/[MK]iB$/ { b += $2 } END { print b }')
|
||||||
|
|
||||||
dvdbackup -p -F -n DVD \
|
dvdbackup -p -F -n DVD \
|
||||||
| tr '\r' '\n' \
|
| tr '\r' '\n' \
|
||||||
| awk -F '[ /:]+' '
|
| awk -v total=$totalSize -F '[ /:()]+' '
|
||||||
function update() {
|
function update(bytes) {
|
||||||
print "% " pct;
|
pct = 100 * bytes / total
|
||||||
fflush();
|
if (pct >= nextpct) {
|
||||||
|
print pct
|
||||||
|
fflush()
|
||||||
|
nextpct = pct + 0.5
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/Found [0-9]+ VTS/ {
|
/[MK]iB.$/ {
|
||||||
numTitles = $3;
|
read = $(NF-3) * 1024
|
||||||
title = 1;
|
if ($(NF-1) == "MiB") {
|
||||||
pct = 0;
|
read *= 1024
|
||||||
print "# I found " numTitles " titles"
|
|
||||||
update()
|
|
||||||
}
|
|
||||||
/Copying menu:/ {
|
|
||||||
# Not sure how to know in advance how many of these there will be.
|
|
||||||
print "# We are reading the menu: " $0
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
/Copying Title,/ {
|
|
||||||
# Copying Title, part 1/5: 23% done (239/1024 MiB)
|
|
||||||
part = $4
|
|
||||||
parts = $5
|
|
||||||
done = $6
|
|
||||||
print "# Title " part " of " parts " pct " done
|
|
||||||
titleDone = (part * 100 - 100 + done) / parts;
|
|
||||||
if (titleDone < titleLast) {
|
|
||||||
title += 1;
|
|
||||||
}
|
}
|
||||||
titleLast = titleDone;
|
if (read < last) {
|
||||||
pct = (title * 100 - 100 + pctDone) / numTitles;
|
totalRead += last
|
||||||
update();
|
}
|
||||||
}
|
update(totalRead + read)
|
||||||
{
|
last = read
|
||||||
print "## " $0;
|
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
' \
|
' \
|
||||||
| while read t val; do
|
| while read val; do
|
||||||
case "$t" in
|
setenv complete "$val"
|
||||||
"%")
|
echo "Complete: $val"
|
||||||
setenv complete "$val"
|
|
||||||
echo "Complete: $val"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "$t $val"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue