home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 16653 / imas.7z / imas.py
Encoding:
Python Source  |  2019-08-25  |  1.9 KB  |  58 lines

  1. from urllib.request import ProxyHandler, build_opener, install_opener, urlopen
  2. import lz4
  3. import lz4.block
  4. from itertools import islice
  5. from multiprocessing.dummy import Pool as ThreadPool
  6. import csv
  7. import os
  8. import struct
  9.  
  10. pool = ThreadPool(100)
  11.  
  12. if not os.path.exists("Imas2"):
  13.     os.makedirs("Imas2")
  14. #proxy = urllib.request.ProxyHandler({'http': 'http://192.168.1.91:8888'})
  15. proxy = ProxyHandler({})
  16. opener = build_opener(proxy)
  17. opener.addheaders = [('X-Unity-Version','2018.3.8f1'),('User-Agent','Dalvik/2.1.0 (Linux; U; Android 7.1.2; SM-G955N Build/NRD90M)')]
  18. install_opener(opener)
  19.  
  20.  
  21.  
  22. def geturl(file,link):
  23.     try:
  24.         #print(file)
  25.         #myFile = urlopen('http://storage.game.starlight-stage.jp/dl/resources/High/AssetBundles/Android/' + link).read()
  26.         #myFile = urlopen('http://storage.game.starlight-stage.jp/dl/resources/High/AssetBundles/iOS/' + link).read()
  27.         link = link[0:2] + '/' + link
  28.         #print(link)
  29.         #print(('http://asset-starlight-stage.akamaized.net/dl/resources/AssetBundles/' + link))
  30.         myFile = urlopen('http://asset-starlight-stage.akamaized.net/dl/resources/AssetBundles/' + link).read()
  31.         #print(myFile[18:25])
  32.         size,zsize = struct.unpack('2I', myFile[4:12])
  33.         #print(size,zsize)
  34.         myArr = lz4.block.decompress(myFile[16:],size)
  35.         #print(myArr)
  36.         #myArr = myFile
  37.         with open('Imas2\\' + file, 'wb') as f:
  38.             f.write(myArr)
  39.         
  40.     except:
  41.         pass
  42. def chunk(it, size):
  43.     it = iter(it)
  44.     return iter(lambda: tuple(islice(it, size)), ())
  45.  
  46.  
  47. with open('manifests-ios.csv', "rt" ) as theFile:
  48.     reader = csv.DictReader( theFile )
  49.     result = {}
  50.     for row in reader:
  51.         for column, value in row.items():
  52.             result.setdefault(column, []).append(value)
  53.     names = (list(chunk(result['name'], 100)))
  54.     hashes = (list(chunk(result['hash'], 100)))
  55.     for i in range(0,len(names)):
  56.         pool.starmap(geturl, zip(names[i], hashes[i]))
  57.         print(str(100*(i + 1)) + '/' + str(len(names) * 100))
  58.