Skip to content

Instantly share code, notes, and snippets.

@hlorand
Last active May 18, 2022 22:47
Show Gist options
  • Select an option

  • Save hlorand/991f17329f64f0496bcc5377287d1690 to your computer and use it in GitHub Desktop.

Select an option

Save hlorand/991f17329f64f0496bcc5377287d1690 to your computer and use it in GitHub Desktop.
Uploads files to your archive.org account
#!/bin/bash
#######################
# Usage:
# ./upload.sh <foldername> <filename>
#
# Foldername must be globally unique.
# Fill in the USER and PASS variable below.
#
# Known issues: filename with spaces or filename with full or relative path
#
# see more:
# https://archive.org/services/docs/api/internetarchive/cli.html#getting-started
USER="..."
PASS="..."
# Do not modify below
#########################
FOLDER=$1
FILE=$2
# check parameters
if [ "$#" -lt 2 ]; then
echo 'Usage: ./upload.sh UniqueFolderName FileName'
exit 1
fi
# check if ia binary downloaded
if [ ! -f ./ia ];
then
echo "ia binary does not exists, downloading"
wget --quiet https://archive.org/download/ia-pex/ia
fi
# check config file
if [ ! -f /home/$USER/.config/internetarchive/ia.ini ]
then
./ia configure --username=$USER --password=$PASS
fi
# upload
./ia upload $FOLDER $FILE
echo "Waiting for server to return HTTP 200"
while true
do
if wget -q --spider https://archive.org/download/"$FOLDER"/"$FILE"; then
break
fi
echo -n "."
sleep 5
done
echo DONE
echo https://archive.org/download/"$FOLDER"/"$FILE"
open https://archive.org/download/"$FOLDER"/"$FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment