j178 / leetgo

Best LeetCode friend for geek. :snowboarder:
MIT License
540 stars 32 forks source link

`leetgo pick 1` with output `invalid qid: no such question` #297

Closed zwyyy456 closed 6 months ago

zwyyy456 commented 6 months ago

leetgo debug

Leetgo version info :

1.4.5
commit: 19a7eb1ba0bc2a376043a1afb5ad4660b046dafe
built at: 2024-04-04T02:09:03Z
goos: darwin
goarch: arm64

Home dir : /Users/zwyyy/.config/leetgo Project root : /Users/zwyyy/code/leetcode Working dir : /Users/zwyyy/code/leetcode Project config file : /Users/zwyyy/code/leetcode/leetgo.yaml Project configuration:

# Leetgo configuration file, see more at https://github.com/j178/leetgo

# Your name
author: zwyyy456
# Language of the question description: 'zh' (Simplified Chinese) or 'en' (English).
language: en
code:
  # Language of code generated for questions: go, cpp, python, java...
  # (will be overridden by command line flag -l/--lang).
  lang: cpp
  # The default template to generate filename (without extension), e.g. {{.Id}}.{{.Slug}}
  # Available attributes: Id, Slug, Title, Difficulty, Lang, SlugIsMeaningful
  # (Most questions have descriptive slugs, but some consist of random characters. The SlugIsMeaningful boolean indicates whether a slug is meaningful.)
  # Available functions: lower, upper, trim, padWithZero, toUnderscore, group.
  filename_template: '{{ .Id | padWithZero 4 }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  # Generate question description into a separate question.md file, otherwise it will be embed in the code file.
  separate_description_file: true
  # Default modifiers for all languages.
  modifiers:
    - name: removeUselessComments
  go:
    # Base directory to put generated questions, defaults to the language slug, e.g. go, python, cpp.
    out_dir: go
    # Functions that modify the generated code.
    modifiers:
      - name: removeUselessComments
      - name: changeReceiverName
      - name: addNamedReturn
      - name: addMod
  python3:
    # Base directory to put generated questions, defaults to the language slug, e.g. go, python, cpp.
    out_dir: python
    # Path to the python executable that creates the venv.
    executable: python3
  cpp:
    # Base directory to put generated questions, defaults to the language slug, e.g. go, python, cpp.
    out_dir: cpp
    # C++ compiler
    cxx: g++
    # C++ compiler flags (our Leetcode I/O library implementation requires C++17).
    cxxflags: -O2 -std=c++17
  rust:
    # Base directory to put generated questions, defaults to the language slug, e.g. go, python, cpp.
    out_dir: rust
  java:
    # Base directory to put generated questions, defaults to the language slug, e.g. go, python, cpp.
    out_dir: java
leetcode:
  # LeetCode site, https://leetcode.com or https://leetcode.cn
  site: https://leetcode.com
  # Credentials to access LeetCode.
  credentials:
    # How to provide credentials: browser, cookies, password or none.
    from: browser
    # Browsers to get cookies from: chrome, safari, edge or firefox. If empty, all browsers will be tried. Only used when 'from' is 'browser'.
    browsers: []
contest:
  # Base directory to put generated contest questions.
  out_dir: contest
  # Template to generate filename of the question.
  filename_template: '{{ .ContestShortSlug }}/{{ .Id }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  # Open the contest page in browser after generating.
  open_in_browser: true
# Editor settings to open generated files.
editor:
  # Use a predefined editor: vim, vscode, goland
  # Set to 'none' to disable, set to 'custom' to provide your own command and args.
  use: custom
  # Custom command to open files.
  command: "subl"
  # Arguments to your custom command.
  # String contains {{.CodeFile}}, {{.TestFile}}, {{.DescriptionFile}}, {{.TestCasesFile}} will be replaced with corresponding file path.
  # {{.Folder}} will be substituted with the output directory.
  # {{.Files}} will be substituted with the list of all file paths.
  args: "{{.Files}}"

Full configuration :

author: zwyyy456
language: en
code:
  lang: cpp
  filename_template: '{{ .Id | padWithZero 4 }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  separate_description_file: true
  modifiers:
    - name: removeUselessComments
  go:
    out_dir: go
    modifiers:
      - name: removeUselessComments
      - name: changeReceiverName
      - name: addNamedReturn
      - name: addMod
  python3:
    out_dir: python
    executable: python3
  cpp:
    out_dir: cpp
    cxx: g++
    cxxflags: -O2 -std=c++17
  rust:
    out_dir: rust
  java:
    out_dir: java
leetcode:
  site: https://leetcode.com
  credentials:
    from: browser
    browsers: []
contest:
  out_dir: contest
  filename_template: '{{ .ContestShortSlug }}/{{ .Id }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  open_in_browser: true
editor:
  use: custom
  command: subl
  args: '{{.Files}}'

Debug log

zwyyy@zwy-mbp14 ~/c/leetcode (main)> export DEBUG=1                                                                                                                                                                                                                      (base)
zwyyy@zwy-mbp14 ~/c/leetcode (main)> leetgo pick 124                                                                                                                                                                                                                     (base)
2024/05/03 18:48:33 DEBU cache loaded path=/Users/zwyyy/.config/leetgo/cache/leetcode-questions.json elapsed=249.375µs
2024/05/03 18:48:33 DEBU get by id elapsed=408.542µs
2024/05/03 18:48:33 DEBU reading cookies browser=firefox file="/Users/zwyyy/Library/Application Support/Firefox/Profiles/u5wz55r1.default/cookies.sqlite"
2024/05/03 18:48:33 DEBU failed to read cookies error="open /Users/zwyyy/Library/Application Support/Firefox/Profiles/u5wz55r1.default/cookies.sqlite: no such file or directory"
2024/05/03 18:48:33 DEBU reading cookies browser=firefox file="/Users/zwyyy/Library/Application Support/Firefox/Profiles/l7cju6x5.default-release/cookies.sqlite"
2024/05/03 18:48:33 INFO read LeetCode cookies browser=firefox domain=leetcode.com
2024/05/03 18:48:33 DEBU finished reading cookies elapsed=4.128208ms
2024/05/03 18:48:33 DEBU request method=POST url=https://leetcode.com/graphql
  body=
  │ {"operationName":"questionData","query":"\n\tquery questionData($titleSlug: String!) {\n\t\tquestion(titleSlug: $titleSlug) {\n\t\t\tquestionId\n\t\t\tquestionFrontendId\n\t\t\tcategoryTitle\n\t\t\ttitle\n\t\t\ttitleSlug\n\t\t\tcontent\n\t\t\tisPaidOnly\n\t\t\ttranslatedTitle\n\t\t\ttranslatedContent\n\t\t\tdifficulty\n\t\t\tstatus\n\t\t\tstats\n\t\t\thints\n\t\t\tsimilarQuestions\n\t\t\tsampleTestCase\n\t\t\texampleTestcases\n\t\t\texampleTestcaseList\n\t\t\tmetaData\n\t\t\tcodeSnippets {\n\t\t\t\tlang\n\t\t\t\tlangSlug\n\t\t\t\tcode\n\t\t\t}\n\t\t\ttopicTags {\n\t\t\t\tname\n\t\t\t\tslug\n\t\t\t\ttranslatedName\n\t\t\t}\n\t\t}\n\t}","variables":{"titleSlug":"124"}}

2024/05/03 18:48:34 DEBU response url=https://leetcode.com/graphql code=200
  headers=
  │ Cf-Cache-Status: DYNAMIC\r
  │ Cf-Ray: 87dfaded8c6cf5d0-NRT\r
  │ Connection: keep-alive\r
  │ Content-Length: 26\r
  │ Content-Type: application/json\r
  │ Server: cloudflare\r
  │ X-Content-Type-Options: nosniff\r
 data="{\"data\":{\"question\":null}}"
2024/05/03 18:48:34 DEBU get by id elapsed=1.5µs
2024/05/03 18:48:34 FATA invalid qid: no such question

Description

图片

如图,执行 leetgo pick today 时工作正常,执行 leetgo pick <number> 时,显示不存在这样的题目。

j178 commented 6 months ago

试下执行 leetgo cache update 呢?

zwyyy456 commented 6 months ago

试下执行 leetgo cache update 呢? 执行之后可以了,感谢解答。