コード例 #1
0
ファイル: workshoputils.py プロジェクト: Bo98/gmosh
def download(addons, path, extr):
    info = workshopinfo(addons)
    for res in info:
        if not "title" in res:
            print("Addon does not exist!")
            return

        name = res['title']
        download = res['file_url']

        print("Downloading '%s' from the workshop" % name)

        lzmafile = os.path.join(path, "%s.gma.lzma" % res['publishedfileid'])
        outfile = os.path.join(path, "%s.gma" % res['publishedfileid'])

        urllib.request.urlretrieve(download, lzmafile,
            lambda x, y, z: sys.stdout.write("\r{0:.2f}%".format(x * y / z)))
        sys.stdout.write("\r100.00%\n")

        print("Downloaded '%s' from the workshop. Decompressing..." % name)
        with lzma.open(lzmafile) as lzmaF:
            with open(outfile, "wb") as gma:
                gma.write(lzmaF.read())

        os.remove(lzmafile)

        if not extr: return

        name = os.path.join(path, re.sub('[\\/:"*?<>|]+', '_', name))
        gmafile.extract(outfile, name)
コード例 #2
0
ファイル: workshoputils.py プロジェクト: mTxServ/gmosh
def download(addons, extr):
    info = workshopinfo(addons)
    for res in info:
        if not "title" in res:
            print("Addon does not exist!")
            return

        name = res['title']
        download = res['file_url']

        print("Downloading '%s' from the workshop" % name)

        w = Wgety()
        lzmafile = "%s.gma.lzma" % res['publishedfileid']
        outfile = "%s.gma" % res['publishedfileid']
        w.execute(url=download, filename=lzmafile)

        print("Downloaded '%s' from the workshop. Decompressing..." % name)
        with lzma.open(lzmafile) as lzmaF:
            with open(outfile, "wb") as gma:
                gma.write(lzmaF.read())

        os.remove(lzmafile)

        if not extr: return

        name = re.sub('[\\/:"*?<>|]+', '_', name)
        gmafile.extract(outfile, name)
コード例 #3
0
def download(addons, path, extr):
    info = workshopinfo(addons)
    for res in info:
        if not "title" in res:
            print("Addon does not exist!")
            return

        if not "file_url" in res or res['file_url'] == '':
            print("Steam did not provide a direct download URL!")
            return

        name = res['title']
        download = res['file_url']

        print("Downloading '%s' from the workshop" % name)

        lzmafile = os.path.join(path, "%s.gma.lzma" % res['publishedfileid'])
        outfile = os.path.join(path, "%s.gma" % res['publishedfileid'])

        urllib.request.urlretrieve(
            download, lzmafile, lambda x, y, z: sys.stdout.write(
                "\r{0:.2f}%".format(x * y / z * 100)))
        sys.stdout.write("\r100.00%\n")

        print("Downloaded '%s' from the workshop. Decompressing..." % name)
        with lzma.open(lzmafile) as lzmaF:
            with open(outfile, "wb") as gma:
                gma.write(lzmaF.read())

        os.remove(lzmafile)

        if not extr: return

        name = os.path.join(path, re.sub('[\\/:"*?<>|]+', '_', name))
        gmafile.extract(outfile, name)
コード例 #4
0
ファイル: workshoputils.py プロジェクト: mTxServ/gmosh
def download(addons, extr):
    info = workshopinfo(addons)
    for res in info:
        if not "title" in res:
            print("Addon does not exist!")
            return

        name = res['title']
        download = res['file_url']

        print("Downloading '%s' from the workshop" % name)

        w = Wgety()
        lzmafile = "%s.gma.lzma" % res['publishedfileid']
        outfile = "%s.gma" % res['publishedfileid']
        w.execute(url = download, filename = lzmafile)

        print("Downloaded '%s' from the workshop. Decompressing..." % name)
        with lzma.open(lzmafile) as lzmaF:
            with open(outfile, "wb") as gma:
                gma.write(lzmaF.read())

        os.remove(lzmafile)

        if not extr: return

        name = re.sub('[\\/:"*?<>|]+', '_', name)
        gmafile.extract(outfile, name)
コード例 #5
0
ファイル: gmosh.py プロジェクト: mTxServ/gmosh
def extract(gma_files, directories):
    for file in gma_files:
        for output_dir in directories:
            gmafile.extract(file, output_dir)
コード例 #6
0
ファイル: gmosh.py プロジェクト: mTxServ/gmosh
def extract(gma_files, directories):
	for file in gma_files:
		for output_dir in directories:
			gmafile.extract(file, output_dir)