-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hikari
committed
Oct 3, 2024
1 parent
37baa99
commit 9d24e38
Showing
20 changed files
with
396 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,4 @@ test*.py | |
.ssh/ | ||
.cache/ | ||
.idea/ | ||
pack.py | ||
b64.txt | ||
templates.zip | ||
templates.py | ||
hsl-config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from . import core | ||
from . import utils | ||
from . import gametypes | ||
from . import gametypes | ||
from . import source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import logging | ||
import requests | ||
from hsl.source.source import Source | ||
logger = logging.getLogger(__name__) | ||
DOWNLOAD_SOURCE = r'https://hsl.hikari.bond/source.json' | ||
SPCONFIGS_SOURCE = r'https://hsl.hikari.bond/spconfigs.json' | ||
VERSION_SOURCE = r'https://hsl.hikari.bond/hsl.json' | ||
|
||
def make_request(url: str, error_message: str) -> dict: | ||
try: | ||
response = requests.get(url) | ||
if response.status_code == 200: | ||
return response.json() | ||
logger.error(f'{error_message},状态码:{response.status_code}') | ||
return {} | ||
except Exception as e: | ||
logger.error(f'{error_message},错误信息:{e}') | ||
return {} | ||
def check_update(version: int) -> tuple[bool, int]: | ||
data = make_request(VERSION_SOURCE, error_message='检查更新失败') | ||
latest: int = data.get('version', 0) | ||
return (True, latest) if version < latest else (False, version) | ||
def load_source() -> Source: | ||
"""Load source data from sources | ||
""" | ||
_source = make_request(DOWNLOAD_SOURCE, error_message='加载源数据失败') | ||
return Source(**_source) | ||
def get_spconfigs(): | ||
return make_request(SPCONFIGS_SOURCE, error_message='加载特定配置文件失败') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class NoSuchServerException(Exception): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.