Skip to content

Commit

Permalink
docs(zh): add quick start, download, shell completion
Browse files Browse the repository at this point in the history
  • Loading branch information
iyear committed Oct 8, 2023
1 parent bdf6cb2 commit 3b9a61c
Show file tree
Hide file tree
Showing 6 changed files with 281 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/content/zh/getting-started/_index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "快速开始"
title: "入门"
bookFlatSection: true
weight: 10
---
50 changes: 50 additions & 0 deletions docs/content/zh/getting-started/quick-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: "快速开始"
weight: 20
---

# 快速开始

## 登录

每个命名空间代表一个 Telegram 帐户

在执行每个命令时,您应该设置命名空间:

### **使用官方客户端登录(推荐)**

{{< hint warning >}}
请确保从[官方网站](https://desktop.telegram.org/)下载客户端(不要从 Microsoft Store 或 App Store 下载)
{{< /hint >}}

使用默认路径:

{{< command >}}
tdl login -n quickstart
{{< /command >}}

如果您设置了本地密码:

{{< command >}}
tdl login -n quickstart -p YOUR_PASSCODE
{{< /command >}}

或者指定自定义客户端路径:

{{< command >}}
tdl login -n quickstart -d /path/to/TelegramDesktop
{{< /command >}}

### **使用手机号码和验证码登录**

{{< command >}}
tdl login -n quickstart --code
{{< /command >}}

## 下载

我们使用帐户 `quickstart` 从 Telegram 官方频道下载文件:

{{< command >}}
tdl dl -n quickstart -u https://t.me/telegram/193
{{< /command >}}
42 changes: 42 additions & 0 deletions docs/content/zh/getting-started/shell-completion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: "自动补全"
weight: 30
---

# 自动补全

运行对应的命令以在所有会话中启用 Shell 自动补全:

{{< tabs "shell" >}}
{{< tab "bash" >}}

{{< command >}}
echo "source <(tdl completion bash)" >> ~/.bashrc
{{< /command >}}

{{< /tab >}}

{{< tab "zsh" >}}

{{< command >}}
echo "source <(tdl completion zsh)" >> ~/.zshrc
{{< /command >}}

{{< /tab >}}

{{< tab "fish" >}}

{{< command >}}
echo "tdl completion fish | source" >> ~/.config/fish/config.fish
{{< /command >}}

{{< /tab >}}

{{< tab "PowerShell" >}}

{{< command >}}
Add-Content -Path $PROFILE -Value "tdl completion powershell | Out-String | Invoke-Expression"
{{< /command >}}

{{< /tab >}}
{{< /tabs >}}
5 changes: 5 additions & 0 deletions docs/content/zh/guide/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: "指南"
bookFlatSection: true
weight: 20
---
178 changes: 178 additions & 0 deletions docs/content/zh/guide/download.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
---
title: "下载"
weight: 30
---

# 下载

## 从链接下载:

{{< hint info >}}
点击官方客户端的 "复制链接" 按钮获取消息链接。
{{< /hint >}}

{{< details title="消息链接示例" open=false >}}

- `https://t.me/telegram/193`
- `https://t.me/c/1697797156/151`
- `https://t.me/iFreeKnow/45662/55005`
- `https://t.me/c/1492447836/251015/251021`
- `...`(如果发现新的链接格式,请提交新的 Issue)
{{< /details >}}

{{< command >}}
tdl dl -u https://t.me/tdl/1 -u https://t.me/tdl/2
{{< /command >}}

## 从 JSON 下载:

有两种导出 JSON 文件的方式:

{{< tabs "json" >}}
{{< tab "tdl" >}}
请参考 [导出消息](/guide/tools/export-messages)
{{< /tab >}}

{{< tab "桌面客户端" >}}

1. 选择要导出的对话,点击右上角的三个点,然后点击 `导出聊天历史`
2. 取消选中所有选项(您现在不需要下载它们),将 `大小限制` 设置为最小值。
3. 设置格式为 `JSON` 并选择您需要的时间段。
4. 导出它!`result.json` 就是您需要的文件。
{{< /tab >}}
{{< /tabs >}}

{{< command >}}
tdl dl -f result1.json -f result2.json
{{< /command >}}

## 合并下载:

{{< command >}}
tdl dl \
-u https://t.me/tdl/1 -u https://t.me/tdl/2 \
-f result1.json -f result2.json
{{< /command >}}

## 自定义目录:

将文件下载到自定义目录

{{< command >}}
tdl dl -u https://t.me/tdl/1 -d /path/to/dir
{{< /command >}}

## 自定义参数:

使用每个任务8个线程,512KiB(最大)的分段大小,4个并发任务下载:

{{< command >}}
tdl dl -u https://t.me/tdl/1 -t 8 -s 524288 -l 4
{{< /command >}}

## 反序下载:

按反序下载文件(从最新到最旧)

{{< hint warning >}}
不同的顺序将影响“恢复下载”功能
{{< /hint >}}

{{< command >}}
tdl dl -f result.json --desc
{{< /command >}}

## MIME 探测:

如果文件扩展名与 MIME 类型不匹配,tdl将使用正确的扩展名重命名文件。

{{< hint warning >}}
副作用:例如 `.apk` 文件将被重命名为 `.zip`
{{< /hint >}}

{{< command >}}
tdl dl -u https://t.me/tdl/1 --rewrite-ext
{{< /command >}}

## 自动跳过

在下载时跳过相同的文件(即名称和大小相同)。

{{< command >}}
tdl dl -u https://t.me/tdl/1 --skip-same
{{< /command >}}

## "Takeout" 会话

通过 ["Takeout" 会话](https://arabic-telethon.readthedocs.io/en/stable/extra/examples/telegram-client.html#exporting-messages) 下载文件:

> 如果下载大量媒体,更倾向于使用 "Takeout" 会话,它允许您以较低的速率限制从您的帐户中导出数据。
{{< command >}}
tdl dl -u https://t.me/tdl/1 --takeout
{{< /command >}}

## 过滤器

使用扩展名过滤器下载文件:

{{< hint warning >}}
扩展名仅与文件名匹配,而不是 MIME 类型。因此,这可能不会按预期工作。

白名单和黑名单不能同时使用。
{{< /hint >}}

白名单:只下载扩展名为 `.jpg` `.png` 的文件

{{< command >}}
tdl dl -u https://t.me/tdl/1 -i jpg,png
{{< /command >}}

黑名单:下载除了扩展名为 `.mp4` `.flv` 的所有文件

{{< command >}}
tdl dl -u https://t.me/tdl/1 -e mp4,flv
{{< /command >}}

## 文件名模板

使用自定义文件名模板下载:

请参考 [模板指南](/guide/template) 了解更多。

{{< command >}}
tdl dl -u https://t.me/tdl/1 \
--template "{{ .DialogID }}_{{ .MessageID }}_{{ .DownloadDate }}_{{ .FileName }}"
{{< /command >}}

## 恢复/重新开始下载

在不需要交互的情况下恢复下载:

{{< command >}}
tdl dl -u https://t.me/tdl/1 --continue
{{< /command >}}

在不需要交互的情况下重新开始下载:

{{< command >}}
tdl dl -u https://t.me/tdl/1 --restart
{{< /command >}}

## HTTP 文件服务器

将文件暴露为 HTTP 服务器,而不使用内置下载它们

{{< hint info >}}
当您想要使用下载管理器(如 `aria2`/`wget`/`axel`/`IDM`)下载文件时,适合使用此选项。
{{< /hint >}}

{{< command >}}
tdl dl -u https://t.me/tdl/1 --serve
{{< /command >}}

使用自定义端口:

{{< command >}}
tdl dl -u https://t.me/tdl/1 --serve --port 8081
{{< /command >}}
5 changes: 5 additions & 0 deletions docs/content/zh/more/cli/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: "CLI"
weight: 10
bookHref: "/more/cli/tdl"
---

0 comments on commit 3b9a61c

Please sign in to comment.