Skip to main content

Download any game file at any version of Hoyo games

Project description

HoyoDL

Download any file at any version from Hoyo games, with additional utilities.

Setting up

First, create an instance of the class :

>>> import HoyoDL
>>> client = HoyoDL(game="hk4e", version="5.5")

You can also specify the game and version separately :

>>> client = HoyoDL()
>>> client.setGame("hk4e")
>>> client.setVersion("5.4")

The list of games is as follow :

Game Game ID Minimum supported version
Genshin Impact hk4e 2.3
Honkai: Star Rail hkrpg 1.5
Zenless Zone Zero nap 1.1

Downloading a file

To download a file, call downloadFile() and specify its path, the game and version must be defined :

>>> dl = client.downloadFile("GenshinImpact.exe")
>>> dl = client.downloadFile("GenshinImpact_Data/app.info")

This functions returns a requests.Response object, you can then use it to save your file :

>>> file = "GenshinImpact.exe"
>>> dl = client.downloadFile(file)
>>>
>>> with open(file, "wb") as f:
>>>     f.write(dl.content)

Or if you want to have a progress along with it, save it in chunks :

>>> file = "GenshinImpact.exe"
>>> dl = client.downloadFile(file)
>>> 
>>> with open(file, "wb") as f:
>>> 	for chunk in dl.iter_content(chunk_size=8192): # use chunk size of your choice
>>> 		f.write(chunk)

The tool also provides a shortcut function to download a block file using downloadBlock(), this functions returns a requests.Response object too :

>>> client = HoyoDL(game="hkrpg", version="3.1")
>>> block = "000a8acede9ed8aea7a8c3281a2f7ebd" # file extension is automatically added upon request as it differs between games
>>> dl = client.downloadBlock(block) # will download 000a8acede9ed8aea7a8c3281a2f7ebd.block

⚠️ Genshin uses folders for blocks, so you must add the folder name in the block name to download correctly :

>>> client = HoyoDL(game="hk4e", version="5.5")
>>> block = "00/35323818"
>>> dl = client.downloadBlock(block) # will download 00/35323818.blk

If you don't want to have a requests.Response object but rather a URL directly, you can use getFileURL() instead :

>>> client = HoyoDL(game="hk4e", version="5.5")
>>> url = client.getFileURL("GenshinImpact.exe")
>>> print(url)
"https://autopatchhk.yuanshen.com/client_app/download/pc_zip/20250314110016_HcIQuDGRmsbByeAE/ScatteredFiles/GenshinImpact.exe"

Getting files names

If you don't know what files you can have, or want to get lists easily, you can call the following functions, each will return a list of files, each file being a dictionary in the following structure :

{
  "name": "path/to/file.ext",
  "md5": "md5 hash",
  "size": "size in bytes"
}

To get all blocks :

>>> files = client.getAllBlockFiles()
>>> dl = client.downloadFile(files[0]["name"])

To get all audio files :

>>> files = client.getAllAudioFiles()

To get all cutscenes files :

>>> files = client.getAllCutscenesFiles()

ℹ️ When running any of these functions for the first time may take a few additional seconds as the tool is fetching the list, afterwards it will be cached for future calls until the game or version is changed

Getting miscellaneous information

After selecting a game and version, you can get the date of when this version was released to the servers :

>>> client = HoyoDL(game="hk4e", version="2.7")
>>> date = client.getReleaseDate()
>>> print(date)
"April 29th, 2022 at 11:24:15"

You can also get the timestamp directly if you don't want the formatted date, the output will be in the form YYYYmmddHHMMSS :

>>> date = client.getReleaseDate(raw=True)
>>> print(date)
20220429112415

You can also get the version hash if necessary :

>>> hash = client.getHash()
>>> print(hash)
"20220429112415_dDweiEHDnBI6cKmM"

Customizing the data

This tool works by using what is called a provider json file, this file contains all the games, versions and hashes for each version, the default file is hosted here, but you may want to also make your own to add custom games or add missing version. In theory this file is self updating everytime a game update but just in case this options is available.

To do so, create a json file in the same structure as the official one, host it wherever you want and pass the url to it when initializing the tool :

>>> client = HoyoDL(provider="https://example.com/path/file.json")

Contributing

Any help or contributions to this tool are greatly appreciated, or, if this helped you, a star is also welcome (^∀^●)ノシ

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

HoyoDL-0.1.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

HoyoDL-0.1.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file HoyoDL-0.1.1.tar.gz.

File metadata

  • Download URL: HoyoDL-0.1.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.18

File hashes

Hashes for HoyoDL-0.1.1.tar.gz
Algorithm Hash digest
SHA256 eaed7f724a3e1632c41e18e5e0820e4eff3274d5712bae2bbe397952746ea7a1
MD5 c0eebef13df394a14677c3e3d99d77be
BLAKE2b-256 5ec0b6960547b752cea87cf80d38dc7c16297ff7f5eb56a6381994589b58f641

See more details on using hashes here.

File details

Details for the file HoyoDL-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: HoyoDL-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.18

File hashes

Hashes for HoyoDL-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4d49c6a3ba123eab9d7107c71776c6f79b68be5a60fbe883e5b88bff6c77831f
MD5 efa430bff66133c5dd8b8c59819e12b1
BLAKE2b-256 422dff80ad701b94b163e7331357b914d6b7679aa4f17f6c0de052cde3592809

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page