Skip to content

Solutions downloader #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
garncarz opened this issue Mar 31, 2024 · 2 comments
Open

Solutions downloader #20

garncarz opened this issue Mar 31, 2024 · 2 comments
Labels
good first issue Good for newcomers

Comments

@garncarz
Copy link

Could you allow also downloading of posted solutions, please?

@garncarz
Copy link
Author

It seems this could be done by POSTing to https://leetcode.com/graphql/ userSolutionTopics operation. The query is:

query userSolutionTopics($username: String!, $orderBy: TopicSortingOption, $skip: Int, $first: Int) {
  userSolutionTopics(
    username: $username
    orderBy: $orderBy
    skip: $skip
    first: $first
  ) {
    pageInfo {
      hasNextPage
    }
    edges {
      node {
        id
        title
        url
        viewCount
        questionTitle
        post {
          creationDate
          voteCount
        }
      }
    }
  }
}

The variables are like:

{
  "username": "...",
  "orderBy": "newest_to_oldest",
  "skip": 0,
  "first": 15
}

@NeverMendel
Copy link
Owner

Thank you for sharing your suggestion! I had a quick look and found that exporting community solutions would be possible by using the userSolutionTopics graphql api you mentioned as well as the following to actually retrieve the solution:

query communitySolution($topicId: Int!) {
  topic(id: $topicId) {
    id
    viewCount
    topLevelCommentCount
    subscribed
    title
    pinned
    solutionTags {
      name
      slug
    }
    hideFromTrending
    commentCount
    isFavorite
    post {
      id
      voteCount
      voteStatus
      content
      updationDate
      creationDate
      status
      isHidden
      author {
        isDiscussAdmin
        isDiscussStaff
        username
        nameColor
        activeBadge {
          displayName
          icon
        }
        profile {
          userAvatar
          reputation
        }
        isActive
      }
      authorIsModerator
      isOwnPost
    }
  }
}

Right now, I don't have the bandwith to implement this, so I'll keep it unresolved for now. Contributions are welcome!

@NeverMendel NeverMendel added the good first issue Good for newcomers label Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants