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

[FEATRUE / REQUEST]抖音下载时遇到文件名过长或有特殊字符会报错停止,后续能否规避,遇到单条下载失败的跳过继续下载后面媒体文件。 #179

Open
huyin324 opened this issue Sep 13, 2024 · 4 comments
Labels
需求建议(enhancement) 新功能或需求(New feature or request)

Comments

@huyin324
Copy link

抖音下载全部作品时遇到文件名过长或有特殊字符会报错停止,后续能否规避,遇到单条下载失败的跳过继续下载后面媒体文件。

例如抖音下载下面链接全部作品,每次都会卡在同一条上,报错后程序即刻终止,后续文件无法下载。https://www.douyin.com/user/MS4wLjABAAAAaQSQAWWPRAq96jzhfadyAZV4-KOjQjqH1eR-iNWhJys

具体报错内容如下:
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in run_code
File "C:\Anaconda\envs\python3.11\Scripts\f2.exe_main
.py", line 7, in
File "C:\Anaconda\envs\python3.11\Lib\site-packages\click\core.py", line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Anaconda\envs\python3.11\Lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\Anaconda\envs\python3.11\Lib\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Anaconda\envs\python3.11\Lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Anaconda\envs\python3.11\Lib\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Anaconda\envs\python3.11\Lib\site-packages\click\decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Anaconda\envs\python3.11\Lib\site-packages\f2\apps\douyin\cli.py", line 441, in douyin
ctx.invoke(set_cli_config, **kwargs)
File "C:\Anaconda\envs\python3.11\Lib\site-packages\click\core.py", line 783, in invoke
return callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Anaconda\envs\python3.11\Lib\site-packages\click\decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Anaconda\envs\python3.11\Lib\site-packages\f2\cli\cli_commands.py", line 182, in set_cli_config
asyncio.run(run_app(kwargs))
File "C:\Anaconda\envs\python3.11\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Anaconda\envs\python3.11\Lib\asyncio\runners.py", line 118, in run
return self.loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Anaconda\envs\python3.11\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Anaconda\envs\python3.11\Lib\site-packages\f2\cli\cli_commands.py", line 190, in run_app
await app_module.main(kwargs)
File "C:\Anaconda\envs\python3.11\Lib\site-packages\f2\apps\douyin\handler.py", line 1849, in main
await mode_function_mapmode
File "C:\Anaconda\envs\python3.11\Lib\site-packages\f2\apps\douyin\handler.py", line 257, in handle_user_post
await self.downloader.create_download_tasks(
File "C:\Anaconda\envs\python3.11\Lib\site-packages\f2\apps\douyin\dl.py", line 140, in create_download_tasks
await self.execute_tasks()
File "C:\Anaconda\envs\python3.11\Lib\site-packages\f2\dl\base_downloader.py", line 570, in execute_tasks
await asyncio.gather(*self.download_tasks)
File "C:\Anaconda\envs\python3.11\Lib\site-packages\f2\dl\base_downloader.py", line 170, in download_file
async with aiofiles.open(
File "C:\Anaconda\envs\python3.11\Lib\site-packages\aiofiles\base.py", line 78, in aenter
self.obj = await self.coro
^^^^^^^^^^^^^^^^
File "C:\Anaconda\envs\python3.11\Lib\site-packages\aiofiles\threadpool_init
.py", line 80, in open
f = yield from loop.run_in_executor(executor, cb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Anaconda\envs\python3.11\Lib\concurrent\futures\thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 22] Invalid argument: '\\hy-nas\Data\douyin_f2\douyin_yaml\download\douyin\post\Ss_L\2024-09-05 18-40-18_每天有氧的时候都在后悔这b嘴怎么就这么馋为什么要吃成一个胖子什么肥一定要我本人亲自减我发誓我再也不吃了老天奶啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈要发疯了啊啊啊啊啊#精神状态belike
......一个胖子什么肥一定要我本人亲自减我发誓我再也不吃了老天奶啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈要发疯了啊啊啊啊啊#精神状态belike
#痛苦面具
#今天你锻炼了吗
#抽象艺术
#健身打卡_video.tmp'

@huyin324 huyin324 added the 需求建议(enhancement) 新功能或需求(New feature or request) label Sep 13, 2024
@xiaolinli123
Copy link

遇到类似的问题
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in run_code
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Scripts\f2.exe_main
.py", line 7, in
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\f2\apps\douyin\cli.py", line 441, in douyin
ctx.invoke(set_cli_config, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\core.py", line 783, in invoke
return _callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\click\decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\f2\cli\cli_commands.py", line 182, in set_cli_config
asyncio.run(run_app(kwargs))
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
return self.loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\f2\cli\cli_commands.py", line 190, in run_app
await app_module.main(kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\f2\apps\douyin\handler.py", line 1849, in main
await mode_function_mapmode
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\f2\apps\douyin\handler.py", line 257, in handle_user_post
await self.downloader.create_download_tasks(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\f2\apps\douyin\dl.py", line 140, in create_download_tasks
await self.execute_tasks()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\f2\dl\base_downloader.py", line 570, in execute_tasks
await asyncio.gather(*self.download_tasks)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\f2\dl\base_downloader.py", line 170, in download_file
async with aiofiles.open(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\aiofiles\base.py", line 78, in aenter
self.obj = await self.coro
^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\aiofiles\threadpool_init
.py", line 80, in open
f = yield from loop.run_in_executor(executor, cb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\concurrent\futures\thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\Administrator\Download\douyin\post\赖赖\2024-01-21 17-42-10_和朋友坐在海边的草地 上发呆_突然想到了_闯进森林潜入海底_这句歌词_然后花了几分钟粗扒了一下这支喜欢了很久的编舞_蹦蹦跳跳地很开心_舞蹈是表达感受的一种方式
#张小橘子编舞
#失眠飞行......和朋友坐在海边的草地上发呆_突然想到了_闯进森林潜入海底_这句歌词_然后花了几分钟粗扒了一下这支喜欢了很久的编舞_蹦蹦跳跳地很开心_舞蹈是表达感受的一种方式
#张小橘子编舞
#失眠飞行_video.tmp'

@xiaolinli123
Copy link

如果是文件名称过长导致的失败。可通过解除Windows系统中文件名和目录路径的最大长度限制解决。

@crab890715
Copy link

我把源码改成用视频id了,但是我不知道作者为什么不用id,想知道原因

@xiaolinli123
Copy link

我把源码改成用视频id了,但是我不知道作者为什么不用id,想知道原因

我不知道你说的视频id是什么

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
需求建议(enhancement) 新功能或需求(New feature or request)
Projects
None yet
Development

No branches or pull requests

3 participants