Skip to main content

Wrapper module for enkanetwork.py for creating character cards.

Project description

Баннер

Русская версия | Example | Discord

EnkaNetworkCard

Wrapper for EnkaNetwork.py to create character cards in Python.

Full Documentation:

En: Documentation EN

Navigation

  • Installation
  • Dependencies
  • Launch
  • Running Async
  • Fix bug with async
  • Get a character showcase
  • Description of arguments
  • Languages Supported
  • Sample Results

Installation:

pip install enkanetworkcard

Or you can copy the given repository.

Dependencies:

Dependencies that must be installed for the library to work:

  • Pillow
  • requests
  • io
  • math
  • threading
  • datetime
  • random
  • enkanetwork
  • logging

Launch:

from enkanetworkcard import encbanner

ENC = encbanner.EnkaGenshinGeneration() 

result = ENC.start(uids = 724281429)

print(result)

Running Async:

from enkanetworkcard import aioenkbanner
import asyncio

async def card():
    ENC = aioenkbanner.EnkaGenshinGeneration()
    return await ENC.start(uids = 724281429)

result = asyncio.run(card()) 

print(result)

Thank you for this example and advice: Gaurav Mandal

Fix bug with async:

Windows users may experience an error: RuntimeError: Event loop is closed if this occurs, then you must set the variable FIX_ASYNCIO_WIN = True

Example

from enkanetworkcard import encbanner

ENC = encbanner.EnkaGenshinGeneration() 
ENC.FIX_ASYNCIO_WIN = True

Get a character showcase:

profile - A useful feature for bot developers. Get information about the characters from the showcase, for their further use.

Example

from enkanetworkcard import encbanner

ENC = encbanner.EnkaGenshinGeneration()
resultProfile = ENC.profile(uid = 724281429, image = False)
result = ENC.start(uids = 724281429, name = resultProfile["charactersArg"])

print(result)

Function: profile returns: characters, charactersArg, img

  • characters - Information about each character.
  • charactersArg - List of character names to quickly pass to start()
  • img - Showcase generated image.

Description of arguments:

Main class: EnkaGenshinGeneration Contains the following arguments lang,img,charterImg,name,adapt,randomImg,hide,dowload,namecard,splash

Class argument description::

  • lang - Takes one value to define the language. Supported languages are listed below in the documentation. The default is Russian.
  • Values: str
  • Example str: EnkaGenshinGeneration(lang = "en")

  • img - If you want to use your image on the card, then pass this argument.
  • Values str: Image link or the path to the file.
  • Values PIL.ImageFile: Image opened with Image.open()
  • Values list: Image link, the path to the file or PIL.ImageFile
  • Example str the path to the file: EnkaGenshinGeneration(img = "img.png")
  • Example str image link: EnkaGenshinGeneration(img = "https//...image.png")
  • Example PIL.ImageFile: EnkaGenshinGeneration(img = Image.open("img.png"))
  • Example list: EnkaGenshinGeneration(img = [Image.open("img.png"), "img.png", "https//...image.png"]) - list only works with the argument: randomImg.

  • charterImg - Give each character a custom image.
  • Values dict: Can take all values from the img argument except list.
  • Example dict: EnkaGenshinGeneration(charterImg = {"Klee": Image.open("img.png"), "Albedo": "img.png", "Xiao": "https//...image.png"})

  • name - Needed if you want to get certain characters.
  • Values: str
  • Example str one character: EnkaGenshinGeneration(name = "Klee")
  • Example str two or more characters: EnkaGenshinGeneration(name = "Klee, Albedo, ...")

  • adapt - Adapt background to custom image.
  • Values: bool
  • Example bool: EnkaGenshinGeneration(img = "img.png", adapt = True)

  • randomImg - Random selection of custom images from the list.
  • Values: bool
  • Example bool: EnkaGenshinGeneration(img = [Image.open("img.png"), "img.png"], randomImg = True) - If img is not a list, then randomImg is ignored.

  • hide - Hide the UID on the character card.
  • Values: bool
  • Example bool: EnkaGenshinGeneration(hide = True)

  • dowload - Will return ready images for further work with them. (If not specified, then the finished results will be saved in the directory of the executable file in the folder and return None: EnkaImg)
  • Values: bool
  • Example bool: EnkaGenshinGeneration(dowload = True)

  • namecard - Replaces the background of the player card image with character images. (Used only for the second template.)
  • Values: bool
  • Example bool: EnkaGenshinGeneration(namecard = True)

  • splash - Displays splashes of characters in costumes
  • Values: bool
  • Example bool: EnkaGenshinGeneration(splash= True)

The main function of the class: start takes template, uids, name argument

Function argument description::

  • uids - Game UID in the game Genshin Impact.
  • Values: int, str
  • Example int: EnkaGenshinGeneration().start(uids = 757562748)
  • Example str one UID: EnkaGenshinGeneration().start(uids = "757562748")
  • Example str two or more UID: EnkaGenshinGeneration().start(uids = "757562748,544523587,874385763")

  • template - Changes the character card template.
  • Values: int
  • Example int: EnkaGenshinGeneration().start(uids = "757562748", template = 2)

  • name - Needed if you want to get certain characters.
  • Values: str
  • Example str one character: EnkaGenshinGeneration(uids = "757562748", name = "Klee")
  • Example str two or more characters: EnkaGenshinGeneration.start(uids = "757562748", name = "Klee, Albedo, ...")

Additional class function: profile takes uid, image argument

  • uid - Game UID in the game Genshin Impact.
  • Values: int
  • Example int: EnkaGenshinGeneration().profile(uids = 757562748)

  • image - Generate a showcase image. (Default True)
  • Values: bool
  • Example bool: EnkaGenshinGeneration().profile(uid = 757562748б, image = False)

Languages Supported

Languege Code Languege Code
English en русский ru
Tiếng Việt vi ไทย th
português pt 한국어 kr
日本語 jp 中文 zh
中文 zh Indonesian id
français fr español es
deutsch de Taiwan cht
Chinese chs

Sample Results:

The result of a custom images and adaptation (template= 1).

Example1 Example2

Usual result (template= 1).

Example3 Example4

The result of a custom images and adaptation (template= 2).

namecard = True namecard = False

Usual result (template= 2).

namecard = True namecard = False

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

enkanetworkcard-0.2.5.tar.gz (32.6 MB view details)

Uploaded Source

Built Distribution

enkanetworkcard-0.2.5-py3-none-any.whl (32.6 MB view details)

Uploaded Python 3

File details

Details for the file enkanetworkcard-0.2.5.tar.gz.

File metadata

  • Download URL: enkanetworkcard-0.2.5.tar.gz
  • Upload date:
  • Size: 32.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.9.11 Windows/10

File hashes

Hashes for enkanetworkcard-0.2.5.tar.gz
Algorithm Hash digest
SHA256 0e0659395ab9bbe1c8155a60093981c404da8ee4c6ac27baa38d3ae6c7122d3d
MD5 05f0f5d42dd87d55cd88f6cd99a8e833
BLAKE2b-256 dbf4517c0cd487f52a10f7ec3c14d40b2f09f115959ebc5f6ba5d5897a618187

See more details on using hashes here.

File details

Details for the file enkanetworkcard-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: enkanetworkcard-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 32.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.9.11 Windows/10

File hashes

Hashes for enkanetworkcard-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0e8e563923a2399d21b58e830e7fa2fa3d8d32cb9e76de81b4e59a68f1c91769
MD5 719307ecc5b1420e2bb7ea05ca9edd1b
BLAKE2b-256 914e46301ca391c780773a9e4520c8cd9f34f6def2257addf455bcf8dfec3d01

See more details on using hashes here.

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