modify some scripts.
This commit is contained in:
@ -24,27 +24,16 @@ update_dir = '../result'
|
||||
performers_dir = f'{update_dir}/performers'
|
||||
movies_dir = f'{update_dir}/movies'
|
||||
|
||||
def uniq_performers(new_performers):
|
||||
try:
|
||||
if not isinstance(new_performers, list):
|
||||
raise TypeError(f"new_performers should be a list, but got {type(new_performers)}")
|
||||
def dist_stu_href_rewrite(href):
|
||||
# 提取 ID(适用于 distrib 或 studio)
|
||||
import re
|
||||
match = re.search(r"(distrib|studio)=(\d+)", href)
|
||||
if not match:
|
||||
return None # 不是目标 URL,返回 None
|
||||
|
||||
seen = set()
|
||||
unique_performers = []
|
||||
|
||||
for item in new_performers:
|
||||
if not item or item['href'] is None:
|
||||
raise ValueError(f"Invalid item in new_performers: {item}")
|
||||
|
||||
if item["href"] not in seen:
|
||||
seen.add(item["href"])
|
||||
unique_performers.append(item)
|
||||
|
||||
return unique_performers
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Error in remove_duplicate_performers: {e}")
|
||||
return [] # 返回空列表,避免程序崩溃
|
||||
key, id_number = match.groups()
|
||||
new_url = f"https://www.iafd.com/{key}.rme/{key}={id_number}"
|
||||
return new_url
|
||||
|
||||
# 创建目录
|
||||
def create_sub_directory(base_dir, str):
|
||||
@ -90,3 +79,15 @@ def write_movie_json(href, data):
|
||||
except Exception as e:
|
||||
logging.error(f"Error writing file {full_path}: {e}")
|
||||
|
||||
|
||||
# 读取json文件并返回内容
|
||||
def read_json(file_path):
|
||||
try:
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
return json.load(f)
|
||||
except FileNotFoundError:
|
||||
print(f"文件 {file_path} 未找到.")
|
||||
return None
|
||||
except json.JSONDecodeError:
|
||||
print(f"文件 {file_path} 解析错误.")
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user