Skip to content
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

[BUG] tiktok只能下载第一页的视频 #270

Open
xshwy opened this issue Feb 10, 2025 · 4 comments
Open

[BUG] tiktok只能下载第一页的视频 #270

xshwy opened this issue Feb 10, 2025 · 4 comments
Labels
故障(bug) 代码问题导致的错误(Bugs caused by code problems) 已确认(confirmed) 该issue已被处理,将在下次推送中更新(The issue has been processed and will be updated in the next push)

Comments

@xshwy
Copy link

xshwy commented Feb 10, 2025

详细描述错误
正确配置device_id后,可以正常下载tiktok的视频列表,但是只能下载第一页的视频,第二页会报错崩溃。

系统平台

单击展开 Q:你在哪个平台(Win/Linux/Mac)上运行?你使用的是什么浏览器?你使用的是什么终端软件?你使用的F2是什么版本?

A:

  • 操作系统: MacOS 15.2 (24C101)
  • 浏览器 Chrome Version 133.0.6943.53 (Official Build) (arm64)
  • 终端 iTerm2 Zsh
  • F2版本 0.0.1.7

错误重现

单击展开 Q: 请你复制并粘贴出错时运行的命令和配置文件内容,以及重现该行为的步骤。如果你一次性就提供完整信息,就会节省很多解决问题的时间。

A:

venv ❯ f2 tk -c tk.yaml -M post -u https://www.tiktok.com/@your_cutepet --desc true
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────── F2 版本检查 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 您当前使用的是最新版本:0.0.1.7                                                                                                                                                                                                                     │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
INFO     应用:tiktok
INFO     模式:post
INFO     主配置路径:/Users/names/project/f2test/venv/lib/python3.13/site-packages/f2/conf/app.yaml
INFO     自定义配置路径:/Users/names/project/f2test/tk.yaml
INFO     处理用户:MS4wLjABAAAAC5nP6P-kjA7F2mxSlJ-sux8_rKhKO1LODfQaskbDFWVGfh56vPUBrAdmMy0E0E6o 发布的作品
────────────────────────────────────────────────────────────────────────────────────────────────────────── 处理第 0 页 (2025-02-10 17-22-07) ──────────────────────────────────────────────────────────────────────────────────────────────────────────
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7245827628286954754_#Pet_#CutePet_#Cat_#cuteanimals__video.mp4
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7245827628286954754_#Pet_#CutePet_#Cat_#cuteanimals__desc.txt
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7233585942072806657_#Pet_#CutePet_#Cat_#cuteanimals__video.mp4
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7233585942072806657_#Pet_#CutePet_#Cat_#cuteanimals__desc.txt
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7233209867727834370_#Pet_#CutePet_#Cat_#cuteanimals__video.mp4
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7233209867727834370_#Pet_#CutePet_#Cat_#cuteanimals__desc.txt
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7395011727290649873_#pet_#CutePet_#cat_#cuteanimals__video.mp4
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7395011727290649873_#pet_#CutePet_#cat_#cuteanimals__desc.txt
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7389440053774241031_#pet_#CutePet_#cat_#cuteanimals__video.mp4
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7389440053774241031_#pet_#CutePet_#cat_#cuteanimals__desc.txt
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7383512854030322945_#pet_#CutePet_#cat_#cuteanimals__video.mp4
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7383512854030322945_#pet_#CutePet_#cat_#cuteanimals__desc.txt
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7377190895659011344_#pet_#CutePet_#cat_#cuteanimals__video.mp4
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7377190895659011344_#pet_#CutePet_#cat_#cuteanimals__desc.txt
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7374740803714927873_#pet_#CutePet_#cat_#cuteanimals__video.mp4
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7374740803714927873_#pet_#CutePet_#cat_#cuteanimals__desc.txt
────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 当前任务处理完成 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
INFO     等待 10 秒后继续
──────────────────────────────────────────────────────────────────────────────────────────────────── 处理第 1717065654000 页 (2024-05-30 18-40-54) ────────────────────────────────────────────────────────────────────────────────────────────────────
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7367575475461410065_#pet_#CutePet_#cat_#cuteanimals__video.mp4
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7367575475461410065_#pet_#CutePet_#cat_#cuteanimals__desc.txt
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7363467327364549905_#pet_#CutePet_#cat_#cuteanimals__video.mp4
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7363467327364549905_#pet_#CutePet_#cat_#cuteanimals__desc.txt
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7359380331146775824_#pet_#CutePet_#cat_#cuteanimals__video.mp4
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7359380331146775824_#pet_#CutePet_#cat_#cuteanimals__desc.txt
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7356029303156428048_#pet_#CutePet_#cat_#cuteanimals__video.mp4
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7356029303156428048_#pet_#CutePet_#cat_#cuteanimals__desc.txt
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7350853967515061506_#pet_#CutePet_#cat_#cuteanimals__video.mp4
INFO     [  跳过  ]: your_cute_pet_7215928992633226246_7350853967515061506_#pet_#CutePet_#cat_#cuteanimals__desc.txt
────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 当前任务处理完成 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Traceback (most recent call last):
  File "/Users/names/project/f2test/venv/bin/f2", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/Users/names/project/f2test/venv/lib/python3.13/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/Users/names/project/f2test/venv/lib/python3.13/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/Users/names/project/f2test/venv/lib/python3.13/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/names/project/f2test/venv/lib/python3.13/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/names/project/f2test/venv/lib/python3.13/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/names/project/f2test/venv/lib/python3.13/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/names/project/f2test/venv/lib/python3.13/site-packages/f2/apps/tiktok/cli.py", line 456, in tiktok
    ctx.invoke(set_cli_config, **kwargs)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/names/project/f2test/venv/lib/python3.13/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/names/project/f2test/venv/lib/python3.13/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/names/project/f2test/venv/lib/python3.13/site-packages/f2/cli/cli_commands.py", line 199, in set_cli_config
    asyncio.run(run_app(kwargs))
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 720, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/Users/names/project/f2test/venv/lib/python3.13/site-packages/f2/cli/cli_commands.py", line 205, in run_app
    await app_module.main(kwargs)
  File "/Users/names/project/f2test/venv/lib/python3.13/site-packages/f2/apps/tiktok/handler.py", line 1194, in main
    await mode_function_map[mode](TiktokHandler(kwargs))
  File "/Users/names/project/f2test/venv/lib/python3.13/site-packages/f2/apps/tiktok/handler.py", line 311, in handle_user_post
    async for aweme_data_list in self.fetch_user_post_videos(
    ...<5 lines>...
        )
  File "/Users/names/project/f2test/venv/lib/python3.13/site-packages/f2/apps/tiktok/handler.py", line 389, in fetch_user_post_videos
    if cursor < min_cursor:
       ^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'str' and 'int'

Q: 请添加调试命令f2 -d DEBUG重新运行出错的命令并提供日志目录下的日志文件。

A:

2025-02-10 17:25:49,621 - f2 - INFO - 应用:tiktok
2025-02-10 17:25:49,648 - f2 - INFO - 模式:post
2025-02-10 17:25:49,649 - f2 - INFO - 主配置路径:/Users/names/project/f2test/venv/lib/python3.13/site-packages/f2/conf/app.yaml
2025-02-10 17:25:49,650 - f2 - INFO - 自定义配置路径:/Users/names/project/f2test/tk.yaml
2025-02-10 17:25:52,951 - f2 - INFO - 处理用户:MS4wLjABAAAAC5nP6P-kjA7F2mxSlJ-sux8_rKhKO1LODfQaskbDFWVGfh56vPUBrAdmMy0E0E6o 发布的作品
2025-02-10 17:25:54,096 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7245827628286954754_#Pet_#CutePet_#Cat_#cuteanimals__video.mp4[/cyan]
2025-02-10 17:25:54,098 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7245827628286954754_#Pet_#CutePet_#Cat_#cuteanimals__desc.txt[/cyan]
2025-02-10 17:25:54,101 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7233585942072806657_#Pet_#CutePet_#Cat_#cuteanimals__video.mp4[/cyan]
2025-02-10 17:25:54,103 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7233585942072806657_#Pet_#CutePet_#Cat_#cuteanimals__desc.txt[/cyan]
2025-02-10 17:25:54,106 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7233209867727834370_#Pet_#CutePet_#Cat_#cuteanimals__video.mp4[/cyan]
2025-02-10 17:25:54,107 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7233209867727834370_#Pet_#CutePet_#Cat_#cuteanimals__desc.txt[/cyan]
2025-02-10 17:25:54,110 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7395011727290649873_#pet_#CutePet_#cat_#cuteanimals__video.mp4[/cyan]
2025-02-10 17:25:54,112 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7395011727290649873_#pet_#CutePet_#cat_#cuteanimals__desc.txt[/cyan]
2025-02-10 17:25:54,115 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7389440053774241031_#pet_#CutePet_#cat_#cuteanimals__video.mp4[/cyan]
2025-02-10 17:25:54,116 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7389440053774241031_#pet_#CutePet_#cat_#cuteanimals__desc.txt[/cyan]
2025-02-10 17:25:54,119 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7383512854030322945_#pet_#CutePet_#cat_#cuteanimals__video.mp4[/cyan]
2025-02-10 17:25:54,120 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7383512854030322945_#pet_#CutePet_#cat_#cuteanimals__desc.txt[/cyan]
2025-02-10 17:25:54,123 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7377190895659011344_#pet_#CutePet_#cat_#cuteanimals__video.mp4[/cyan]
2025-02-10 17:25:54,124 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7377190895659011344_#pet_#CutePet_#cat_#cuteanimals__desc.txt[/cyan]
2025-02-10 17:25:54,127 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7374740803714927873_#pet_#CutePet_#cat_#cuteanimals__video.mp4[/cyan]
2025-02-10 17:25:54,128 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7374740803714927873_#pet_#CutePet_#cat_#cuteanimals__desc.txt[/cyan]
2025-02-10 17:25:54,340 - f2 - INFO - 等待 10 秒后继续
2025-02-10 17:26:05,233 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7367575475461410065_#pet_#CutePet_#cat_#cuteanimals__video.mp4[/cyan]
2025-02-10 17:26:05,234 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7367575475461410065_#pet_#CutePet_#cat_#cuteanimals__desc.txt[/cyan]
2025-02-10 17:26:05,239 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7363467327364549905_#pet_#CutePet_#cat_#cuteanimals__video.mp4[/cyan]
2025-02-10 17:26:05,240 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7363467327364549905_#pet_#CutePet_#cat_#cuteanimals__desc.txt[/cyan]
2025-02-10 17:26:05,243 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7359380331146775824_#pet_#CutePet_#cat_#cuteanimals__video.mp4[/cyan]
2025-02-10 17:26:05,245 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7359380331146775824_#pet_#CutePet_#cat_#cuteanimals__desc.txt[/cyan]
2025-02-10 17:26:05,247 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7356029303156428048_#pet_#CutePet_#cat_#cuteanimals__video.mp4[/cyan]
2025-02-10 17:26:05,249 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7356029303156428048_#pet_#CutePet_#cat_#cuteanimals__desc.txt[/cyan]
2025-02-10 17:26:05,251 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7350853967515061506_#pet_#CutePet_#cat_#cuteanimals__video.mp4[/cyan]
2025-02-10 17:26:05,253 - f2 - INFO - [cyan][  跳过  ]: your_cute_pet_7215928992633226246_7350853967515061506_#pet_#CutePet_#cat_#cuteanimals__desc.txt[/cyan]

Q: 如果是开发者请提供最小的代码示例

A:

预期行为
预期正常下载tiktok视频

屏幕截图
错误日志过多,请详见上方的「错误重现」

日志文件
错误日志过多,请详见上方的「错误重现」

其他
如有,可以添加有关问题的其他信息。

@xshwy xshwy added the 故障(bug) 代码问题导致的错误(Bugs caused by code problems) label Feb 10, 2025
Copy link

dosubot bot commented Feb 10, 2025

@xshwy 你好,我是Dosu!我是一个可以帮助解决bug、回答问题并成为贡献者的机器人。我可以帮助你解决问题,等待人类维护者的过程中我会一直在这里帮助你。

The issue you're encountering seems to be related to a type mismatch in the fetch_user_post_videos function, where a comparison is attempted between a string and an integer. This is indicated by the error message: TypeError: '<' not supported between instances of 'str' and 'int'.

In the fetch_user_post_videos function, both cursor and min_cursor are expected to be integers [1]. The error suggests that one of these variables is being set as a string, which leads to the crash when trying to compare them.

To resolve this issue, you should ensure that the cursor and min_cursor values are correctly initialized and maintained as integers throughout the function. You might want to check the part of the code where these values are set or updated, especially after fetching data from the TikTok API, to ensure they remain integers.

If you have control over the code, you can add a type conversion to ensure that these variables are integers, like so:

cursor = int(cursor)
min_cursor = int(min_cursor)

This should be done before any comparison operations involving these variables. If the issue persists, you may need to trace back to where these values are initially set or fetched to ensure they are correctly handled as integers.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@xshwy
Copy link
Author

xshwy commented Feb 10, 2025

@xshwy 你好,我是Dosu!我是一个可以帮助解决bug、回答问题并成为贡献者的机器人。我可以帮助你解决问题,等待人类维护者的过程中我会一直在这里帮助你。

The issue you're encountering seems to be related to a type mismatch in the fetch_user_post_videos function, where a comparison is attempted between a string and an integer. This is indicated by the error message: TypeError: '<' not supported between instances of 'str' and 'int'.

In the fetch_user_post_videos function, both cursor and min_cursor are expected to be integers [1]. The error suggests that one of these variables is being set as a string, which leads to the crash when trying to compare them.

To resolve this issue, you should ensure that the cursor and min_cursor values are correctly initialized and maintained as integers throughout the function. You might want to check the part of the code where these values are set or updated, especially after fetching data from the TikTok API, to ensure they remain integers.

If you have control over the code, you can add a type conversion to ensure that these variables are integers, like so:

cursor = int(cursor)
min_cursor = int(min_cursor)
This should be done before any comparison operations involving these variables. If the issue persists, you may need to trace back to where these values are initially set or fetched to ensure they are correctly handled as integers.

To continue talking to Dosu, mention @dosu.

Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

这个可用,我在 f2/apps/tiktok/handler.py 这个文件添加了上面的格式转换代码,即可正常运行

Image

@Johnserf-Seed
Copy link
Owner

Image
复现成功,具体原因是因为tk把返回的cursor改回了str类型导致报错

@Johnserf-Seed Johnserf-Seed added the 已确认(confirmed) 该issue已被处理,将在下次推送中更新(The issue has been processed and will be updated in the next push) label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
故障(bug) 代码问题导致的错误(Bugs caused by code problems) 已确认(confirmed) 该issue已被处理,将在下次推送中更新(The issue has been processed and will be updated in the next push)
Projects
None yet
Development

No branches or pull requests

2 participants