-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
急求。Seed大佬,下载视频出现FileNotFoundError: [Errno 2] No such file or directory。感觉是{desc}参数太长导致。 #772
Comments
按大佬的方法,下载成功了。 我下载的结果,下载的文件名称是:2024-11-20 07-00-00_成功的交易者并非生来就守规矩_但他们都最终学会了......#交易人生#金融人_#期货_#交易心得#交易_video.mp4 。 修改请求: |
打开 不建议这样子做,因为有些短文案的情况会造成前省略号后内容重复。 如果还是需要我可以给你判断后的修改结果。def split_filename(text: str, os_limit: dict) -> str:
"""
根据操作系统的字符限制分割文件名,并用 '......' 代替。
Args:
text (str): 要计算的文本
os_limit (dict): 操作系统的字符限制字典
Returns:
str: 分割后的文本
"""
import sys
# 获取操作系统名称和文件名长度限制
os_name = sys.platform
filename_length_limit = os_limit.get(os_name, 200)
# 计算中文字符长度(中文字符长度*3)
chinese_length = sum(1 for char in text if "\u4e00" <= char <= "\u9fff") * 3
# 计算英文字符长度
english_length = sum(1 for char in text if char.isalpha())
# 计算下划线数量
num_underscores = text.count("_")
# 计算总长度
total_length = chinese_length + english_length + num_underscores
# 如果总长度超过操作系统限制或手动设置的限制,则根据限制进行分割
if total_length > filename_length_limit:
split_index = max((filename_length_limit - 6) * 2 // 3, 1)
end_index = max((filename_length_limit - 6) // 3, 1)
# 如果分割前后部分有重叠内容,确保至少有一个字符间隔
if split_index + end_index > len(text):
split_index = max(len(text) - end_index - 1, 1)
split_text = text[:split_index] + "......" + text[-end_index:]
return split_text
else:
return text 调整之后前半部分的长度是后半部分的2倍。 |
Thank you,sir! |
下载的视频网址:https://www.douyin.com/user/MS4wLjABAAAAHulzlH6cETVMrnFTuEVrGb6GXcV6pw0S4uC4jQSTUyhnnFtuWs8zryKCcyaM9shm
命令:
f2 dy --auto-cookie firefox
f2 dy -u https://www.douyin.com/user/MS4wLjABAAAAHulzlH6cETVMrnFTuEVrGb6GXcV6pw0S4uC4jQSTUyhnnFtuWs8zryKCcyaM9shm
配置文件内容:
douyin:
cookie:
cover: false
desc: no
folderize: false
interval: all
languages: zh_CN
max_connections: 5
max_counts: 0
max_retries: 4
max_tasks: 6
mode: post
music: false
naming: '{create}{desc}{nickname}'
page_counts: 20
path: ./Download
timeout: 6
我试了好多主页,名字短的是成功的。试了好多遍。发现,应该是视频的naming: '{create}{desc}{nickname}'原因,{desc}参数的名字太长导致视频文件名和目录路径太长了,才出现下载中途中断。大佬,觉得是这个原因吗?
请求:
在不解除Windows系统中文件名和目录路径的最大长度限制的情况下,如何修改程序中的参数来实现限制{desc}长度,能下载视频成功?具体在哪里修改程序,如何修改程序?麻烦大佬明示。急求。
The text was updated successfully, but these errors were encountered: