fix: use frontend id instead
This commit is contained in:
parent
910ac3423e
commit
cc87c4b30c
2 changed files with 13 additions and 3 deletions
14
create.sh
14
create.sh
|
|
@ -15,7 +15,7 @@ if [ -f "$sol_file" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
title_slug=$(jq -r "select(.id == $id) | .titleSlug" ./problemset.jsonl)
|
title_slug=$(jq -r "select(.frontendId == $id) | .titleSlug" ./problemset.jsonl)
|
||||||
[ -n "$title_slug" ] || {
|
[ -n "$title_slug" ] || {
|
||||||
echo "Err: problem $id not found in the problem set." >&2
|
echo "Err: problem $id not found in the problem set." >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -26,13 +26,23 @@ echo -e "Creating template for problem \033[32m${id}: $title_slug\033[0m" >&2
|
||||||
mkdir -pv "$pdir"
|
mkdir -pv "$pdir"
|
||||||
echo "// Package q$id implements a solution for $problem_url" > "$sol_file"
|
echo "// Package q$id implements a solution for $problem_url" > "$sol_file"
|
||||||
echo -e "package q$id\n" >> "$sol_file"
|
echo -e "package q$id\n" >> "$sol_file"
|
||||||
|
|
||||||
echo "Created: $sol_file"
|
echo "Created: $sol_file"
|
||||||
|
|
||||||
echo "Fetching code snippet for Go ..."
|
echo "Fetching code snippet for Go ..."
|
||||||
curl -sSLf "${problem_url}description/" \
|
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: 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 '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' \
|
-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[^>]*>.*' \
|
| grep -o 'NEXT_DATA[^>]*>.*' \
|
||||||
| sed 's/^[^>]*>//;s/<\/script.*//' \
|
| sed 's/^[^>]*>//;s/<\/script.*//' \
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ query() {
|
||||||
"filtersV2": {"filterCombineType":"ALL","statusFilter":{"questionStatuses":[],"operator":"IS"},"difficultyFilter":{"difficulties":[],"operator":"IS"},"languageFilter":{"languageSlugs":[],"operator":"IS"},"topicFilter":{"topicSlugs":[],"operator":"IS"},"acceptanceFilter":{},"frequencyFilter":{},"frontendIdFilter":{},"lastSubmittedFilter":{},"publishedFilter":{},"companyFilter":{"companySlugs":[],"operator":"IS"},"positionFilter":{"positionSlugs":[],"operator":"IS"},"positionLevelFilter":{"positionLevelSlugs":[],"operator":"IS"},"contestPointFilter":{"contestPoints":[],"operator":"IS"},"premiumFilter":{"premiumStatus":[],"operator":"IS"}}
|
"filtersV2": {"filterCombineType":"ALL","statusFilter":{"questionStatuses":[],"operator":"IS"},"difficultyFilter":{"difficulties":[],"operator":"IS"},"languageFilter":{"languageSlugs":[],"operator":"IS"},"topicFilter":{"topicSlugs":[],"operator":"IS"},"acceptanceFilter":{},"frequencyFilter":{},"frontendIdFilter":{},"lastSubmittedFilter":{},"publishedFilter":{},"companyFilter":{"companySlugs":[],"operator":"IS"},"positionFilter":{"positionSlugs":[],"operator":"IS"},"positionLevelFilter":{"positionLevelSlugs":[],"operator":"IS"},"contestPointFilter":{"contestPoints":[],"operator":"IS"},"premiumFilter":{"premiumStatus":[],"operator":"IS"}}
|
||||||
},
|
},
|
||||||
"operationName": "problemsetQuestionListV2"
|
"operationName": "problemsetQuestionListV2"
|
||||||
}' | jq -c '.data.problemsetQuestionListV2.questions[] | { id, title, titleSlug, difficulty, paidOnly, tags: [ .topicTags[] | .slug ] }'
|
}' | jq -c '.data.problemsetQuestionListV2.questions[] | { id, frontendId: .questionFrontendId | tonumber, title, titleSlug, difficulty, paidOnly, tags: [ .topicTags[] | .slug ] }'
|
||||||
}
|
}
|
||||||
|
|
||||||
page=0
|
page=0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue