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

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.3.tar.gz (14.1 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.3-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: HoyoDL-0.1.3.tar.gz
  • Upload date:
  • Size: 14.1 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.3.tar.gz
Algorithm Hash digest
SHA256 84ae6ca1eb7853ed1b8ef99644e01a07d8465d47062795beda8346bf37dcfd5b
MD5 3934164412eb9f25d6754f2a609225e0
BLAKE2b-256 8ce7b120c03168314412c5ec297849d93c54140ce9160e7d86957639088f074f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: HoyoDL-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.9 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 12a97a76dc9f4c13c478fd061917c4ea012e667ca79b1532fdfe16f811673c1a
MD5 3afbd3df9e19f3fe3af89072091e09a1
BLAKE2b-256 522dd2ed6346601f2db9f7ac5b6e61cd5338ef108a8c3c317cf85331fe2f5b3e

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