File tree Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Expand file tree Collapse file tree 3 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ import typer
2+ from src .commands import show
3+ from src .commands .edit import edit
4+ from src .server .api import get_daily_question
5+
6+ def daily (
7+ lang : str = typer .Argument ("python" , help = "Programming language to use." ),
8+ editor : str = typer .Option ("code" , '-e' , help = "Code editor to use." ),
9+ ):
10+ """Check the daily problem."""
11+ result = get_daily_question ()
12+ question = result ['data' ]['activeDailyCodingChallengeQuestion' ]
13+
14+ show (problem = question ['question' ]['titleSlug' ], layout = True )
15+
16+ if editor :
17+ edit (problem = question ['question' ]['titleSlug' ], lang = lang , editor = editor )
Original file line number Diff line number Diff line change 11import profile
22import typer
33from src import show , profile
4+ from src .commands .daily import daily
45from src .commands .edit import edit
56from src .commands .list_problems import list_problems
67from src .commands .login import login , logout
1112
1213app .command (name = "show" )(show )
1314app .command (name = "list" )(list_problems )
15+ app .command (name = "daily" )(daily )
1416app .command (name = "profile" )(profile )
1517app .command (name = "login" )(login )
1618app .command (name = "logout" )(logout )
Original file line number Diff line number Diff line change 11from gql import gql , Client
22from gql .transport .requests import RequestsHTTPTransport
3+ import requests
34
45def create_leetcode_client (csrf_token : str , session_id : str ):
56 headers = {
@@ -177,3 +178,37 @@ def fetch_problem_list(
177178 except Exception as e :
178179 print (f"Error fetching data: { str (e )} " )
179180 return None
181+
182+
183+ def get_daily_question ():
184+ url = "https://leetcode.com/graphql"
185+ query = """
186+ query questionOfToday {
187+ activeDailyCodingChallengeQuestion {
188+ date
189+ userStatus
190+ link
191+ question {
192+ titleSlug
193+ title
194+ translatedTitle
195+ acRate
196+ difficulty
197+ freqBar
198+ frontendQuestionId: questionFrontendId
199+ isFavor
200+ paidOnly: isPaidOnly
201+ status
202+ hasVideoSolution
203+ hasSolution
204+ topicTags {
205+ name
206+ id
207+ slug
208+ }
209+ }
210+ }
211+ }
212+ """
213+ response = requests .post (url , json = {'query' : query })
214+ return response .json ()
You can’t perform that action at this time.
0 commit comments