From f8eec08d6fa7cd1bb40a72e8c0c79ff986f6b52e Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 11 Jun 2018 19:00:52 +0200 Subject: determine success by output --- odin/strm/download_youtube | 53 +++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/odin/strm/download_youtube b/odin/strm/download_youtube index d6e41865..4d351cd5 100644 --- a/odin/strm/download_youtube +++ b/odin/strm/download_youtube @@ -293,31 +293,36 @@ printf ">>> %s <<<\n %s\n" "${msgId}" "${message}" [[ "${bare_amp}" -ne 0 ]] && p2args+=(-af "${amp}") - local success=false - - if [[ $#prePass -gt 0 ]]; then - args+=(-v info -i ${tempfile}) - - oldPwd=${PWD} - cd $(mktemp -d --tmpdir "transcode.${0:t}.$$.XXXXXX") - cleanup rm -rfv -- ${PWD} - - p1args+=(-an -f matroska) - print -- ${prePass} ${p1args} - ffmpeg ${args} ${prePass} ${p1args} -- /dev/null - - print -- ${cargs} ${p2args} - ffmpeg ${args} ${cargs} ${p2args} -- "${filename}" && success=true - - cd ${oldPwd} - else - args+=(-v warning -i pipe:0) - - print -- ${cargs} ${p2args} - pv -N "$(trimName "trans:" ${title})" ${tempfile} | ffmpeg ${args} ${cargs} ${p2args} -- "${filename}" && success=true - fi + transcodeStdout=$(mktemp --tmpdir "transcode.stdout.${0:t}.$$.XXXXXX") + cleanup rm -rfv -- ${transcodeStdout} + transcodeStderr=$(mktemp --tmpdir "transcode.stderr.${0:t}.$$.XXXXXX") + cleanup rm -rfv -- ${transcodeStderr} + + ( + if [[ $#prePass -gt 0 ]]; then + args+=(-v info -i ${tempfile}) + + oldPwd=${PWD} + cd $(mktemp -d --tmpdir "transcode.${0:t}.$$.XXXXXX") + cleanup rm -rfv -- ${PWD} + + p1args+=(-an -f matroska) + print -- ${prePass} ${p1args} + ffmpeg ${args} ${prePass} ${p1args} -- /dev/null + + print -- ${cargs} ${p2args} + ffmpeg ${args} ${cargs} ${p2args} -- "${filename}" + + cd ${oldPwd} + else + args+=(-v warning -i pipe:0) + + print -- ${cargs} ${p2args} + pv -N "$(trimName "trans:" ${title})" ${tempfile} | ffmpeg ${args} ${cargs} ${p2args} -- "${filename}" + fi + ) >&1 >${transcodeStdout} 2>&2 2>${transcodeStderr} - if ${success}; then + if grep -qv "Invalid encoder type" ${transcodeStdout} ${transcodeStderr}; then printf "Successfully transcoded using transMode=%s\n" ${transMode} break fi -- cgit v1.2.3