Skip to content

Commit

Permalink
Merge pull request #79 from LlmKira/dev
Browse files Browse the repository at this point in the history
⬆️ feat: migrate from datetime to arrow for datetime handling
  • Loading branch information
sudoskys authored Sep 27, 2024
2 parents feeb058 + 9d2d307 commit 7a7d03b
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 9 deletions.
53 changes: 52 additions & 1 deletion pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "novelai-python"
version = "0.5.2"
version = "0.5.3"
description = "NovelAI Python Binding With Pydantic"
authors = [
{ name = "sudoskys", email = "[email protected]" },
Expand Down Expand Up @@ -29,6 +29,7 @@ dependencies = [
"json-repair>=0.29.4",
"robust-downloader>=0.0.2",
"bchlib>=2.1.3",
"arrow>=1.3.0",
]
requires-python = ">=3.9"
readme = "README.md"
Expand Down
5 changes: 2 additions & 3 deletions src/novelai_python/credential/ApiToken.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# @File : ApiToken.py
# @Software: PyCharm

import datetime

import arrow
import shortuuid
from curl_cffi.requests import AsyncSession
from loguru import logger
Expand All @@ -31,7 +30,7 @@ async def get_session(self, timeout: int = 180, update_headers: dict = None):
"Origin": "https://novelai.net",
"Referer": "https://novelai.net/",
"x-correlation-id": self._x_correlation_id,
"x-initiated-at": f"{datetime.datetime.now(datetime.UTC).isoformat()}Z",
"x-initiated-at": f"{arrow.utcnow().isoformat()}Z",
}

if update_headers:
Expand Down
4 changes: 2 additions & 2 deletions src/novelai_python/credential/JwtToken.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# @Author : sudoskys
# @File : JwtToken.py
# @Software: PyCharm
import datetime

import arrow
import shortuuid
from curl_cffi.requests import AsyncSession
from loguru import logger
Expand All @@ -30,7 +30,7 @@ async def get_session(self, timeout: int = 180, update_headers: dict = None):
"Origin": "https://novelai.net",
"Referer": "https://novelai.net/",
"x-correlation-id": self._x_correlation_id,
"x-initiated-at": f"{datetime.datetime.now(datetime.UTC).isoformat()}Z",
"x-initiated-at": f"{arrow.utcnow().isoformat()}Z",
}

if update_headers:
Expand Down
4 changes: 2 additions & 2 deletions src/novelai_python/credential/UserAuth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# @Time : 2024/2/7 下午12:14
# @Author : sudoskys
# @File : UserAuth.py
import datetime
import time
from typing import Optional

import arrow
import shortuuid
from curl_cffi.requests import AsyncSession
from pydantic import SecretStr, Field
Expand Down Expand Up @@ -33,7 +33,7 @@ async def get_session(self, timeout: int = 180, update_headers: dict = None):
"Origin": "https://novelai.net",
"Referer": "https://novelai.net/",
"x-correlation-id": self._x_correlation_id,
"x-initiated-at": f"{datetime.datetime.now(datetime.UTC).isoformat()}Z",
"x-initiated-at": f"{arrow.utcnow().isoformat()}Z",
}

# 30 天有效期
Expand Down

0 comments on commit 7a7d03b

Please sign in to comment.