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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: HoyoDL-0.1.2.tar.gz
  • Upload date:
  • Size: 13.9 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.2.tar.gz
Algorithm Hash digest
SHA256 fd65b2b08cc4eb41e93269986d23fb2ee8eee1cbc4dfd53930f5a1b6257051b9
MD5 ceaddc1bad1c6935553f93044ed4fb60
BLAKE2b-256 d94d54cc82c66beb0dd820f83e13b18fa51a5edb903b2b7a9fe00f31e8217b2f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: HoyoDL-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e3bc441097d9b10d89cab6cb65259e9462699690af6590553e1f2ef42516ed18
MD5 a2a5f2cdda92850928c8cf682fa90f4f
BLAKE2b-256 9eb1af3d181c7c9660b785bd8fbb6db63e7e4d43f03daf1afc9009e04e3b69e1

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