|
@@ -6,34 +6,35 @@ using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
-using WechatBakTool.Interface;
|
|
|
|
using WechatBakTool.Model;
|
|
using WechatBakTool.Model;
|
|
using System.Xml;
|
|
using System.Xml;
|
|
|
|
|
|
-namespace WechatBakTool
|
|
+namespace WechatBakTool.Export
|
|
{
|
|
{
|
|
public class HtmlExport : IExport
|
|
public class HtmlExport : IExport
|
|
{
|
|
{
|
|
private string HtmlBody = "";
|
|
private string HtmlBody = "";
|
|
private WXSession? Session = null;
|
|
private WXSession? Session = null;
|
|
|
|
+ private string Path = "";
|
|
public void InitTemplate(WXSession session)
|
|
public void InitTemplate(WXSession session)
|
|
{
|
|
{
|
|
Session = session;
|
|
Session = session;
|
|
- HtmlBody = "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>溯雪微信聊天记录备份工具</title><style>p{margin:0px;}.msg{padding-bottom:10px;}.nickname{font-size:10px;}.content{font-size:14px;}</style></head><body>";
|
|
+ HtmlBody = "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>WechatBakTool</title><style>p{margin:0px;}.msg{padding-bottom:10px;}.nickname{font-size:10px;}.content{font-size:14px;}</style></head><body>";
|
|
|
|
|
|
HtmlBody += string.Format("<div class=\"msg\"><p class=\"nickname\"><b>与 {0}({1}) 的聊天记录</b></p>", Session.NickName, Session.UserName);
|
|
HtmlBody += string.Format("<div class=\"msg\"><p class=\"nickname\"><b>与 {0}({1}) 的聊天记录</b></p>", Session.NickName, Session.UserName);
|
|
HtmlBody += string.Format("<div class=\"msg\"><p class=\"nickname\"><b>导出时间:{0}</b></p><hr/>", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
HtmlBody += string.Format("<div class=\"msg\"><p class=\"nickname\"><b>导出时间:{0}</b></p><hr/>", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
}
|
|
}
|
|
|
|
|
|
- public void InitTemplate(WXContact contact)
|
|
+ public void InitTemplate(WXContact contact, string p)
|
|
{
|
|
{
|
|
|
|
+ Path = p;
|
|
WXSession session = new WXSession();
|
|
WXSession session = new WXSession();
|
|
session.NickName = contact.NickName;
|
|
session.NickName = contact.NickName;
|
|
session.UserName = contact.UserName;
|
|
session.UserName = contact.UserName;
|
|
InitTemplate(session);
|
|
InitTemplate(session);
|
|
}
|
|
}
|
|
|
|
|
|
- public void Save(string path = "",bool append = false)
|
|
+ public void Save(string path = "", bool append = false)
|
|
{
|
|
{
|
|
if (!append)
|
|
if (!append)
|
|
{
|
|
{
|
|
@@ -51,7 +52,7 @@ namespace WechatBakTool
|
|
HtmlBody += "</body></html>";
|
|
HtmlBody += "</body></html>";
|
|
}
|
|
}
|
|
|
|
|
|
- public void SetMsg(WXUserReader reader,WXContact contact)
|
|
+ public void SetMsg(WXUserReader reader, WXContact contact)
|
|
{
|
|
{
|
|
if (Session == null)
|
|
if (Session == null)
|
|
throw new Exception("请初始化模版:Not Use InitTemplate");
|
|
throw new Exception("请初始化模版:Not Use InitTemplate");
|
|
@@ -88,13 +89,13 @@ namespace WechatBakTool
|
|
}
|
|
}
|
|
HtmlBody += string.Format("<p class=\"content\"><video controls style=\"max-height:300px;max-width:300px;\"><source src=\"{0}\" type=\"video/mp4\" /></video></p></div>", path);
|
|
HtmlBody += string.Format("<p class=\"content\"><video controls style=\"max-height:300px;max-width:300px;\"><source src=\"{0}\" type=\"video/mp4\" /></video></p></div>", path);
|
|
}
|
|
}
|
|
- else if(msg.Type== 49)
|
|
+ else if (msg.Type == 49)
|
|
{
|
|
{
|
|
using (var decoder = LZ4Decoder.Create(true, 64))
|
|
using (var decoder = LZ4Decoder.Create(true, 64))
|
|
{
|
|
{
|
|
byte[] target = new byte[10240];
|
|
byte[] target = new byte[10240];
|
|
int res = 0;
|
|
int res = 0;
|
|
- if(msg.CompressContent != null)
|
|
+ if (msg.CompressContent != null)
|
|
res = LZ4Codec.Decode(msg.CompressContent, 0, msg.CompressContent.Length, target, 0, target.Length);
|
|
res = LZ4Codec.Decode(msg.CompressContent, 0, msg.CompressContent.Length, target, 0, target.Length);
|
|
|
|
|
|
byte[] data = target.Skip(0).Take(res).ToArray();
|
|
byte[] data = target.Skip(0).Take(res).ToArray();
|
|
@@ -104,15 +105,15 @@ namespace WechatBakTool
|
|
xml = xml.Replace("\n", "");
|
|
xml = xml.Replace("\n", "");
|
|
XmlDocument xmlObj = new XmlDocument();
|
|
XmlDocument xmlObj = new XmlDocument();
|
|
xmlObj.LoadXml(xml);
|
|
xmlObj.LoadXml(xml);
|
|
- if(xmlObj.DocumentElement != null)
|
|
+ if (xmlObj.DocumentElement != null)
|
|
{
|
|
{
|
|
string title = "";
|
|
string title = "";
|
|
string appName = "";
|
|
string appName = "";
|
|
string url = "";
|
|
string url = "";
|
|
XmlNodeList? findNode = xmlObj.DocumentElement.SelectNodes("/msg/appmsg/title");
|
|
XmlNodeList? findNode = xmlObj.DocumentElement.SelectNodes("/msg/appmsg/title");
|
|
- if(findNode != null)
|
|
+ if (findNode != null)
|
|
{
|
|
{
|
|
- if(findNode.Count > 0)
|
|
+ if (findNode.Count > 0)
|
|
{
|
|
{
|
|
title = findNode[0]!.InnerText;
|
|
title = findNode[0]!.InnerText;
|
|
}
|
|
}
|
|
@@ -137,7 +138,6 @@ namespace WechatBakTool
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (msg.Type == 34)
|
|
else if (msg.Type == 34)
|