#!/usr/bin/env python
import sys, random, urllib2, zipfile, StringIO, os
from optparse import OptionParser

FILENAME=["gapps-hdpi-20101008-signed.zip","gapps-mdpi-20101008-signed.zip","gapps-mdpi-tiny-20101008-signed.zip"]
VERSIONS=["hdpi","mdpi","mdpi-tiny"]
MIRRORS=["http://mirror.teamdouche.net/get/various/",]

def device():
    print "usage: get-google-files -m [method] -v [version]"
    print "Note:  Device method is currently not implemented, please use download"
    sys.exit(1)

def download(version):
    try:
        os.makedirs("proprietary")
    except:
        pass
    if len(MIRRORS) > 1:
        i = random.randrange(0, len(MIRRORS)-1)
    else:
        i = 0

    try:
        j = VERSIONS.index(version.lower())
    except ValueError:
	print "GApps version not found, defaulting to HDPI"
        j = 0

    url = MIRRORS[i] + FILENAME[j]

    print "Fetching %s GApps from %s" % (version.upper(),url)

    data = urllib2.urlopen(url).read()
    zip = zipfile.ZipFile(StringIO.StringIO(data),'r')
    
    for filename in zip.namelist():
        if filename.split("/")[0] == "system" and filename[-1] != "/":
            print "Extracting %s" % filename
            try:
                bytes = zip.read(filename)
                fd = open("proprietary/"+os.path.basename(filename),"wb")
                fd.write(bytes)
                fd.close()
            except Exception, e:
                print e
                pass

def main():
    parser = OptionParser(usage="usage: %prog [options]")
    parser.add_option("-m", "--method", dest='method', default="download", help="Extraction Method: download")
    parser.add_option("-v", "--version", dest='version', default="hdpi", help="GApps Version: hdpi, mdpi, mdpi-tiny [default: hdpi]")
    (options, args) = parser.parse_args()

    if options.method == "device":
        return device()

    if options.method == "download":
        return download(options.version)

if __name__ == '__main__':
    main()
