Skip to content

Commit

Permalink
update_checker: check game version online and download yup file
Browse files Browse the repository at this point in the history
  • Loading branch information
klensy committed Aug 5, 2020
1 parent 0beba79 commit ca4218f
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ bencode.py==4.0.0

# for diffing jsons
jsondiff==1.2.0

# for http requests
requests==2.24.0
12 changes: 8 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
src_path = "src/wt_tools/"
packages = []
includes = []
excludes = ["socket", "unittest", "http", "email", "pydoc", "construct.examples", "bz2"]
excludes = ["unittest", "pydoc", "construct.examples", "bz2"]
includefiles = [os.path.join(src_path, "./formats/blk.lark"), os.path.join(src_path, '../../README.md')]
zip_include_packages = ["collections", "construct", "ctypes", "encodings", "json", "logging", "importlib", "formats",
"zstandard", "xml", "urllib", "distutils", "click", "pkg_resources", "colorama", "bencodepy",
"jsondiff"]
"jsondiff", "requests", "chardet", "idna", "urllib3", "email", "http"]


blk_unpack = Executable(
Expand Down Expand Up @@ -45,15 +45,19 @@
script=os.path.join(src_path, "update_differ.py"),
)

update_checker = Executable(
script=os.path.join(src_path, "update_checker.py"),
)

setup(
name="wt_tools",
version="0.2.2.6-dev",
version="0.2.2.7-dev",
author='klensy',
description="War Thunder resource extraction tools",
url="https://github.com/klensy/wt-tools",
options={"build_exe": {"includes": includes, "excludes": excludes, "include_files": includefiles,
"packages": packages, "zip_include_packages": zip_include_packages,
"path": sys.path + [src_path]}},
executables=[blk_unpack, clog_unpack, ddsx_unpack, dxp_unpack, vromfs_unpacker, wrpl_unpacker, blk_minify,
update_differ]
update_differ, update_checker]
)
48 changes: 48 additions & 0 deletions src/wt_tools/update_checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from urllib.parse import urlparse

import click
import requests


def check_versions_online():
"""check"""
tag_list = ["", "dev", "dev-stable", "production-rc", "test", "nightly", "tournament", "experimental",
"ps4submission", "xbox-submission", "experimental2", "china-test", "china-dev"]
headers = {"User-Agent": "wt-tools"}
versions_url = "https://yupmaster.gaijinent.com/yuitem/get_version.php?proj=warthunder&tag={}"

s = requests.Session()
s.headers.update(headers)
for tag in tag_list:
r = s.get(versions_url.format(tag))
# if any valid version
if r.text != "NOITEM":
print(tag if tag else "default", r.text)


def download_yup(tag):
headers = {"User-Agent": "wt-tools"}
yup_url = "https://yupmaster.gaijinent.com/yuitem/get_version_yup.php?proj=warthunder&tag={}"
r = requests.get(yup_url.format("" if tag == "default" else tag), headers=headers)
for line in r.text.split():
# get the first good link
if line.startswith("https"):
name = urlparse(line).path.strip('/')
r = requests.get(line, headers=headers)
with open("{}.{}".format(tag, name), 'wb') as f:
f.write(r.content)
break


@click.command()
@click.option('--check_versions', is_flag=True, default=False)
@click.option('--download_yup', "tag")
def main(check_versions, tag):
if check_versions:
check_versions_online()
elif tag:
download_yup(tag)


if __name__ == '__main__':
main()

0 comments on commit ca4218f

Please sign in to comment.