Skip to content

Commit

Permalink
fix: return type bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles94jp committed Apr 6, 2022
1 parent a2647bb commit 32beb2e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
9 changes: 5 additions & 4 deletions cnblogs_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ def __init__(self, cnblogs_cookie, workdir, download_img=False):
"Referer": "https://i.cnblogs.com/",
"Cookie": rf".Cnblogs.AspNetCore.Cookies={cnblogs_cookie}"}
self._category = api.get_category_list(self._http_headers)
errors = self._category.get("errors1")
if errors is not None and errors[0] == "Unauthorized":
print("Cookie 已过期,请重新配置Cookie")
sys.exit()
if type(self._category) == dict:
errors = self._category.get("errors1")
if errors is not None and errors[0] == "Unauthorized":
print("Cookie 已过期,请重新配置Cookie")
sys.exit()

flag_path = rf"{workdir}\{self._FLAG_FILE_NAME}"
if os.path.isfile(flag_path):
Expand Down
4 changes: 2 additions & 2 deletions docs/lib/cnblogs-apiDoc.html

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion lib/cnblogs-apiDoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
https://i.cnblogs.com/api/category/blog/1/edit
```

**返回示例**
**成功返回示例**

```json
[
Expand All @@ -49,6 +49,19 @@ https://i.cnblogs.com/api/category/blog/1/edit
]
```

**未授权返回示例:**

```json
{
"errors": [
"Unauthorized"
],
"type": 1
}
```



<br></br>

## 2 获取用户随笔列表
Expand Down
2 changes: 1 addition & 1 deletion lib/cnblogs_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_category_list(http_header):
获取用户的博客分类
:param dict http_header: 其中应当包含Cookie
:rtype: dict
:rtype: list
:return: 详情参见接口文档: `cnblogs-apiDoc.md <./cnblogs-apiDoc.html>`_
"""
r = httpx.get("https://i.cnblogs.com/api/category/blog/1/edit", headers=http_header, timeout=TIMEOUT)
Expand Down

0 comments on commit 32beb2e

Please sign in to comment.