(input_file)
| 50 | |
| 51 | |
| 52 | def process_script_ids(input_file): |
| 53 | result_text = [] |
| 54 | try: |
| 55 | with open(input_file, 'r', encoding='utf-8') as infile: |
| 56 | first_line = infile.readline().strip() |
| 57 | if first_line.startswith("<!--") and first_line.endswith("-->"): |
| 58 | greasyfork_ids = first_line[4:-3].split(',') |
| 59 | print(f"GreasyFork ID: {greasyfork_ids}") |
| 60 | else: |
| 61 | print(f"错误:第一行格式无效 {first_line}") |
| 62 | return None |
| 63 | |
| 64 | for greasyfork_id in greasyfork_ids: |
| 65 | greasyfork_id = greasyfork_id.strip() |
| 66 | if not greasyfork_id.isdigit(): |
| 67 | print(f"警告:跳过无效的脚本编号 {greasyfork_id}") |
| 68 | continue |
| 69 | result = fetch_script_json(int(greasyfork_id)) |
| 70 | if result: |
| 71 | result_text.append(result) |
| 72 | print(f"成功处理脚本编号 {greasyfork_id}") |
| 73 | else: |
| 74 | print(f"失败:无法获取脚本编号 {greasyfork_id}") |
| 75 | return '<br>\n'.join(result_text) |
| 76 | except FileNotFoundError: |
| 77 | print(f"错误:找不到输入文件 {input_file}") |
| 78 | except Exception as e: |
| 79 | print(f"运行时出错:{e}") |
| 80 | return None |
| 81 | |
| 82 | |
| 83 | def main(): |
no test coverage detected