add some scripts.

This commit is contained in:
2024-11-22 14:18:08 +08:00
parent a261a9e7ed
commit ba31911477
5 changed files with 387 additions and 0 deletions

35
scripts/pornhub/test.py Normal file
View File

@ -0,0 +1,35 @@
from yt_dlp import YoutubeDL
from custom_pornhub import CustomPornHubIE
import logging
# 配置日志记录
logger = logging.getLogger('yt_dlp')
logger.setLevel(logging.DEBUG) # 设置为 DEBUG 级别
handler = logging.StreamHandler() # 输出到终端
logger.addHandler(handler)
# 自定义选项
ydl_opts = {
'extract_flat': True, # 仅提取元数据
'skip_download': True, # 跳过视频下载
'verbose': True, # 启用详细日志
'logger': logger, # 使用自定义日志记录器
}
with YoutubeDL(ydl_opts) as ydl:
# 添加自定义提取器
ydl.add_info_extractor(CustomPornHubIE())
# 打印已注册的提取器列表
print("调试: 已注册的提取器列表:")
for ie_name in ydl._ies:
print(ie_name)
# 提取视频信息
info = ydl.extract_info("https://www.pornhub.com/view_video.php?viewkey=6710f3bc00200")
# 输出信息
print(info)
# 输出收藏次数
print(f"收藏次数: {info.get('favorites_count', '未找到')}")