add some scripts.

This commit is contained in:
2025-02-11 16:07:43 +08:00
parent 2cab12ea34
commit 62a2fbdc77
20 changed files with 148909 additions and 4 deletions

View File

@ -55,7 +55,8 @@ def is_recent_video(upload_date):
# 获取视频列表
def fetch_video_list(output_file="video_list.json"):
url = "https://www.pornhub.com/video?o=mr" # 根据时间排序(最近一年)
#url = "https://www.pornhub.com/video?o=mr" # 根据时间排序(最近一年)
url = "https://www.pornhub.com/video?o=cm" # 最近
# 爬取视频列表
with YoutubeDL(ydl_opts) as ydl:

30
scripts/pornhub/sort.py Normal file
View File

@ -0,0 +1,30 @@
import json
import argparse
# 排序 JSON 文件
def sort_json_file(input_file, output_file, sort_key):
with open(input_file, 'r', encoding='utf-8') as f:
# 读取所有行并解析为 JSON
json_list = [json.loads(line.strip()) for line in f if line.strip()]
# 按指定键排序,从大到小
sorted_list = sorted(json_list, key=lambda x: int(x.get(sort_key, 0)), reverse=True)
# 写入排序后的结果到输出文件
with open(output_file, 'w', encoding='utf-8') as f:
for entry in sorted_list:
f.write(json.dumps(entry, ensure_ascii=False) + '\n')
print(f"排序完成!结果已保存到 {output_file}")
# 主函数
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="对 JSON 文件进行排序")
parser.add_argument("input_file", help="输入的 JSON 文件,每行一个 JSON 对象")
parser.add_argument("output_file", help="输出的排序结果文件")
parser.add_argument("sort_key", help="排序的键,比如 upload_date, view_count 等")
args = parser.parse_args()
sort_json_file(args.input_file, args.output_file, args.sort_key)