--- /dev/null
+#!/usr/bin/python
+
+import json, sys, os, time
+import subprocess
+
+yellow = '\033[0;33m'
+green = '\033[0;92m'
+purple = '\033[0;95m'
+red = '\033[0;91m'
+
+endc = '\033[0m'
+s3_bucket="s3://agg/"
+s3_url="http://agg.s3.amazonaws.com/"
+
+def main():
+
+ if len(sys.argv) <= 2:
+ print """must have 2 arguments"""
+ exit()
+
+ action = sys.argv[1]
+ #media_path_obj =
+ media_filename = os.path.split(sys.argv[2])[-1]
+
+ if action == "ul":
+
+ # check to see if file exists
+ p = subprocess.Popen("s3cmd ls " + s3_bucket + "v/" + media_filename, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ for line in p.stdout.readlines():
+ print line,
+ print red + "File exists." + endc
+ exit()
+ retval = p.wait()
+
+ # start new entry
+ new_entry = get_new_entry(media_filename)
+
+ print green + "Uploading to s3..." + endc
+ p = subprocess.Popen("s3cmd put --acl-public --guess-mime-type " + media_filename + " " + s3_bucket + "v/" + media_filename, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ for line in p.stdout.readlines():
+ print line,
+ retval = p.wait()
+
+ with open('data.json', 'r') as f:
+ data = json.load(f)
+
+ #print purple + json.dumps(new_entry, indent = 2) + endc
+ #exit()
+
+ data['entries'].append(new_entry)
+ with open('data.json', 'w') as f:
+ json.dump(data, f)
+
+
+ elif action == "dl":
+ print "download"
+
+
+
+
+def get_new_entry(filename):
+ new_entry = { "filename" : filename, "added" : int(time.time()) }
+ new_entry['url'] = s3_url + "v/" + filename
+ new_entry['link'] = get_user_input("link ")
+ new_entry['title'] = get_user_input("title ")
+ new_entry['desc'] = get_user_input("desc ")
+ return new_entry
+
+
+def get_user_input(question):
+ while True :
+ sys.stdout.write(yellow + question + "\t" + endc)
+ choice = raw_input()
+ return choice
+
+
+
+if __name__ == "__main__":
+ main()
--- /dev/null
+#!/usr/bin/env bash
+
+ACTION=$1
+VID=$2
+TIMESTAMP=$(date +%s)
+S3_BUCKET="s3://agg/"
+
+if [ -z "$ACTION" ]
+then
+ echo "Action is not defined."
+ exit
+fi
+if [ -z "$VID" ]
+then
+ echo "Video is not defined."
+ exit
+fi
+
+if [ "dl" = "$ACTION" ]
+then
+ echo "downloading $VID"
+# ~/_code/youtube-dl/youtube-dl -o "%(stitle)s-%(id)s-%(autonumber)s.%(ext)s" $VID
+fi
+if [ "ul" = "$ACTION" ]
+then
+ echo "uploading to: $S3_BUCKET"v/"$VID"
+ s3cmd put "$VID" "$S3_BUCKET"v/"$VID"
+
+ ## append data
+ DATA="https://s3.amazonaws.com/agg/v/$VID"
+
+ read -r -p "Origin: " URL
+ DATA="$DATA | $URL"
+
+ read -r -p "Title: " TITLE
+ DATA="$DATA | $TITLE"
+
+ read -r -p "Description: " DESC
+ DATA="$DATA | $DESC"
+
+ ## download datafile
+ echo "downloading datafile"
+ s3cmd get "$S3_BUCKET"data.json --force
+
+ echo "appending new entry"
+ echo "$DATA" >> "data.json"
+
+
+
+ echo "uploading new datafile"
+ s3cmd put data.json "$S3_BUCKET"data.json
+
+fi
+
+