fix bug
This commit is contained in:
parent
4d9a38ad68
commit
c9010de050
@ -11,10 +11,10 @@ def natural_sort_key(s):
|
||||
def generate_urls(file_names, base_url, sub_directory):
|
||||
"""根据文件名、基础URL和子目录生成URL链接"""
|
||||
urls = []
|
||||
# 确保base_url和sub_directory以斜线结尾
|
||||
# 确保base_url和sub_directory以斜线结尾(如果sub_directory不为空)
|
||||
if not base_url.endswith('/'):
|
||||
base_url += '/'
|
||||
if not sub_directory.endswith('/'):
|
||||
if sub_directory and not sub_directory.endswith('/'):
|
||||
sub_directory += '/'
|
||||
current_timestamp = int(time.time()) # 获取当前时间的时间戳,转换为整数
|
||||
for name in sorted(file_names, key=natural_sort_key): # 使用自定义排序
|
||||
@ -35,7 +35,7 @@ def save_urls(urls, output_file):
|
||||
def parse_arguments():
|
||||
"""解析命令行参数"""
|
||||
parser = argparse.ArgumentParser(description='Generate URLs from file names.')
|
||||
parser.add_argument('--dir', type=str, help='Sub-directory for generating file URLs', required=True)
|
||||
parser.add_argument('--dir', type=str, default='', help='Sub-directory for generating file URLs (optional)')
|
||||
return parser.parse_args()
|
||||
|
||||
def main():
|
||||
|
Loading…
Reference in New Issue
Block a user