Merge branch 'main' of https://kami.kim/AnimeFunsion/AlistSource
This commit is contained in:
commit
cf23886f64
@ -1,6 +1,6 @@
|
||||
## Updated
|
||||
|
||||
2024.2.19 - 恐怖片 新增
|
||||
2024.2.20 - Anime 新增
|
||||
|
||||
2024.2.19 - bilibili 新增
|
||||
|
||||
@ -16,6 +16,5 @@ Live - 魔法未来 2014-2016
|
||||
Anime - 排球少年
|
||||
|
||||
|
||||
|
||||
[资源提交](https://kami.kim/AnimeFunsion/AlistSoure/issues)
|
||||
|
||||
|
10
urls/main.py
10
urls/main.py
@ -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():
|
||||
@ -45,9 +45,9 @@ def main():
|
||||
# 固定的base_url值
|
||||
base_url = 'https://link.kite.kim/feng'
|
||||
|
||||
# 获取当前目录下的所有文件名,排除此脚本文件
|
||||
# 获取当前目录下的所有文件名,排除此脚本文件和隐藏文件
|
||||
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链接
|
||||
urls = generate_urls(file_names, base_url, args.dir)
|
||||
|
Loading…
Reference in New Issue
Block a user