Skip to content

Instantly share code, notes, and snippets.

@lupettohf
Created April 11, 2014 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lupettohf/10488514 to your computer and use it in GitHub Desktop.
Save lupettohf/10488514 to your computer and use it in GitHub Desktop.
Misterix2 Dowloader
# -*- coding:utf-8 -*-
##.__ ______ ________
##| | ____ ________/ __ \/ __ \
##| | _/ __ \\___ /> <\____ /
##| |_\ ___/ / // -- \ / /
##|____/\___ >_____ \______ / /____/
## \/ \/ \/
## Downloader by lupettohf -*- Versione 1.0.0
##
import urllib2
import zipfile
import os
import requests
## -+- Variabili -+-
url = "https://misterix2.acegamer.it/MISTERIX2.zip"
unzipdir = os.getcwd()
zipfileloc = os.getcwd() + "/MISTERIX2.zip"
## Controllo sistema operativo
from sys import platform as _platform
if _platform == "linux" or _platform == "linux2":
osS = "Linux"
elif _platform == "darwin":
osS = "Mac Os X (LEZZOH!)"
## Downloader con progresso.
file_name = url.split("/")[-1]
u = urllib2.urlopen(url)
f = open(file_name, "wb")
meta = u.info()
file_size = int(meta.getheaders("Content-Length")[0])
os.system("clear") ## <--- pulisce il terminale
print(" __ .__ ________ ")
print(" _____ ___.__. _______/ |_ ___________|__|__ ___ \_____ \ ")
print(" / < | |/ ___/\ __\/ __ \_ __ \ \ \/ / / ____/ ")
print("| Y Y \___ |\___ \ | | \ ___/| | \/ |> < / \ ")
print("|__|_| / ____/____ > |__| \___ >__| |__/__/\_ \ \_______ \ ")
print(" \/\/ \/ \/ \/ \/ ")
print(" Sistema operativo %s" %(osS))
print "-*- Download in corso: %s Bytes: %s -*-" % (file_name, file_size)
file_size_dl = 0
block_sz = 8192
while True:
buffer = u.read(block_sz)
if not buffer:
break
file_size_dl += len(buffer)
f.write(buffer)
status = r"%10d [%3.2f%%]" % (file_size_dl, file_size_dl * 100. / file_size)
status = status + chr(8)*(len(status)+1)
print status,
f.close()
## Unzippa la Misterix2
print ("Download completato. Non chiudere la finestra, sto estraendo il file zip...")
mxzip = zipfile.ZipFile(zipfileloc)
mxzip.extractall(unzipdir)
print("Unzip Completato")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment