This repository has been archived on 2026-01-07. You can view files and clone it, but cannot push or open issues or pull requests.
Files
resources/pornhub/test.py
2025-03-17 11:30:35 +08:00

35 lines
1.0 KiB
Python

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', '未找到')}")