Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
DEViantUA authored Feb 29, 2024
1 parent 055a789 commit 02a7256
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 21 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ An asynchronous module and API that allows you to connect to your bot the genera
:white_medium_square: [Generation results](https://github.com/DEViantUA/EnkaCard/wiki/Resultate)<br>
:white_medium_square: [StarRailCard](https://github.com/DEViantUA/StarRailCard)<br>
:white_medium_square: [Additional module](https://github.com/DEViantUA/ENCard)<br>
:white_medium_square: [Assets](https://github.com/DEViantUA/EnkaCardData)
:white_medium_square: [Assets](https://github.com/DEViantUA/EnkaCard)
## Installation:
```
pip install enkacard
Expand Down Expand Up @@ -76,6 +76,7 @@ result = asyncio.run(main())
print(result)
```
> _**Aliternative method: [Tools](https://github.com/DEViantUA/EnkaCard/wiki/Tools)**_
</details>

## Languages Supported
Expand Down
5 changes: 4 additions & 1 deletion enkacard/encbanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ async def creat(self, template = 1, akasha = False, snow = False):
if not generator.get(key.id,None) is None:
gen_tools.append(generator.get(key.id))
continue

if str(key.id) == "10000092":
key.image.banner.url = "https://api.ambr.top/assets/UI/UI_Gacha_AvatarImg_Gaming.png"
elif str(key.id) == "10000093":
key.image.banner.url = "https://api.ambr.top/assets/UI/UI_Gacha_AvatarImg_Liuyun.png"
art = None
if self.character_art:
if str(key.id) in self.character_art:
Expand Down
18 changes: 16 additions & 2 deletions enkacard/enkatools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
from io import BytesIO
import aiohttp
from contextlib import AsyncExitStack
import magic

import_magic = False

try:
import magic
except ImportError:
import_magic = True
import imghdr

IMAGE_TYPES = {
'image/jpeg',
Expand Down Expand Up @@ -58,7 +65,14 @@ async def download_image(session, url, headers=None, allow_redirects=True, use_r
async def get_mimetype(session, url, size=2048, allow_redirects=True, **kwargs):
async with session:
data = await download_image(session, url, size=size, allow_redirects=allow_redirects, **kwargs)
return magic.Magic(mime=True).from_buffer(data)
if import_magic:
mime_type = imghdr.what(None, h=data)
if mime_type:
return mime_type
else:
return "application/octet-stream"
else:
return magic.Magic(mime=True).from_buffer(data)

async def is_valid(session, url, allow_redirects=True, **kwargs):
async with session:
Expand Down
Binary file added enkacard/src/assets/font/GSEnochian.ttf
Binary file not shown.
Binary file added enkacard/src/assets/font/Genshin_Impact.ttf
Binary file not shown.
19 changes: 16 additions & 3 deletions enkacard/src/generator/akasha_rank.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import aiohttp
import random
from ..utils import pill, git
from PIL import ImageDraw,Image

Expand All @@ -7,6 +8,10 @@
api_url = "https://akasha.cv/api/getCalculationsForUser/{uid}"
api_update = "https://akasha.cv/api/user/refresh/{uid}"

#https://akasha.cv/api/leaderboards/{uid}/{hash}?variant=profilePage - ПОЛУЧИТЬ ХАШ ОБЩИЙ И ДЛЯ ПЕРСОНАЖЕЙ
#https://akasha.cv/api/substatPriority/{uid}/{hash} - ПОЛУЧИТЬ ИНФОРМАЦИЮ О СТАТАХ ПЕРСОНАЖА


data_akasha = {}

class AkashaCreat:
Expand All @@ -15,15 +20,23 @@ def __init__(self,card = None,teample= None,rank= None,uid= None) -> None:
self.teample = teample
self.rank = rank
self.uid = uid


async def get_hash(self, charter_id):
async with aiohttp.ClientSession() as session:
async with session.get(api_url.format(uid = self.uid)) as response:
data = await response.json()
for key in data["data"]:
if str(charter_id) == str(key["characterId"]):
return key["md5"]

async def update(self):
async with aiohttp.ClientSession() as session:
async with session.get(api_update.format(uid = self.uid)) as response:
return await response.json()

async def get_info_character(self, id):
url = f'https://akasha.cv/api/leaderboards/qusoleum/{id}?type=current'

hash = await self.get_hash(id)
url = f'https://akasha.cv/api/leaderboards/{self.uid}/{hash}?variant=profilePage'
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
if response.status == 200:
Expand Down
2 changes: 2 additions & 0 deletions enkacard/src/generator/profile_teample_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ async def creat_avatar_info(self):

async def creat_charter(self,key):
background = Image.new("RGBA", (180, 263), (0,0,0,0))
if self.img is None:
self.img = {}
if str(key.id) in self.img:
url = self.img[str(key.id)]
else:
Expand Down
4 changes: 3 additions & 1 deletion enkacard/src/generator/teample_two.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ async def creat_diagram(self):
akashaElement = False
data_user = []

dataAkasha = await AkashaCreat().get_info_character(self.character.id)
dataAkasha = await AkashaCreat(uid = self.uid).get_info_character(self.character.id)
if dataAkasha == []:
dataAkasha = {}
if dataAkasha != {}:
dataAkasha = dataAkasha[random.choice(list(dataAkasha.keys()))]['stats']
dataAkasha_new = []
Expand Down
Binary file added enkacard/src/pickle_cashe/data_characters.pkz
Binary file not shown.
Empty file.
5 changes: 4 additions & 1 deletion enkacard/src/utils/diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import font_manager
from pathlib import Path

font_path = 'enkacard\\src\\assets\\total\\font\\Genshin_Impact.ttf'
assets = assets = Path(__file__).parent.parent / 'assets'

font_path = str(assets / 'font' / 'Genshin_Impact.ttf')

custom_font = font_manager.FontProperties(fname=font_path)
plt.rcParams['font.family'] = custom_font.get_name()
Expand Down
1 change: 0 additions & 1 deletion enkacard/src/utils/enkanetwork_update/pathfinding.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys
import os
import json

async def search():
python_paths = sys.path
Expand Down
12 changes: 6 additions & 6 deletions enkacard/src/utils/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@

_cache = TTLCache(maxsize=1000, ttl=300)

assets = Path(__file__).parent.parent / 'assets'
_BASE_URL = 'https://raw.githubusercontent.com/DEViantUA/EnkaCardData/main/assets/'

font = str(assets /'total'/'font' / 'Genshin_Impact.ttf')
fontKH = str(assets /'total'/ 'font' / 'GSEnochian.ttf')
assets = Path(__file__).parent.parent / 'assets'

font = str(assets / 'font' / 'Genshin_Impact.ttf')
fontKH = str(assets / 'font' / 'GSEnochian.ttf')

async def change_Font(x):
global font
if x == 0:
font = str(assets /'total' / 'font' / 'Genshin_Impact.ttf')
font = str(assets / 'font' / 'Genshin_Impact.ttf')
else:
font = str(assets /'total' / 'font' / 'GSEnochian.ttf')

font = str(assets / 'font' / 'GSEnochian.ttf')
mapping = {
"artifact_bg": "one/artifact_bg.png",
"artifact_bg_none": "one/artifact_bg_none.png",
Expand Down
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "enkacard"
version = "3.1.2"
version = "3.2.9"
description = "An asynchronous module and API that allows you to connect to your bot the generation of Genshin character cards from the Enka.Network website."
authors = ["None"]

Expand All @@ -12,16 +12,15 @@ homepage = "https://github.com/DEViantUA/EnkaCard"
[tool.poetry.dependencies]
python = "^3.10"
Pillow = "^10.0.1"
"enkanetwork.py" = "^1.4.5"
"enkanetworkv2.py" = "^2.0.0"
cachetools = "^5.2.0"
asyncache = "^0.3.1"
numpy = "^1.24.2"
more-itertools = "^10.1.0"
aiofiles = "^23.2.1"
pydantic = "1.10.13"
matplotlib = "^3.8.2"
python-magic = "^0.4.27"
python-magic-bin = "^0.4.14"
python-magic = { platform = "windows", version = "^0.4.27" }
python-magic-bin = { platform = "windows", version = "^0.4.14" }

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
13 changes: 13 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
aiofiles
aiohttp
asyncio
cachetools
cloudpickle
enkanetworkv2.py
python-magic
python-magic-bin
matplotlib
more-itertools
numpy
Pillow
pydantic

0 comments on commit 02a7256

Please sign in to comment.