From 7d86462c8e1e0055d3a59bb95566827f312e14bf Mon Sep 17 00:00:00 2001 From: Gabriel Dunne Date: Tue, 19 Mar 2013 18:38:08 -0700 Subject: [PATCH] Some cleanup and new commands. --- agg | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/agg b/agg index 80ac30b..a54233d 100755 --- a/agg +++ b/agg @@ -1,7 +1,27 @@ #!/usr/bin/env bash -ACTION=$1 -FILE=$2 +USAGE="Usage: agg COMMAND [parameters] + +agg is a script for downloading media files and +uploading them to an S3 bucket. The scripts stores +metadata in a sqlite3 database. + +Commands: + Upload media file + agg ul file.mpg + Download media from external Site with youtube-dl + agg dl http://www.youtube.com/watch?v=ZUdHX1Bent0 + Download database to Local + agg pull-data + Upload database to S3 + agg push-data + Publish on remote website + agg publish + List folder on S3 + agg ls [folder]" +[[ -n "$1" ]] || { echo "$USAGE"; exit 1 ; } + +COMMAND=$1 c_yellow='\033[0;93m' c_green='\033[0;92m' @@ -28,10 +48,10 @@ image_folder='i/' declare -a video_types=('video/mp4' 'video/avi' 'video/fla'); declare -a image_types=('image/jpg' 'image/jpeg' 'image/png' 'image/gif'); - -if [ -z $ACTION ]; then +if [ -z $COMMAND ]; then exit -elif [[ "ul" = $ACTION && $FILE ]]; then +elif [[ "ul" = $COMMAND && $2 ]]; then + FILE=$2 # get mime type mimetype=$(file -b --mime-type $FILE) @@ -61,15 +81,15 @@ elif [[ "ul" = $ACTION && $FILE ]]; then # put file on s3 echo -e $c_green"Put file on s3..."$c_end s3cmd put -v --acl-public --guess-mime-type "$FILE" "$S3_BUCKET$FOLDER$FILENAME" - -elif [ "pull-data" = $ACTION ]; then +elif [ "ls" = $COMMAND ]; then + s3cmd ls $S3_BUCKET$2/ +elif [ "pull-data" = $COMMAND ]; then s3cmd get -v "$S3_BUCKET$DB" -elif [ "push-data" = $ACTION ]; then +elif [ "push-data" = $COMMAND ]; then s3cmd put -v --acl-public "$DB" "$S3_BUCKET$DB" - echo -e "$c_green"Pulling new DB to quilime"$c_end" -elif [ "push-remote" = $ACTION ]; then +elif [ "publish" = $COMMAND ]; then ssh quilime@quilime.com "cd ~/media.quilime.com/vid/; curl -O http://agg.s3.amazonaws.com/agg.db" -elif [ "dl" = $ACTION ]; then - echo "downloading $FILE" -# ~/_code/youtube-dl/youtube-dl -o "%(stitle)s-%(id)s-%(autonumber)s.%(ext)s" $FILE +elif [[ "dl" = $COMMAND && 2 ]]; then + echo "downloading $2" + ~/_code/youtube-dl/youtube-dl -o "%(stitle)s-%(id)s-%(autonumber)s.%(ext)s" $2 fi -- 2.34.1