Import LeetCode problems from a pasted link on the site
Test and publish the site / test (push) Successful in 1m9s
Test and publish the site / publish (push) Successful in 1m31s

The problem list's admin row gains a link box beside "Today's LeetCode":
POST /leetcode/import takes {url} and does what `usaco new
<leetcode-link>` does, through the same lib/leetcode.py run and "Start
<slug>" commit as the daily question, then opens the solve page. A
problem already in the repo is only opened.

leetcode.Slug reads the link as slug_of in lib/leetcode.py does: full
links with /description/ and query strings, www., no scheme, or a bare
slug. Anything else is a 400.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-20 13:02:11 +01:00
co-authored by Claude Opus 5.5
parent ccf4e4dd74
commit 3a8f651a6f
8 changed files with 179 additions and 23 deletions
+3 -2
View File
@@ -54,8 +54,8 @@ type Server struct {
// Statements reads a statement from the problem's judge; nil means the
// real judges.
Statements Fetcher
// LeetCode starts the daily question; nil means the real API and the
// clone's lib/leetcode.py.
// LeetCode starts the daily question and pasted links; nil means the
// real API and the clone's lib/leetcode.py.
LeetCode LeetCode
// Transcriber turns review recordings into text; nil when
// TRANSCRIBE_API_KEY is not set, which turns reviews off.
@@ -118,6 +118,7 @@ func (s *Server) Routes(api *gin.RouterGroup) {
admin.POST("/problems/:name/evaluate", s.startEvaluate)
admin.GET("/problems/:name/evaluate", s.evaluateStatus)
admin.POST("/leetcode/daily", s.startDaily)
admin.POST("/leetcode/import", s.startImport)
api.GET("/concepts", s.listConcepts)
api.GET("/concepts/:slug", s.getConcept)
admin.POST("/concepts", s.startConcept)