Created
March 21, 2011 11:14
-
-
Save xulapp/879308 to your computer and use it in GitHub Desktop.
MPC HomeCinema installer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| import os | |
| import re | |
| import urllib | |
| import urlparse | |
| import locale | |
| locale.setlocale(locale.LC_ALL, '') | |
| pageurl = 'http://xhmikosr.1f0.de/index.php?folder=bXBjLWhj' | |
| re_fileurl = re.compile(r'(?<=")\./mpc-hc/MPC-HC_r\d+_x86\.7z(?=")') | |
| namelist = r''' | |
| *\Authors.txt | |
| *\COPYING.txt | |
| *\Changelog.txt | |
| *\mpc-hc.exe | |
| *\mpciconlib.dll | |
| *\mpcresources.ja.dll | |
| ''' | |
| def progress(block_count, block_size, total_size): | |
| per = 100 * block_count * block_size / total_size | |
| print '%3d%% (total: %s)\r' % (per, locale.format('%d', total_size, True)), | |
| def main(): | |
| page = urllib.urlopen(pageurl) | |
| for line in page: | |
| x = re_fileurl.search(line) | |
| if x: | |
| break | |
| else: | |
| print u'file url not found.' | |
| return | |
| fileurl = urlparse.urljoin(pageurl, x.group()) | |
| print 'Downloading archive:', fileurl | |
| filename, headers = urllib.urlretrieve(fileurl, reporthook=progress) | |
| listfile = open('.listfile', 'w') | |
| listfile.write(namelist) | |
| listfile.close() | |
| os.system('7z e -y [email protected] "%s"' % filename) | |
| urllib.urlcleanup() | |
| os.remove('.listfile') | |
| print '\ndone' | |
| if __name__ == '__main__': | |
| main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment