20
20
import genanki # type: ignore
21
21
22
22
# https://github.com/prius/python-leetcode
23
- import leetcode # type: ignore
23
+ import leetcode .api .default_api # type: ignore
24
+ import leetcode .api_client # type: ignore
24
25
import leetcode .auth # type: ignore
26
+ import leetcode .configuration # type: ignore
27
+ import leetcode .models .graphql_query # type: ignore
28
+ import leetcode .models .graphql_query_variables # type: ignore
25
29
import urllib3 # type: ignore
26
30
from tqdm import tqdm # type: ignore
27
31
@@ -110,7 +114,7 @@ async def _get_problem_data(self, problem_slug: str) -> Dict[str, str]:
110
114
111
115
api_instance = self ._api_instance
112
116
113
- graphql_request = leetcode .GraphqlQuery (
117
+ graphql_request = leetcode .models . graphql_query . GraphqlQuery (
114
118
query = """
115
119
query getQuestionDetail($titleSlug: String!) {
116
120
question(titleSlug: $titleSlug) {
@@ -168,7 +172,9 @@ async def _get_problem_data(self, problem_slug: str) -> Dict[str, str]:
168
172
}
169
173
}
170
174
""" ,
171
- variables = leetcode .GraphqlQueryVariables (title_slug = problem_slug ),
175
+ variables = leetcode .models .graphql_query_variables .GraphqlQueryVariables (
176
+ title_slug = problem_slug
177
+ ),
172
178
operation_name = "getQuestionDetail" ,
173
179
)
174
180
@@ -300,14 +306,14 @@ def guid(self):
300
306
301
307
302
308
@lru_cache (None )
303
- def get_leetcode_api_client () -> leetcode .DefaultApi :
309
+ def get_leetcode_api_client () -> leetcode .api . default_api . DefaultApi :
304
310
"""
305
311
Leetcode API instance constructor.
306
312
307
313
This is a singleton, because we don't need to create a separate client
308
314
each time
309
315
"""
310
- configuration = leetcode .Configuration ()
316
+ configuration = leetcode .configuration . Configuration ()
311
317
312
318
session_id = os .environ ["LEETCODE_SESSION_ID" ]
313
319
csrf_token = leetcode .auth .get_csrf_cookie (session_id )
@@ -317,7 +323,9 @@ def get_leetcode_api_client() -> leetcode.DefaultApi:
317
323
configuration .api_key ["LEETCODE_SESSION" ] = session_id
318
324
configuration .api_key ["Referer" ] = "https://leetcode.com"
319
325
configuration .debug = False
320
- api_instance = leetcode .DefaultApi (leetcode .ApiClient (configuration ))
326
+ api_instance = leetcode .api .default_api .DefaultApi (
327
+ leetcode .api_client .ApiClient (configuration )
328
+ )
321
329
322
330
return api_instance
323
331
0 commit comments