private void DownloadFile(MomentInfo momentInfo) { string guid; string localFileName; if (momentInfo.momentImgs != null) { momentInfo.momentImgsLocal = new List <string>(); foreach (Uri img in momentInfo.momentImgs) { guid = Guid.NewGuid().ToString(); localFileName = $"LocalFile\\{guid}.jpg"; LogUtil.Log($"下载{img}"); webClient.DownloadFile(img, localFileName); momentInfo.momentImgsLocal.Add(localFileName); } } if (momentInfo.shortVideoUrl != null) { guid = Guid.NewGuid().ToString(); localFileName = $"LocalFile\\{guid}.mp4"; LogUtil.Log($"下载{momentInfo.shortVideoUrl}"); webClient.DownloadFile(momentInfo.shortVideoUrl, localFileName); momentInfo.shortVideoUrlLocal = localFileName; } if (momentInfo.sharedItem != null) { guid = Guid.NewGuid().ToString(); localFileName = $"LocalFile\\{guid}.mp4"; LogUtil.Log($"下载{momentInfo.sharedItem.sharedUrl}"); webClient.DownloadFile(momentInfo.sharedItem.sharedUrl, localFileName); momentInfo.sharedItem.sharedFileLocal = localFileName; } }
public void Start() { MomentDBUtil.LoadMomentSQLite(userHash); DirectoryInfo directoryInfo = new DirectoryInfo("Plist"); foreach (FileInfo momentPlistFile in directoryInfo.GetFiles()) { NSObject plist = PropertyListParser.Parse(momentPlistFile); MomentSerializer serializer = new MomentSerializer((NSDictionary)plist); MomentInfo momentInfo = serializer.SerializMoment(); if (momentInfo != null && ( !(skipSharedItem && momentInfo.momentType == Enum.MomentType.Shared) || (momentInfo.sharedItem != null && momentInfo.sharedItem.sharedFrom == "微视")) ) { LogUtil.Log($"解析{momentInfo.momentId}"); DownloadFile(momentInfo); bigOne.Add(momentInfo); string momentJson = JsonConvert.SerializeObject(momentInfo); File.WriteAllText($"Json\\{momentInfo.momentId}.json", momentJson, Encoding.UTF8); } } string bigOneJson = JsonConvert.SerializeObject(bigOne); bigOneJson = "var moment_data = " + bigOneJson; File.WriteAllText($"View\\static\\script\\data.js", bigOneJson, Encoding.UTF8); }
public MomentSerializer(NSDictionary plist) { this.momentPlist = plist; momentInfo = new MomentInfo(); }