home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 13075 / imas.7z / imas.py
Encoding:
Python Source  |  2017-07-04  |  1.4 KB  |  41 lines

  1. from urllib.request import ProxyHandler, build_opener, install_opener, urlretrieve
  2. from itertools import islice
  3. from multiprocessing.dummy import Pool as ThreadPool
  4. import csv
  5. import os
  6. pool = ThreadPool(10)
  7.  
  8. if not os.path.exists("Imas2"):
  9.     os.makedirs("Imas2")
  10. #proxy = urllib.request.ProxyHandler({'http': 'http://192.168.1.91:8888'})
  11. proxy = ProxyHandler({})
  12. opener = build_opener(proxy)
  13. opener.addheaders = [('X-Unity-Version','5.4.5p1'),('User-Agent','Dalvik/1.6.0 (Linux; U; Android 4.4.4; GT-P5210 Build/KTU84P)')]
  14. install_opener(opener)
  15.  
  16.  
  17. def geturl(file,link):
  18.     try:
  19.         #print(file)
  20.         urlretrieve('http://storage.game.starlight-stage.jp/dl/resources/High/AssetBundles/Android/' + link, 'Imas2\\' + file)
  21.         #urlretrieve('http://storage.game.starlight-stage.jp/dl/resources/High/AssetBundles/iOS/' + link, 'Imas2\\' + file)
  22.         
  23.     except:
  24.         pass
  25. def chunk(it, size):
  26.     it = iter(it)
  27.     return iter(lambda: tuple(islice(it, size)), ())
  28.  
  29.  
  30. with open('manifests.csv', "rt" ) as theFile:
  31.     reader = csv.DictReader( theFile )
  32.     result = {}
  33.     for row in reader:
  34.         for column, value in row.items():
  35.             result.setdefault(column, []).append(value)
  36.     names = (list(chunk(result['name'], 100)))
  37.     hashes = (list(chunk(result['hash'], 100)))
  38.     for i in range(0,len(names)):
  39.         pool.starmap(geturl, zip(names[i], hashes[i]))
  40.         print(str(100*(i + 1)) + '/' + str(len(names) * 100))
  41.