This commit is contained in:
岛风 2024-02-23 20:19:05 +08:00
commit cf23886f64
2 changed files with 6 additions and 7 deletions

View File

@ -1,6 +1,6 @@
## Updated ## Updated
2024.2.19 - 恐怖片 新增 2024.2.20 - Anime 新增
2024.2.19 - bilibili 新增 2024.2.19 - bilibili 新增
@ -16,6 +16,5 @@ Live - 魔法未来 2014-2016
Anime - 排球少年 Anime - 排球少年
[资源提交](https://kami.kim/AnimeFunsion/AlistSoure/issues) [资源提交](https://kami.kim/AnimeFunsion/AlistSoure/issues)

View File

@ -11,10 +11,10 @@ def natural_sort_key(s):
def generate_urls(file_names, base_url, sub_directory): def generate_urls(file_names, base_url, sub_directory):
"""根据文件名、基础URL和子目录生成URL链接""" """根据文件名、基础URL和子目录生成URL链接"""
urls = [] urls = []
# 确保base_url和sub_directory以斜线结尾 # 确保base_url和sub_directory以斜线结尾如果sub_directory不为空
if not base_url.endswith('/'): if not base_url.endswith('/'):
base_url += '/' base_url += '/'
if not sub_directory.endswith('/'): if sub_directory and not sub_directory.endswith('/'):
sub_directory += '/' sub_directory += '/'
current_timestamp = int(time.time()) # 获取当前时间的时间戳,转换为整数 current_timestamp = int(time.time()) # 获取当前时间的时间戳,转换为整数
for name in sorted(file_names, key=natural_sort_key): # 使用自定义排序 for name in sorted(file_names, key=natural_sort_key): # 使用自定义排序
@ -35,7 +35,7 @@ def save_urls(urls, output_file):
def parse_arguments(): def parse_arguments():
"""解析命令行参数""" """解析命令行参数"""
parser = argparse.ArgumentParser(description='Generate URLs from file names.') 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() return parser.parse_args()
def main(): def main():
@ -45,9 +45,9 @@ def main():
# 固定的base_url值 # 固定的base_url值
base_url = 'https://link.kite.kim/feng' base_url = 'https://link.kite.kim/feng'
# 获取当前目录下的所有文件名,排除此脚本文件 # 获取当前目录下的所有文件名,排除此脚本文件和隐藏文件
current_script = os.path.basename(__file__) current_script = os.path.basename(__file__)
file_names = [f for f in os.listdir('.') if os.path.isfile(f) and f != current_script] file_names = [f for f in os.listdir('.') if os.path.isfile(f) and f != current_script and not f.startswith('.')]
# 生成URL链接 # 生成URL链接
urls = generate_urls(file_names, base_url, args.dir) urls = generate_urls(file_names, base_url, args.dir)