Created
April 9, 2016 15:21
-
-
Save x1nixmzeng/f027dc3a3fe7e1936d86bc7c87812fcf to your computer and use it in GitHub Desktop.
Soul Worker Update Checker
This file contains 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
#!/usr/bin/env python | |
import io | |
import urllib | |
import zipfile | |
import ConfigParser | |
import datetime | |
# constants | |
sw_base = "http://down.hangame.co.jp/jp/purple/plii/j_sw/" | |
sw_update = sw_base + "j_sw_m.xml" | |
sw_server_ini = "ServerVer.ini" | |
sw_version = sw_base + sw_server_ini + ".zip" | |
# set user-agent | |
class PurpleAgent(urllib.FancyURLopener): | |
version = "purple" | |
urllib._urlopener = PurpleAgent() | |
# | |
print "Soul Worker Update Status" | |
print "----------------------------------------------------" | |
# get config xml | |
#urllib.urlretrieve (sw_update, "update.xml") | |
# returns 3 files we need to patch on opening the launcher: | |
# <rpc> | |
# <OnFirstUIAfter> | |
# <download> | |
# <item path="$(gamefolder)" version="1.0.0.0" overwrite="always">ServerVer.ini</item> | |
# these are zip files "item.zip" | |
# download new data | |
# turple of temporay filename and headers | |
tmp = urllib.urlretrieve (sw_version) | |
myzip = zipfile.ZipFile(tmp[0], 'r') | |
# get version info: | |
config = ConfigParser.RawConfigParser() | |
# hack around patchy unicode support in python 2.6 | |
data = myzip.read(sw_server_ini).translate(None, "\0") | |
config.readfp(io.BytesIO(data)) | |
print "Latest version is ", config.get('Client', 'ver') | |
# last modified: | |
info = myzip.getinfo(sw_server_ini) | |
print "Updated: ", datetime.datetime(*info.date_time) | |
print "----------------------------------------------------" | |
myzip.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ulkyome The game moved from Hangame to WeMade Online so this no longer works 😀