Skip to content

Commit

Permalink
Merge pull request #39 from Johnserf-Seed/v0.0.1.4-pw1
Browse files Browse the repository at this point in the history
## v0.0.1.4 Changed

### 修复 [Fixed]
- 修复了非Windows系统下创建长中文名文件出错的问题 #34 
Johnserf-Seed/TikTokDownload#653
Johnserf-Seed/TikTokDownload#636
Johnserf-Seed/TikTokDownload#483
- 修复了接口缺失时间戳值导致的问题 #23
- 修复了douyin `utils`模块对aweme_id的处理
- 修复了CLI参数合并时的一些问题,确保自定义配置的正确性
- 修复douyin直播嵌套ts文件无法获取字节大小的问题 Johnserf-Seed/TikTokDownload#649
- 修复了douyin收藏作品下载错误的问题 Johnserf-Seed/TikTokDownload#650
- 修复了示例代码片段与开发者文档代码片段
- 修复了cli退出时`base_downloader`出现 UnboundLocalError 错误的问题
- 修复了`base_downloader`下载文件区块时未能正确捕获超时错误
- 修复了在更新配置时缺少自定义配置文件路径的问题
- 修复了`get_or_add_user_data`中的`AttributeError`问题
- 修复了数据库文件名
- 修复了部分自定义配置失效的问题

### 修改 [Change]
- 修改了日志输出,以便更好地了解配置加载情况
- 修改了TokenManager里固定配置的读取方式,增强了配置的易用性和可维护性
- 修改了默认低频主配置文件、F2低频配置文件
- 修改了配置文件与CLI命令,解决了部分自定义配置失效的问题
- 修改了部分方法的签名,提升了代码清晰度和可读性

### 更新 [Update]
- 更新了翻译文件和模板
- 更新了app帮助说明
- 更新了文档内容和静态文件
- 更新了`base_crawler`的POST获取json方法
- 重新设计了处理配置参数的逻辑,提升了性能和灵活性
- 更新了模块捕获错误时显示具体类名
- 更新了默认低频主配置文件和F2低频配置文件
- 更新了依赖库版本,确保兼容性 Johnserf-Seed/TikTokDownload#641
- 更新了TikTok和Douyin的开发者接口文档和代码片段

### 添加 [Add]
- 添加了默认低频配置文件路径,用于生成app配置文件
- 添加了QA文档,提供了常见问题与解决办法
- 添加了app`cli`模块的`merge_config`方法
- 添加了写入配置文件时处理文件权限问题的功能
- 添加了所有单元测试的path注释
- 添加了对于不同操作系统下文件名长度的处理方法
- 添加了不同app`utils`模块的连接失败与错误处理
- 添加了提取有效URL的错误类型
- 添加了douyin msToken值验证

### 改进 [Improve]
- 改进了部分单元测试代码,提升了代码质量
- 改进了douyin的handler_sso_login方法,保证配置文件路径正确
- 优化了异常处理机制,使得错误信息更加详细和可读
- 改进了`base_downloader`无代理配置默认值
- 改进了app`crawler`无代理配置默认值
- 改进了app`handler`类的结构和清晰度
- 改进了日志输出,增加了配置加载情况的显示
- 重写了配置参数的处理逻辑,提升了性能和可维护性

### 删除 [Delete]
- 删除了pot翻译模板文件
- 删除了无用的测试文件和部分注释代码
- 删除了弃用文档
- 移除了一些不必要的依赖和配置项
- 删除了不再使用的接口和方法
- 删除了f2主配置文件中的代理值与无效值
- 删除了一些注释
- 删除了`base_crawler`模块选择随机代理的注释代码

### 其他 [Other]
- 进行了代码格式化和优化,增强了代码的可读性和可维护性
- 解决了一些Bug和错误,提升了程序的稳定性和可靠性
  • Loading branch information
Johnserf-Seed committed Feb 15, 2024
2 parents 1eba6b7 + c74d0f7 commit 8759a27
Show file tree
Hide file tree
Showing 103 changed files with 3,000 additions and 5,600 deletions.
27 changes: 16 additions & 11 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export default defineConfig({
{ icon: 'discord', link: 'https://discord.gg/3PhtPmgHf8' },
],
algolia: {
appId: '',
apiKey: '',
appId: 'KKYI8Z7LEP',
apiKey: '8f27043df972a4e8eb009a3195f2042b',
indexName: 'f2'
},
footer: {
Expand All @@ -56,6 +56,7 @@ export default defineConfig({
{text: '安装', link: '/install'},
{text: '快速使用', link: '/quick-start'},
{text: '配置文件', link: '/site-config'},
{text: '命令行', link: '/cli'},
{text: '进阶用法', link: '/advance-guide'},
]
},
Expand All @@ -79,8 +80,17 @@ export default defineConfig({
{text: 'DouYin', link: '/guide/apps/douyin/index'},
{text: 'TikTok', link: '/guide/apps/tiktok/index'}
]
}
},

],
'/question-answer/': [
{
text: 'QA',
items: [
{text: 'Issue里经常反馈的问题', link: '/question-answer/qa'}
]
},
]
}
}
},
Expand Down Expand Up @@ -123,9 +133,9 @@ function cn_nav(): DefaultTheme.NavItem[] {
activeMatch: '/guide/'
},
{
text: '参考',
link: '/reference/cli',
activeMatch: '/reference/'
text: 'QA',
link: '/question-answer/qa',
activeMatch: '/question-answer/'
},
{
//text: pkg.version,
Expand All @@ -151,11 +161,6 @@ function en_nav(): DefaultTheme.NavItem[] {
link: '/en/guide/what-is-f2',
activeMatch: '/guide/'
},
{
text: 'reference',
link: '/en/site-config',
activeMatch: '/reference/'
},
{
//text: pkg.version,
text: version,
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/en/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ $ f2 dy -M one -u '7.64 gOX:/ w@f.oD 05/14 世界这本书 又多读了一页。
:::

The CLI parameter has the highest priority and allows you to set different download modes and links without modifying the configuration file.
For more detailed information on the "Jitterbug" CLI commands, see [CLI reference](./reference/cli).
For more detailed information on the "Jitterbug" CLI commands, see [CLI reference](/cli).


## What's next?
Expand Down
Empty file removed docs/en/reference/runtime-api.md
Empty file.
5 changes: 0 additions & 5 deletions docs/guide/api-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,3 @@ outline: deep
::: details 提取作品id
<<< @/snippets/douyin/sec-user-id.py#multi-user-id-snippet{14,17}
:::


## More

请查看 [API 完整列表](../reference/runtime-api).
84 changes: 19 additions & 65 deletions docs/guide/apps/douyin/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ outline: deep
| :--- | :--- | :--- |
| video_data | dict | 视频数据字典,包含视频ID、视频文案、作者昵称等 |

<<< @/snippets/douyin/one-video.py{6,8}
<<< @/snippets/douyin/one-video.py{15,17}

### 用户发布作品数据 🟢

Expand All @@ -134,7 +134,7 @@ outline: deep
| :--- | :--- | :--- |
| video_data | dict | 视频数据字典,包含视频ID、视频文案、作者昵称、页码等 |

<<< @/snippets/douyin/user-post.py{6,8,13,14}
<<< @/snippets/douyin/user-post.py{15,17-20,25-28}

### 用户喜欢作品数据 🟢

Expand All @@ -151,7 +151,7 @@ outline: deep
| :--- | :--- | :--- |
| aweme_data | dict | 视频数据字典,包含视频ID、视频文案、作者昵称、页码等 |

<<< @/snippets/douyin/user-like.py{6,8,13,14}
<<< @/snippets/douyin/user-like.py{15,17-20,25-28}

### 用户收藏作品数据 🟢

Expand All @@ -167,7 +167,7 @@ outline: deep
| :--- | :--- | :--- |
| aweme_data | dict | 视频数据字典,包含视频ID、视频文案、作者昵称、页码等 |

<<< @/snippets/douyin/user-collect.py{6,10,11}
<<< @/snippets/douyin/user-collect.py{16-17,22-25}

### 用户合辑作品数据 🟢

Expand All @@ -184,7 +184,7 @@ outline: deep
| :--- | :--- | :--- |
| aweme_data | dict | 视频数据字典,包含视频ID、视频文案、作者昵称、页码等 |

<<< @/snippets/douyin/user-mix.py{6,8,13,14}
<<< @/snippets/douyin/user-mix.py{16-18,21-24,29-32}

### 用户直播流数据 🟢

Expand All @@ -198,7 +198,7 @@ outline: deep
| :--- | :--- | :--- |
| webcast_data | dict | 直播数据字典,包含直播ID、直播标题、直播状态、观看人数、子分区、主播昵称等 |

<<< @/snippets/douyin/user-live.py{6}
<<< @/snippets/douyin/user-live.py{15}

### 用户直播流数据2 🟢

Expand All @@ -212,7 +212,7 @@ outline: deep
| :--- | :--- | :--- |
| webcast_data | dict | 直播数据字典,包含直播ID、直播标题、直播状态、观看人数、子分区、主播昵称等 |

<<< @/snippets/douyin/user-live-room-id.py{6}
<<< @/snippets/douyin/user-live-room-id.py{16-18}

### 用户信息 🟢

Expand All @@ -226,7 +226,7 @@ outline: deep
| :--- | :--- | :--- |
| UserProfileFilter | _to_dict() | 自定义的接口数据过滤器 | 用户数据字典,包含用户ID、用户昵称、用户签名、用户头像等 |

<<< @/snippets/douyin/user-profile.py{6-7}
<<< @/snippets/douyin/user-profile.py{15-16}

### 获取指定用户名 🔴

Expand All @@ -241,7 +241,7 @@ outline: deep
| :--- | :--- | :--- |
| user_nickname | str | 用户昵称 |

<<< @/snippets/douyin/user-nickname.py{7-9}
<<< @/snippets/douyin/user-nickname.py{17,19-21}

### 创建用户记录与目录 🟡

Expand All @@ -258,7 +258,7 @@ outline: deep
| :--- | :--- | :--- |
| user_path | Path | 用户目录路径对象 |

<<< @/snippets/douyin/user-get-add.py{7-12}
<<< @/snippets/douyin/user-get-add.py{18,20-22}

::: tip 提示
此为cli模式的接口,开发者可自行定义创建用户目录的功能。
Expand All @@ -278,7 +278,7 @@ outline: deep
| :--- | :--- | :--- |
|None | None ||

<<< @/snippets/douyin/video-get-add.py{6,10-12}
<<< @/snippets/douyin/video-get-add.py{6,23-25}

### SSO登录 🟢

Expand All @@ -294,7 +294,7 @@ outline: deep
| is_login | bool | 是否登录成功 |
| login_cookie | str | 登录cookie |

<<< @/snippets/douyin/sso-login.py
<<< @/snippets/douyin/sso-login.py{5}

::: danger 警告
由于扫码登录受风控影响较大,多数cookie都无法使用。为了保障体验,建议使用--auto-cookie命令自动从浏览器获取cookie,更多使用帮助参考cli命令。
Expand Down Expand Up @@ -388,7 +388,7 @@ outline: deep
| :--- | :--- | :--- |
| final_endpoint | str | 带Xbogus参数的完整地址 |

<<< @/snippets/douyin/xbogus.py#str-2-endpoint-snippet{7}
<<< @/snippets/douyin/xbogus.py#str-2-endpoint-snippet{6,7}

### 使用接口模型生成Xb参数 🟢

Expand All @@ -410,7 +410,7 @@ outline: deep

还可以使用爬虫引擎与过滤器采集数据。

<<< @/snippets/douyin/xbogus.py#model-2-endpoint-2-filter-snippet{10-16}
<<< @/snippets/douyin/xbogus.py#model-2-endpoint-2-filter-snippet{22-27}

更加抽象的高级方法可以直接调用handler接口的`handler_user_profile`

Expand Down Expand Up @@ -459,7 +459,7 @@ outline: deep
| :--- | :--- | :--- |
| aweme_id | str | 作品ID |

<<< @/snippets/douyin/aweme-id.py#single-aweme-id-snippet{6}
<<< @/snippets/douyin/aweme-id.py#single-aweme-id-snippet{5,6}

### 提取列表作品id 🟢

Expand Down Expand Up @@ -493,7 +493,7 @@ outline: deep
| webcast_id | str | 直播间RID |


<<< @/snippets/douyin/webcast-id.py#single-webcast-id-snippet{6}
<<< @/snippets/douyin/webcast-id.py#single-webcast-id-snippet{5,6}

### 提取列表直播间号 🟢

Expand All @@ -519,33 +519,6 @@ Rid是直播间的短链标识,room_id是直播间的唯一标识。
短链无法使用该接口返回Rid,如raw_urls中的第3和第4条链接只会返回room_id。需要搭配使用`fetch_user_live_videos_by_room_id`接口获取数据。
:::

### 获取请求count数列表 🔴

用于获取请求大小列表,根据请求页数与最大请求数计算每次请求数量。

| 参数 | 类型 | 说明 |
| :--- | :--- | :--- |
| page_counts | int | 请求页数 |
| max_counts | int | 最大请求数 |

| 返回 | 类型 | 说明 |
| :--- | :--- | :--- |
| request_sizes | list | 请求大小列表 |

<<< @/snippets/douyin/request-sizes.py{4,6}

::: warning 将会弃用
该接口将会在下个版本中弃用。
```python
max_counts = max_counts or float("inf")
videos_collected = 0
while videos_collected < max_counts:
current_request_size = min(page_counts, max_counts - videos_collected)
......
videos_collected += len(video.aweme_id)
```
:::

### 全局格式化文件名 🟢

根据配置文件的全局格式化文件名。
Expand All @@ -560,13 +533,12 @@ while videos_collected < max_counts:
| naming_template | str | 文件的命名模板 |
| aweme_data | dict | 作品数据的字典 |
| custom_fields | dict | 用户自定义字段, 用于替代默认的字段值 |
| desc_length_limit | int | 控制 'desc' 字段的长度限制,默认200 |

| 返回 | 类型 | 说明 |
| :--- | :--- | :--- |
| file_name | str | 格式化后的文件名 |

<<< @/snippets/douyin/format-file-name.py{7-10,14-22}
<<< @/snippets/douyin/format-file-name.py{13,19,28,32,34,36-39}

### 创建用户目录 🟢

Expand Down Expand Up @@ -598,7 +570,7 @@ while videos_collected < max_counts:
| :--- | :--- | :--- |
| user_path | Path | 用户目录路径对象 |

<<< @/snippets/douyin/user-folder.py#create-user-folder{4-6,9-10}
<<< @/snippets/douyin/user-folder.py#create-user-folder{17-19}

### 重命名用户目录 🟢

Expand All @@ -613,7 +585,7 @@ while videos_collected < max_counts:
| :--- | :--- | :--- |
| new_path | Path | 新的用户目录路径对象 |

<<< @/snippets/douyin/user-folder.py#rename-user-folder{7-8,10-11,15-16}
<<< @/snippets/douyin/user-folder.py#rename-user-folder{23-27,29-32}

::: tip 提示
如果目录不存在会先创建该用户目录再重命名。
Expand All @@ -637,24 +609,6 @@ while videos_collected < max_counts:
该接口很好的解决了用户改名之后重复重新下载的问题。集合在hanlder接口的`get_or_add_user_data`中,开发者无需关心直接调用hanlder的数据接口即可。
:::

### 提取低版本接口的desc 🔴

帮助解决desc字段出现版本过低提示的开发者提取desc的问题。

| 参数 | 类型 | 说明 |
| :--- | :--- | :--- |
| desc | str | 作品的desc |
| share_desc | str | 作品的share_desc |

| 返回 | 类型 | 说明 |
| :--- | :--- | :--- |
| extracted | str | 提取后的desc |

<<< @/snippets/douyin/extract-desc.py

::: tip 提示
出现版本过低的问题是接口携带的参数版本过低如`version_code` `version_name` 等,开发者可以直接使用接口数据模型创建完整的参数。
:::

### 显示二维码 🟢

Expand Down
Loading

0 comments on commit 8759a27

Please sign in to comment.