fix: use frontend id instead

This commit is contained in:
Yiyang Kang 2026-02-26 18:40:25 +09:00
parent 910ac3423e
commit cc87c4b30c
Signed by: kkyy
SSH key fingerprint: SHA256:lJSbAzC3MvrSORdvIVK6h/3g+rVKJNzM7zq0MgA9WKY
2 changed files with 13 additions and 3 deletions

View file

@ -15,7 +15,7 @@ if [ -f "$sol_file" ]; then
exit 0
fi
title_slug=$(jq -r "select(.id == $id) | .titleSlug" ./problemset.jsonl)
title_slug=$(jq -r "select(.frontendId == $id) | .titleSlug" ./problemset.jsonl)
[ -n "$title_slug" ] || {
echo "Err: problem $id not found in the problem set." >&2
exit 1
@ -26,13 +26,23 @@ echo -e "Creating template for problem \033[32m${id}: $title_slug\033[0m" >&2
mkdir -pv "$pdir"
echo "// Package q$id implements a solution for $problem_url" > "$sol_file"
echo -e "package q$id\n" >> "$sol_file"
echo "Created: $sol_file"
echo "Fetching code snippet for Go ..."
curl -sSLf "${problem_url}description/" \
-H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8' \
-H 'accept-language: en-US,en;q=0.5' \
-H 'cache-control: max-age=0' \
-H 'priority: u=0, i' \
-H 'sec-ch-ua: "Not:A-Brand";v="99", "Brave";v="145", "Chromium";v="145"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "Linux"' \
-H 'sec-fetch-dest: document' \
-H 'sec-fetch-mode: navigate' \
-H 'sec-fetch-site: same-origin' \
-H 'sec-fetch-user: ?1' \
-H 'sec-gpc: 1' \
-H 'upgrade-insecure-requests: 1' \
-H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36' \
| grep -o 'NEXT_DATA[^>]*>.*' \
| sed 's/^[^>]*>//;s/<\/script.*//' \