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

FILENAME=["gapps-gb-20110307-signed.zip","gapps-hdpi-20101114-signed.zip","gapps-mdpi-20110501-signed.zip","gapps-mdpi-tiny-20101020-signed.zip","gapps-mdpi-tegra-20101020-signed.zip","gapps-passion-EPE54B-signed.zip","gapps-ds-ERE36B-signed.zip","DRC83_base_defanged.zip"]
VERSIONS=["gb","hdpi","mdpi","mdpi-tiny","tegra","cm5hdpi","cm5mdpi","cm4"]
MIRRORS=["http://goo-inside.me/gapps/","http://android.d3xt3r01.tk/cyanogen/gapps/"]

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(os.path.join(os.path.dirname(__file__), "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(os.path.join(os.path.dirname(__file__), "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="gb", help="GApps Version: gb, hdpi, mdpi, mdpi-tiny, tegra, cm5hdpi, cm5mdpi, cm4 [default: gb]")
    (options, args) = parser.parse_args()

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

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

if __name__ == '__main__':
    main()
