Skip to main content

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, it may take a few additional seconds as the tool is fetching the files 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 date as number directly if you don't want the formatted one, the output will be in the form YYYYmmddHHMMSS :

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

It is also possible to get the latest version of the game :

>>> client = HoyoDL(game="hk4e")
>>> latest = client.getLatestVersion()
>>> print(latest)
"5.5"
>>> client.setVersion(latest)

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 (^∀^●)ノシ

Metadata

Release files for HoyoDL 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for HoyoDL 0.1.3
File Size Uploaded
HoyoDL-0.1.3.tar.gz 14.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for HoyoDL 0.1.3
File Interpreter ABI Platform
HoyoDL-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 26.0 kB

Release files / HoyoDL-0.1.3.tar.gz

Download URL HoyoDL-0.1.3.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
84ae6ca1eb7853ed1b8ef99644e01a07d8465d47062795beda8346bf37dcfd5b
BLAKE2b-256 checksum
How to use checksums
8ce7b120c03168314412c5ec297849d93c54140ce9160e7d86957639088f074f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.18

Release files / HoyoDL-0.1.3-py3-none-any.whl

Download URL HoyoDL-0.1.3-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12a97a76dc9f4c13c478fd061917c4ea012e667ca79b1532fdfe16f811673c1a
BLAKE2b-256 checksum
How to use checksums
522dd2ed6346601f2db9f7ac5b6e61cd5338ef108a8c3c317cf85331fe2f5b3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.18

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page