Skip to content

Instantly share code, notes, and snippets.

@toresbe
Created November 20, 2022 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toresbe/6db3faf2d98afcd0a8028340d8f739e5 to your computer and use it in GitHub Desktop.
Save toresbe/6db3faf2d98afcd0a8028340d8f739e5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
ENDPOINT_URL=http://10.102.38.194
S4_ARGS="--endpoint-url $ENDPOINT_URL "
cd /mnt/media
for file in */original/*; do
VIDEO_ID=$(echo "${file}" | cut -f1 -d/)
TARGET_PATH="s3://${BUCKET}/${VIDEO_ID}_O_$(basename "${file}")"
if s4cmd $S4_ARGS put "${file}" "${TARGET_PATH}"; then
echo -n "Successfully copied: "
echo $VIDEO_ID,${TARGET_PATH} | tee -a ~/copied_videos
else
echo -n "ERROR COPYING: "
echo $VIDEO_ID,${TARGET_PATH} | tee -a ~/not_copied_videos
fi
done
for file in */broadcast/*; do
VIDEO_ID=$(echo "${file}" | cut -f1 -d/)
TARGET_PATH="s3://${BUCKET}/${VIDEO_ID}_B_$(basename "${file}")"
if grep -e ^${VIDEO_ID}, ~/copied_videos; then
echo "Skipping broadcast of video ${VIDEO_ID} as the original was copied"
echo $VIDEO_ID | tee -a ~/skipped_videos
fi
if s4cmd $S4_ARGS put "${file}" "${TARGET_PATH}"; then
echo -n "Successfully copied: "
echo $VIDEO_ID,${TARGET_PATH} | tee -a ~/copied_videos
else
echo -n "ERROR COPYING: "
echo $VIDEO_ID,${TARGET_PATH} | tee -a ~/not_copied_videos
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment