feat: 完善CLI目录参数处理逻辑
This commit is contained in:
@@ -243,13 +243,51 @@ def main():
|
||||
|
||||
parser.add_argument('--check', action='store_true', help='查重')
|
||||
parser.add_argument('--url', type=str, help='要检查的URL')
|
||||
parser.add_argument('--archive', type=str, help='要归档的文件路径')
|
||||
parser.add_argument('--base-path', type=str, help='知识库根目录')
|
||||
|
||||
parser.add_argument('--archive', type=str, help='归档的文件路径')
|
||||
parser.add_argument('--base-path', type=str, help='获取知识库根目录')
|
||||
|
||||
parser.add_argument('--pending', action='store_true', help='获取url解析目录')
|
||||
parser.add_argument('--metadata', action='store_true', help='获取元数据目录')
|
||||
parser.add_argument('--content', action='store_true', help='获取内容目录')
|
||||
parser.add_argument('--content_downloads', action='store_true', help='获取主内容下载目录')
|
||||
parser.add_argument('--content_subtitles', action='store_true', help='获取字幕目录')
|
||||
parser.add_argument('--analyzed', action='store_true', help='获取深度分析目录')
|
||||
parser.add_argument('--archive', action='store_true', help='获取归档目录')
|
||||
parser.add_argument('--archive_subscriptions', action='store_true', help='获取订阅信息目录')
|
||||
parser.add_argument('--extract_platform', type=str, help='要提取平台名称的文件名')
|
||||
args = parser.parse_args()
|
||||
|
||||
base_path = Path(args.base_path) if args.base_path else None
|
||||
|
||||
# 获取目录参数处理
|
||||
dirs = ensure_directories(base_path)
|
||||
|
||||
if args.extract_platform:
|
||||
platform = extract_platform(args.extract_platform)
|
||||
print(json.dumps({"platform": platform}, ensure_ascii=False, indent=2))
|
||||
return
|
||||
|
||||
# 目录路径查询
|
||||
dir_map = {
|
||||
"pending": dirs.get("pending"),
|
||||
"metadata": dirs.get("metadata"),
|
||||
"content": dirs.get("content"),
|
||||
"content_downloads": dirs.get("content_downloads"),
|
||||
"content_subtitles": dirs.get("content_subtitles"),
|
||||
"analyzed": dirs.get("analyzed"),
|
||||
"archive": dirs.get("archive"),
|
||||
"archive_subscriptions": dirs.get("archive_subscriptions"),
|
||||
}
|
||||
|
||||
found = False
|
||||
for arg_name, dir_path in dir_map.items():
|
||||
if getattr(args, arg_name, False) and dir_path:
|
||||
print(json.dumps({"path": str(dir_path)}, ensure_ascii=False, indent=2))
|
||||
found = True
|
||||
|
||||
if found:
|
||||
return
|
||||
|
||||
if args.check and args.url:
|
||||
result = check_duplicate(base_path, args.url)
|
||||
print(json.dumps(result, ensure_ascii=False, indent=2))
|
||||
|
||||
Reference in New Issue
Block a user