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

FILENAME="gapps-passion-FRF85B-signed.zip"
MIRRORS=["http://www.kanged.net/mirror/gapps/",]

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

def download():
    try:
        os.makedirs("proprietary")
    except:
        pass
    if len(MIRRORS) > 1:
        i = random.randrange(0, len(MIRRORS)-1)
    else:
        i = 0
    url = MIRRORS[i] + FILENAME
    print "Fetching from %s" % 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: device, download [default: device]")
    (options, args) = parser.parse_args()

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

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

if __name__ == '__main__':
    main()
