Skip to content

Commit 10b3548

Browse files
committed
Improve README.md
1 parent e744d3e commit 10b3548

File tree

2 files changed

+91
-60
lines changed

2 files changed

+91
-60
lines changed

README.md

Lines changed: 80 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,59 @@
22

33
Python script and Docker image to export your LeetCode submissions.
44

5-
## DISCLAIMER
5+
## 📝 Table of Contents
6+
7+
- [DISCLAIMER](#DISCLAIMER)
8+
- [About](#about)
9+
- [Getting started](#getting-started)
10+
- [Script arguments](#script-arguments)
11+
- [Special mentions](#special-mentions)
12+
- [License](#license)
13+
14+
## ⚠️ DISCLAIMER <a name="disclaimer"></a>
615

716
The problems hosted on leetcode.com are intellectual propriety of LeetCode LLC unless specified otherwise. **DO NOT
817
UPLOAD THE DESCRIPTION OF LEETCODE PROBLEMS ON GITHUB OR ON ANY OTHER WEBSITE** or you might receive ad DMCA Takedown
918
notice.
1019

1120
Before using this script read the [LeetCode Terms of Service](https://leetcode.com/terms/).
1221

13-
## How it works
22+
## ⚙️ About <a name="about"></a>
1423

1524
This script uses LeetCode REST and GraphQL APIs to download all your LeetCode submitted solutions.
1625

1726
Before running the script, make sure that python3 is installed in your system.
1827

19-
If you prefer, you can use the Docker image to download your submissions. For further instructions read the
20-
section [Docker Image here](#docker-image).
28+
If you prefer, you can use the Docker image to download LeetCode submissions. For further instructions read the
29+
section [Docker Image](#docker-image).
30+
31+
## 🏁 Getting started <a name="getting-started"></a>
32+
33+
### Download `leetcode-export`
2134

22-
## How to use
35+
To use `leetcode-export` download it from pypi.org, pull the docker image, or clone this repository.
2336

24-
To use `leetcode-export` you can either download it from pypi.org or you can clone this repository.
37+
#### Download from pypi.org
2538

26-
### Download from pypi.org
39+
Run `pip install leetcode-export` to install leetcode-export, you might have to use `pip3` of your system. Then execute
40+
run the script `leetcode-export`, optionally supply the script arguments. For more information read the
41+
section [script arguments](#script-arguments).
2742

28-
Run `pip install leetcode-export` to install leetcode-export, you might have to use `pip3` of your system. To use the
29-
script run `leetcode-export`, optionally supply the script arguments, for more instructions read the
30-
section [script arguments here](#script-arguments).
43+
#### Docker Image
44+
45+
Download the docker image from DockerHub:
46+
47+
```bash
48+
docker pull nevermendel/leetcode-export
49+
```
50+
51+
Download all your LeetCode submission in the current folder:
52+
53+
```bash
54+
docker run -it -v $(pwd):/usr/app/out --rm nevermendel/leetcode-export
55+
```
3156

32-
### Clone the repository
57+
#### Clone the repository
3358

3459
Clone this repository:
3560

@@ -43,9 +68,9 @@ Install all the needed dependencies:
4368
pip install -r requirements.txt
4469
```
4570

46-
You can either install leetcode-export in your system or just execute it:
71+
Install leetcode-export in your system or just execute it:
4772

48-
- To install it run:
73+
- To install the script:
4974
```bash
5075
pip install .
5176
```
@@ -55,24 +80,10 @@ You can either install leetcode-export in your system or just execute it:
5580
python -m leetcode_export --folder submissions
5681
```
5782

58-
### Docker Image
83+
### Login
5984

60-
Download the docker image from the DockerHub repository:
61-
62-
```bash
63-
docker pull nevermendel/leetcode-export
64-
```
65-
66-
Download all your LeetCode submission in the current folder:
67-
68-
```bash
69-
docker run -it -v $(pwd):/usr/app/out --rm nevermendel/leetcode-export
70-
```
71-
72-
## Login
73-
74-
To download your submissions you need to log in your LeetCode account by providing the cookies. To log in using cookies,
75-
get them from an existing session.
85+
`leetcode-export` requires a valid LeetCode account to download its submissions. Login to your LeetCode account by
86+
providing the cookies. To log in using cookies, get them from an existing session.
7687

7788
**Steps required**:
7889

@@ -88,45 +99,58 @@ program argument when lunching the script, like in the following example:
8899
python leetcode-export --cookies {COOKIES}
89100
```
90101
102+
Using the interactive menu is preferred because it will avoid storing cookies in the command history.
103+
91104
## Script arguments
92105
93106
The script accepts the following arguments:
94107
95108
```
96-
usage: leetcode-export [-h] [--cookies COOKIES] [--folder FOLDER]
97-
[--problem-filename PROBLEM_FILENAME]
98-
[--problem-content PROBLEM_CONTENT]
99-
[--submission-filename SUBMISSION_FILENAME] [-v] [-vv]
100-
[-V]
109+
usage: leetcode_export [-h] [--cookies COOKIES] [--folder FOLDER]
110+
[--problem-folder-name PROBLEM_FOLDER_NAME]
111+
[--problem-statement-filename PROBLEM_STATEMENT_FILENAME]
112+
[--problem-statement-content PROBLEM_STATEMENT_CONTENT]
113+
[--submission-filename SUBMISSION_FILENAME]
114+
[--only-accepted] [--language LANGUAGE_UNPROCESSED] [-v]
115+
[-vv] [-V]
101116
102-
Export LeetCode solutions
117+
Export LeetCode submissions
103118
104-
optional arguments:
119+
options:
105120
-h, --help show this help message and exit
106121
--cookies COOKIES set LeetCode cookies
107122
--folder FOLDER set output folder
108-
--problem-filename PROBLEM_FILENAME
109-
problem description filename format
110-
--problem-content PROBLEM_CONTENT
111-
problem description content format
123+
--problem-folder-name PROBLEM_FOLDER_NAME
124+
problem folder name format
125+
--problem-statement-filename PROBLEM_STATEMENT_FILENAME
126+
problem statement filename format
127+
--problem-statement-content PROBLEM_STATEMENT_CONTENT
128+
problem statement content format
112129
--submission-filename SUBMISSION_FILENAME
113130
submission filename format
131+
--only-accepted save accepted submissions only
132+
--language LANGUAGE_UNPROCESSED
133+
save submissions for specified programming languages.
134+
syntax: --language=<lang1>,<lang2>,...
135+
languages: python, python3, c, cpp, csharp, java,
136+
kotlin, mysql, mssql, oraclesql, javascript,
137+
html, php, golang, scala, pythonml,
138+
rust, ruby, bash, swift
139+
example: --language=python,cpp,java
114140
-v, --verbose enable verbose logging details
115141
-vv, --extra-verbose enable more verbose logging details
116142
-V, --version show program's version number and exit
117143
```
118144

119-
Using the interactive menu is preferred as it will avoid storing your cookies in the command history.
120-
121-
## Filename template arguments
145+
### Problem template arguments
122146

123-
### Problem description filename template
147+
#### Problem statement filename template
124148

125-
To change the format of the problem description filename, you can provide a template as a string when lunching the
149+
To change the format of the problem statement filename provide a template as a string when executing the
126150
script.
127151

128152
```bash
129-
python leetcode-export --problem-filename PROBLEM_FILENAME
153+
python leetcode-export --problem-statement-filename PROBLEM_STATEMENT_FILENAME
130154
```
131155

132156
The template can contain parameters that will later be replaced based on the LeetCode problem information. The available
@@ -140,36 +164,36 @@ title: str
140164
title_slug: str
141165
```
142166

143-
Default problem description filename template: `${question_id} - ${title_slug}.html`
167+
Default problem statement filename template: `${question_id} - ${title_slug}.html`
144168

145-
### Problem description content template
169+
#### Problem statement content template
146170

147-
To change the format of the problem description content, you can provide a template as a string when lunching the
171+
To change the format of the problem statement content provide a template as a string when executing the
148172
script.
149173

150174
```bash
151-
python leetcode-export --problem-content PROBLEM_CONTENT
175+
python leetcode-export --problem-statement-content PROBLEM_STATEMENT_CONTENT
152176
```
153177

154178
The template can contain parameters that will later be replaced based on the LeetCode problem information. The available
155-
parameters are the ones used in [problem description filename template](#problem-description-filename-template) plus:
179+
parameters are the ones contained in [problem statement filename template](#problem-statement-filename-template) plus:
156180

157181
```python
158182
content: str
159183
```
160184

161-
Default problem description content
162-
template: `<h1>${question_id} - ${title}</h1><h2>Difficulty: ${difficulty} - <a href="https://leetcode.com/problems/${title_slug}/">${title_slug}</a></h2>${content}`
185+
Default problem statement content template:
186+
`<h1>${question_id} - ${title}</h1><h2>Difficulty: ${difficulty} - <a href="https://leetcode.com/problems/${title_slug}/">${title_slug}</a></h2>${content}`
163187

164-
### Submission filename template
188+
#### Submission filename template
165189

166190
To change the format of the submission filename, you can provide a template as a string when lunching the script.
167191

168192
```bash
169193
python leetcode-export --submission-filename SUBMISSION_FILENAME
170194
```
171195

172-
The template can contain parameters that will later be replaced based on your submission information. The available
196+
The template can contain parameters that will later be replaced based on the submission information. The available
173197
parameters are the following:
174198

175199
```python

leetcode_export/__main__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717
def parse_args():
1818
parser = argparse.ArgumentParser(
1919
description="Export LeetCode submissions",
20-
formatter_class=argparse.RawTextHelpFormatter,
20+
formatter_class=lambda prog: argparse.RawTextHelpFormatter(
21+
"leetcode_export", width=80
22+
),
2123
)
24+
2225
parser.add_argument("--cookies", type=str, help="set LeetCode cookies")
2326
parser.add_argument("--folder", type=str, default=".", help="set output folder")
2427
parser.add_argument(
@@ -56,9 +59,13 @@ def parse_args():
5659
"--language",
5760
dest="language_unprocessed",
5861
type=str,
59-
help="only save submissions for the specified programming languages (eg. '--language=python,python3,cpp,java,golang')\n"
60-
+ "supported languages: 'python', 'python3', 'c', 'cpp', 'csharp', 'java', 'kotlin', 'mysql', 'mssql', 'oraclesql',\n"
61-
+ " 'javascript', 'html', 'php', 'golang', 'scala', 'pythonml', 'rust', 'ruby', 'bash', 'swift'",
62+
help="save submissions for specified programming languages.\n"
63+
"syntax: --language=<lang1>,<lang2>,...\n"
64+
"languages: python, python3, c, cpp, csharp, java,\n"
65+
" kotlin, mysql, mssql, oraclesql, javascript,\n"
66+
" html, php, golang, scala, pythonml,\n"
67+
" rust, ruby, bash, swift\n"
68+
"example: --language=python,cpp,java",
6269
)
6370
parser.add_argument(
6471
"-v",

0 commit comments

Comments
 (0)