Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3
- import sys
- import os
- import urllib
- if len(sys.argv) <= 2 :
- # Print program information if there aren't enough arguments
- print sys.argv[0] + " database pattern"
- print "pattern is a SQL 'LIKE' pattern. i.e. %.unity3d or b/%"
- else :
- # Create a database connection for the database file provided
- conn = sqlite3.connect(sys.argv[1])
- c = conn.cursor()
- # Query for all files that match the given pattern
- c.execute('SELECT name, hash FROM manifests WHERE name LIKE "' + sys.argv[2] + '"')
- # Create the download directory if it doesn't already exist
- if not os.path.exists("dl") :
- os.makedirs("dl")
- count = 0
- failures = 0
- # Loop through all matching rows
- for row in c :
- count += 1
- name = row[0]
- hash = row[1]
- try :
- # Download the file from the correct location based on its file extension
- if name.endswith(".unity3d") :
- print "Downloading asset bundle " + name
- urllib.urlretrieve("http://storage.game.starlight-stage.jp/dl/resources/High/AssetBundles/Android/" + hash, "dl/" + name)
- elif name.endswith(".acb") :
- # Audio files have an extra directory name in the front that needs to be split out
- print "Downloading audio " + name
- slashpos = name.index("/")
- dir = name[:slashpos + 1]
- name = name[slashpos + 1:]
- urllib.urlretrieve("http://storage.game.starlight-stage.jp/dl/resources/High/Sound/Common/" + dir + hash, "dl/" + name)
- elif name.endswith(".mdb") or name.endswith(".bdb") :
- print "Downloading database " + name
- urllib.urlretrieve("http://storage.game.starlight-stage.jp/dl/resources/Generic/" + hash, "dl/" + name)
- else :
- print "Skipping unknown file " + name
- failures += 1
- count -= 1
- except IOError as err :
- # Something went wrong downloading or saving the file
- print "Error downloading " + name + ": " + str(err)
- failures += 1
- count -= 1
- # All files are done, so print the success/failure count
- print "Downloaded " + str(count) + " file(s)"
- if failures > 0 :
- print "Failed to download " + str(failures) + " file(s)"
Add Comment
Please, Sign In to add comment