]> git.quilime.com - aggs3.git/commitdiff
Some cleanup and new commands.
authorGabriel Dunne <gdunne@quilime.com>
Wed, 20 Mar 2013 01:38:08 +0000 (18:38 -0700)
committerGabriel Dunne <gdunne@quilime.com>
Wed, 20 Mar 2013 01:38:08 +0000 (18:38 -0700)
agg

diff --git a/agg b/agg
index 80ac30bfe05819a0bdc585b373b7b8e8f7df8443..a54233db1c3e26c8ee950d529cf0334c396f734d 100755 (executable)
--- 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