Skip to main content

Add your description here

Project description

RiotManifest

riot提供的manifest文件进行解析下载

介绍

目前的功能是可以传入URL或本地文件目录,解析manifest文件,下载文件。

大部分代码都来自于CommunityDragon/CDTB项目,感谢他们的工作。

PatcherManifest进行修改使其支持URL manifest文件下载,细化filter_files方法,使其支持正则表达式过滤文件。

PatcherFile增加download_file方法,使其支持文件下载。并且使用aiohttp进行异步下载。默认并发数为50,并发数可以通过实例化PatcherManifestconcurrency_limit参数进行设置; 也可以调用PatcherFiledownload_file方法时传入concurrency_limit参数进行设置。

安装

pip3 install riotmanifest

使用

  • 异步多并发下载(不推荐)
import asyncio
from riotmanifest import PatcherManifest
async def main():
    bundle_url = 'https://lol.dyn.riotcdn.net/channels/public/bundles/'
    manifest = PatcherManifest(
      r"https://lol.secure.dyn.riotcdn.net/channels/public/releases/CB3A1B2A17ED9AAB.manifest",
      path=r'E:\out',
      bundle_url=bundle_url)
    
    
    files = list(manifest.filter_files(flag='zh_CN', pattern='wad.client'))

    await manifest.download_files_concurrently(files, 5)



if __name__ == '__main__':
    asyncio.run(main())

注意,单个文件的下载并发是50,download_files_concurrently方法是对多个文件进行并发下载。建议这个数不要超过10,否则有封IP的风险(实测PatcherManifest传入100,download_files_concurrently传入10,后台可查最大线程为800+,正常执行,量力而行)。

  • ManifestDownloader外壳
from riotmanifest.external_manifest import ResourceDL

rdl = ResourceDL(r'E:\out')
rdl.d_game = True
rdl.download_resources('content-metadata.json')

直接调用开源程序Morilli/ManifestDownloader直接下载,具体查看函数文档

自动从GitHub下载可执行文件,保存至temp目录,默认使用代理

  • WADExtractor
from riotmanifest.extractor import WADExtractor

we = WADExtractor("DE515F568F4D9C73.manifest")
data = we.extract_files(
    {
        "DATA/FINAL/Champions/Aatrox.wad.client": [
            "data/characters/aatrox/skins/skin0.bin",
            "data/characters/aatrox/skins/skin1.bin",
            "data/characters/aatrox/skins/skin2.bin",
            "data/characters/aatrox/skins/skin3.bin",
        ],
        "DATA/FINAL/Champions/Ahri.wad.client": [
            "data/characters/Ahri/skins/skin0.bin",
            "data/characters/Ahri/skins/skin1.bin",
            "data/characters/Ahri/skins/skin2.bin",
            "data/characters/Ahri/skins/skin3.bin",
        ]
    }
)
print(len(data))

该方法无需下载完整WAD文件,直接从manifest中计算需要解包的文件位置,直接获取,减少网络请求。

维护者

Virace

感谢

许可证

GPLv3

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

riotmanifest-1.1.0.tar.gz (29.5 kB view hashes)

Uploaded Source

Built Distribution

riotmanifest-1.1.0-py3-none-any.whl (29.3 kB view hashes)

Uploaded Python 3

Supported by

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