a
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
发布适配器模块
|
||||
封装IT资讯项目的共享发布功能
|
||||
"""
|
||||
|
||||
from shared_utils import get_xiaohongshu_publisher
|
||||
from typing import List, Optional
|
||||
|
||||
class XHSPublisherAdapter:
|
||||
"""小红书发布适配器"""
|
||||
|
||||
def __init__(self):
|
||||
self.PublisherClass = get_xiaohongshu_publisher()
|
||||
self.publisher = None
|
||||
|
||||
def publish(self,
|
||||
title: str,
|
||||
content: str,
|
||||
tags: List[str],
|
||||
style: str = "tech") -> bool:
|
||||
"""
|
||||
发布笔记到小红书
|
||||
|
||||
Args:
|
||||
title: 笔记标题
|
||||
content: 笔记正文
|
||||
tags: 话题标签列表
|
||||
style: 图片风格 (tech/warm/business)
|
||||
|
||||
Returns:
|
||||
是否发布成功
|
||||
"""
|
||||
try:
|
||||
# 初始化发布器
|
||||
if not self.publisher:
|
||||
self.publisher = self.PublisherClass()
|
||||
|
||||
# 调用共享发布模块
|
||||
success = self.publisher.publish_to_xiaohongshu(
|
||||
title=title,
|
||||
content=content,
|
||||
tags=tags,
|
||||
style=style
|
||||
)
|
||||
|
||||
return success
|
||||
|
||||
except Exception as e:
|
||||
print(f"发布失败: {e}")
|
||||
return False
|
||||
|
||||
def get_last_note_id(self) -> Optional[str]:
|
||||
"""获取最新发布的笔记ID"""
|
||||
try:
|
||||
# 从日志或返回信息中获取
|
||||
# 这里简化处理
|
||||
return None
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 测试
|
||||
adapter = XHSPublisherAdapter()
|
||||
print("发布适配器初始化成功")
|
||||
Reference in New Issue
Block a user