Skip to content

Commit 6e386d5

Browse files
committed
add: Add Genshin Impact API moduel
Fix: fix some bugs
1 parent 37785b7 commit 6e386d5

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class CookieNotFound(Exception):
2+
def __init__(self):
3+
super().__init__("Cookie not found in the environment variable")
4+
5+
6+
class userNotFound(Exception):
7+
def __init__(self):
8+
super().__init__("User not found")

extendingPython/Genshin_Impact_API/__init__.py

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import os
2+
3+
from extendingPython.Genshin_Impact_API import GenshinImpactAPIExceptions
4+
5+
if (os.environ.get('Genshin_Impact_Cookie') == None):
6+
raise GenshinImpactAPIExceptions.CookieNotFound()

extendingPython/GiteeAPI/Activity.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pyhttpx
22

3-
from . import Exceptions
3+
from extendingPython.GiteeAPI import GiteeAPIExceptions
44

55

66
def getTheUserWhoStarTheRepo(owner: str, repo: str, page: int = -1, access_token: str = '', per_page: int = 100):
@@ -47,9 +47,9 @@ def getTheUserWhoStarTheRepo(owner: str, repo: str, page: int = -1, access_token
4747
res = session.get(url, params=params)
4848
res = res.json()
4949
if len(res) != 0 and res.get("message") == "Not Found Project":
50-
raise Exceptions.NotFoundProject("The project is not found or your project is private")
50+
raise GiteeAPIExceptions.NotFoundProject("The project is not found or your project is private")
5151
elif len(res) != 0 and res.get("message") == "401 Unauthorized: Access token does not exist":
52-
raise Exceptions.AccessTokenNotExist("Access token does not exist")
52+
raise GiteeAPIExceptions.AccessTokenNotExist("Access token does not exist")
5353
return res
5454

5555

@@ -98,9 +98,9 @@ def getTheUserWhoWatchTheRepo(owner: str, repo: str, page: int = -1, access_toke
9898
res = res.json()
9999
try:
100100
if res.get("message") == "Not Found Project":
101-
raise Exceptions.NotFoundProject("The project is not found or your project is private")
101+
raise GiteeAPIExceptions.NotFoundProject("The project is not found or your project is private")
102102
elif res.get("message") == "401 Unauthorized: Access token does not exist":
103-
raise Exceptions.AccessTokenNotExist("Access token does not exist")
103+
raise GiteeAPIExceptions.AccessTokenNotExist("Access token does not exist")
104104
except AttributeError:
105105
pass
106106
return res
@@ -151,9 +151,9 @@ def getTheMassageFromTheRepo(owner: str, repo: str, access_token: str = '', limi
151151
res = res.json()
152152
try:
153153
if res.get("message") == "Not Found Project":
154-
raise Exceptions.NotFoundProject("The project is not found or your project is private")
154+
raise GiteeAPIExceptions.NotFoundProject("The project is not found or your project is private")
155155
elif res.get("message") == "401 Unauthorized: Access token does not exist":
156-
raise Exceptions.AccessTokenNotExist("Access token does not exist")
156+
raise GiteeAPIExceptions.AccessTokenNotExist("Access token does not exist")
157157
except AttributeError:
158158
pass
159159
return res

0 commit comments

Comments
 (0)