Skip to content

Commit 2dd3c98

Browse files
authored
Merge pull request #232 from mathsman5133/feature/static-data-hash
Feature/static data hash
2 parents fa21f7c + 3d5d979 commit 2dd3c98

File tree

7 files changed

+50
-10
lines changed

7 files changed

+50
-10
lines changed

coc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
"""
2424

25-
__version__ = "3.4.0"
25+
__version__ = "3.4.1"
2626

2727
from .abc import BasePlayer, BaseClan
2828
from .clans import RankedClan, Clan

coc/static/buildings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49021,8 +49021,8 @@
4902149021
"DPS": [],
4902249022
"AltDPS": [],
4902349023
"Damage": [
49024-
55,
49025-
60
49024+
60,
49025+
65
4902649026
],
4902749027
"PreferredTarget": [],
4902849028
"PreferredTargetDamageMod": [],

coc/static/characters.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69471,9 +69471,9 @@
6947169471
150
6947269472
],
6947369473
"Hitpoints": [
69474+
6300,
6947469475
6650,
69475-
7050,
69476-
7400
69476+
7000
6947769477
],
6947869478
"TrainingTime": [
6947969479
220,
@@ -69515,9 +69515,9 @@
6951569515
],
6951669516
"CoolDownOverride": [],
6951769517
"DPS": [
69518+
190,
6951869519
210,
69519-
230,
69520-
250
69520+
230
6952169521
],
6952269522
"PreferedTargetDamageMod": [],
6952369523
"DamageRadius": [],

coc/static/update_static.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import zstandard
1010
import lzma
1111
import csv
12+
import os
13+
import zipfile
1214
from collections import defaultdict
1315

1416
# Targets first index is the URL and the second is the filename. If filename
@@ -26,6 +28,7 @@
2628
]
2729
FINGERPRINT = "c4e8c2976dcf42530d68dcb1fdfb61d071085abf"
2830
BASE_URL = f"https://game-assets.clashofclans.com/{FINGERPRINT}"
31+
APK_URL = "https://d.apkpure.net/b/APK/com.supercell.clashofclans?version=latest"
2932

3033

3134
def decompress(data):
@@ -69,6 +72,7 @@ def decompress(data):
6972
decompressed = lzma.LZMADecompressor().decompress(data)
7073
return decompressed
7174

75+
7276
def process_csv(data, file_path, save_name):
7377
decompressed = decompress(data)
7478

@@ -128,6 +132,10 @@ def process_csv(data, file_path, save_name):
128132

129133
jsonf.write(json.dumps(data, indent=4))
130134

135+
# clean up the .csv file, it is not used in coc.py
136+
os.unlink(file_path)
137+
138+
131139
def check_header(data):
132140
if data[0] == 0x5D:
133141
return "csv"
@@ -137,6 +145,30 @@ def check_header(data):
137145
return "sig:"
138146
raise Exception(" Unknown header")
139147

148+
149+
def get_fingerprint():
150+
import aiohttp
151+
import asyncio
152+
153+
async def download():
154+
async with aiohttp.request('GET', APK_URL) as fp:
155+
c = await fp.read()
156+
return c
157+
158+
data = asyncio.run(download())
159+
160+
with open("apk.zip", "wb") as f:
161+
f.write(data)
162+
zf = zipfile.ZipFile("apk.zip")
163+
with zf.open('assets/fingerprint.json') as fp:
164+
fingerprint = json.loads(fp.read())['sha']
165+
166+
# clean up apk
167+
os.unlink("apk.zip")
168+
169+
return fingerprint
170+
171+
140172
def main():
141173
for target_file, target_save in TARGETS:
142174
target_save = target_file if target_save is None else target_save

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
project = 'coc'
1616
copyright = '2022, mathsman5133'
1717
author = 'mathsman5133'
18-
release = '3.4.0'
18+
release = '3.4.1'
1919

2020
# -- General configuration ---------------------------------------------------
2121
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

docs/miscellaneous/changelog.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@ Changelog
77
This page keeps a fairly detailed, human readable version
88
of what has changed, and whats new for each version of the lib.
99

10+
v3.4.1
11+
------
12+
13+
Additions:
14+
~~~~~~~~~~
15+
- added the missing achievements to :class:`coc.ACHIEVEMENT_ORDER`
16+
- updated static data to reflect the March 26th balance patch
17+
1018
v3.4.0
1119
------
1220

1321
Additions:
1422
~~~~~~~~~~
15-
- added the new Fireball equipment to `coc.EQUIPMENT`
23+
- added the new Fireball equipment to :class:`coc.EQUIPMENT`
1624

1725
Bugs Fixed:
1826
~~~~~~~~~~~

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "coc.py"
77
authors = [{ name = "mathsman5133" }]
88
maintainers = [{ name = "majordoobie" }, { name = "MagicTheDev" }, { name = "Kuchenmampfer" },
99
{ name = "lukasthaler"}, { name = "doluk"}]
10-
version = "3.4.0"
10+
version = "3.4.1"
1111
description = "A python wrapper for the Clash of Clans API"
1212
requires-python = ">=3.7.3"
1313
readme = "README.rst"

0 commit comments

Comments
 (0)