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

FILENAME=["gapps-gb-20110120-signed.zip","gapps-gb-tegra-20110118-signed.zip","gapps-hdpi-20101114-signed.zip","gapps-mdpi-20101020-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","gb-tegra","hdpi","mdpi","mdpi-tiny","tegra","cm5hdpi","cm5mdpi","cm4"]
MIRRORS=["http://goo-inside.me/gapps/","http://android.d3xt3r01.tk/cyanogen/gapps/","http://android.local.host.name/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, gb-tegra, 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()
