dustin / gopro

Tools for making the most out of GoPro Plus.
http://dustin.sallings.org/2020/04/29/gopro-plus.html
BSD 3-Clause "New" or "Revised" License
91 stars 12 forks source link

Error 422 during upload #24

Open mkueh opened 1 year ago

mkueh commented 1 year ago

Hello,

I have a problem. During my upload process, I get the following error:

StatusCodeException (Response {responseStatus = Status {statusCode = 422, statusMessage = "Unprocessable Entity"}

and direct under that, there is another one:

"{\"errors\":[{\"code\":6105,\"description\":\"cache value is nil for this request: {DerivativeID:2381467954777687236 UploadID:n3sa.1SZig0dRoUoyUFNhsNgD1UTCqrywDS3IvDAWzH4ZwWunImUIcvdY7leQa0XYWvJjyiUIjqmv4yLzqoOoXSD.gui7WsTPmr9xc1AKTTe7mXDe7HjUSdTbwydRVqy ItemNumber:1 CameraPosition:default TranscodeSource: FileSize:2732485278 PartSize:6291456 Page:1 PerPage:435 :0}\"}

do i miss something?

chapterjason commented 6 months ago

Abort the upload, run gopro cleanup and run gopro upload only on a single file. Multiple files seams to be the issue.

I've created a small bash script to automate the uploads.

#!/usr/bin/env bash

set -euo pipefail

CURRENT_DIRECTORY="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
QUEUE_DIRECTORY="$CURRENT_DIRECTORY/queue"
COMPLETED_DIRECTORY="$CURRENT_DIRECTORY/completed"

CONCURRENCY=15

function upload_file() {
  local FILE="$1"

  local RESULT="$(gopro upload "$FILE" -v --upload-concurrency "$CONCURRENCY" 2>&1 | tee /dev/tty)"

  if echo "$RESULT" | grep -q 'Finished uploading'; then
    move_file "$FILE" "$COMPLETED_DIRECTORY"
  fi
}

function move_file() {
  local FILE="$1"
  local DIR="$2"

  local FILENAME="$(basename "$FILE")"
  local NEW_FILE="$DIR/$FILENAME"

  mv "$FILE" "$NEW_FILE"
}

function upload_dir() {
  local DIR="$1"

  find "$DIR" -type f -name '*.MP4' -o -name '*.jpg' | while read -r FILE; do
    echo "Uploading $FILE"
    upload_file "$FILE"
  done
}

if [ ! -d "$QUEUE_DIRECTORY" ]; then
  mkdir -p "$QUEUE_DIRECTORY"
fi

if [ ! -d "$COMPLETED_DIRECTORY" ]; then
  mkdir -p "$COMPLETED_DIRECTORY"
fi

upload_dir "$QUEUE_DIRECTORY"
dustin commented 6 months ago

I didn't notice this bug.

I get errors like this occasionally from the service, it's pretty annoying.

@chapterjason

I'm not sure a script like that would work for me. I tend to upload a directory at a time (~ an outing) which consists of multiple shots, some of which are multi-chapter. This script would split a single take into multiple different media entries which would be undesirable.

Otherwise, this is approximately what gopro upload $QUEUE_DIRECTORY does already (± occasional service errors). Right now, I've got around 20k files uploaded as about 7k media.

As I mentioned, I've occasionally run into service issues where I have to either wait for cache invalidation or just clear and resend whole clips. That's a bug on their end I can't do much about since it involves them telling me I can upload something and then later telling me the thing they told me was invalid. Kind of unfortunate, but luckily I don' see it super often.

antonsn commented 5 months ago

Hi @dustin is it possible to change the code so if this error happens to continue with futher files instead of breaking?