#!/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
    os.chdir("proprietary")
    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":
            print "Extracting %s" % filename
            try:
                zip.extract(filename)
            except:
                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()
