public int GetMovieInfo(string sn) { try { url = javBusUrl + "search/" + sn + "&type=1"; var htmltext = web.Load(url); if (htmltext.Text.Contains("沒有您要的結果!")) { OutLog?.Invoke("未找到影片。"); return(-1); } htmlNode = HtmlNode.CreateNode(htmltext.Text); var urls = htmlNode.SelectNodes("//div[@id='waterfall']/div[@id='waterfall']/div"); for (int i = 1; i < urls.Count + 1; i++) { string number_get = htmlNode.SelectNodes("//div[@id='waterfall']/div[@id='waterfall']/div[" + i.ToString() + "]/a[@class='movie-box']/div[@class='photo-info']/span/date[1]/text()")[0].InnerText; number_get = number_get.Replace("-", string.Empty).ToUpper(); if (number_get.Equals(sn)) { url = htmlNode.SelectNodes("//div[@id='waterfall']/div[@id='waterfall']/div[" + i.ToString() + "]/a[@class='movie-box']/@href")[0].Attributes["href"].Value; htmlNode = HtmlNode.CreateNode(web.Load(url).Text); website = url; OutLog?.Invoke("获取影片页面成功,开始进行下一步。"); return(0); } } OutLog?.Invoke("未找到影片。"); return(-1); } catch (Exception ex) { OutLog?.Invoke("获取影片页面异常,异常原因:" + ex.ToString()); return(-1); } }
/// <summary> /// 输出日志 /// </summary> /// <param name="msg"></param> void outLog(string msg) { Console.WriteLine("log@" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":->" + msg); Debug.WriteLine("log@" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":->" + msg); OutLog?.Invoke("log@" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + msg); }
private void CollationFilePath(string key) { key = key.ToUpper(); if (key.IndexOf("-C") != -1) { isChinese = true; } Regex regex = new Regex("\\[.*?\\]"); string pContent = regex.Match(key).Value; if (pContent.Length > 0) { key = key.Replace(pContent, string.Empty); } regex = new Regex("^[0-9]{3,4}"); pContent = regex.Match(key).Value; if (pContent.Length > 0) { key = key.Replace(pContent, string.Empty); } key = key.Trim(); //key = key.Replace("_", string.Empty); key = key.Replace(".HD", string.Empty); key = key.Replace(".1080p", string.Empty); key = key.Replace("-C", string.Empty); key = key.Replace("h264", string.Empty); key = key.Replace("-", string.Empty); key = key.Replace("FHD", string.Empty); key = key.Replace("HHB", string.Empty); ext = key.Split('.')[1]; VideoNumber = key.Split('.')[0]; OutLog?.Invoke("规范文件名,key =" + key + ", videoNumber =" + VideoNumber + ", ext =" + ext); }
public int StartGetInfo(string fullName, string name) { isChinese = false; FilePath = fullName; CollationFilePath(name); int ret = javbus.GetMovieInfo(VideoNumber); if (ret == 0) { movieInfo.title = javbus.GetTitle(); movieInfo.studio = javbus.GetStudio(); movieInfo.publisher = javbus.GetPublisher(); movieInfo.coverUrl = javbus.GetCover(); movieInfo.release = javbus.GetRelease(); movieInfo.runtime = javbus.GetRuntime(); movieInfo.director = javbus.GetDirector(); movieInfo.series = javbus.GetSeries(); movieInfo.tag = javbus.GetTag(); if (isChinese) { OutLog?.Invoke("添加中文字幕tag"); movieInfo.tag.Add("中文字幕"); } movieInfo.actor = javbus.GetActor(); movieInfo.number = javbus.GetNumber(); movieInfo.actorPic = javbus.GetActorPhoto(); movieInfo.website = javbus.Getwebsite(); OutLog?.Invoke("写入xml文件"); WriteXmlInfo(); string tempPath = destFilePath + "\\thumb.jpg"; OutLog?.Invoke("开始下载图片"); if (Downloadimg(movieInfo.coverUrl, tempPath) == 0) { OutLog?.Invoke("图片下载成功"); string imgPath = destFilePath + "\\" + movieInfo.actor[0] + "\\" + movieInfo.number + "\\" + movieInfo.number + "-thumb.jpg"; string poster = destFilePath + "\\" + movieInfo.actor[0] + "\\" + movieInfo.number + "\\" + movieInfo.number + "-poster.jpg"; string fanart = destFilePath + "\\" + movieInfo.actor[0] + "\\" + movieInfo.number + "\\" + movieInfo.number + "-fanart.jpg"; File.Copy(tempPath, fanart); if (isChinese) { ImageHelper.AddImageSignPic(tempPath, imgPath, System.Environment.CurrentDirectory + @"\img\sub.png", 1, 100, 10); ImageHelper.CropPosterImg(tempPath, poster); ImageHelper.AddImageSignPic(poster, poster, System.Environment.CurrentDirectory + @"\img\sub.png", 1, 100, 10); } else { File.Copy(tempPath, imgPath); ImageHelper.CropPosterImg(tempPath, poster); } File.Delete(tempPath); } OutLog?.Invoke("移动文件:" + FilePath + "\nTO:" + destFilePath + "\\" + movieInfo.actor[0] + "\\" + movieInfo.number + "\\" + movieInfo.number + "." + ext); File.Move(FilePath, destFilePath + "\\" + movieInfo.actor[0] + "\\" + movieInfo.number + "\\" + movieInfo.number + "." + ext); OutLog?.Invoke("移动文件结束," + movieInfo.number + "刮削结束"); } return(ret); }
public static string outLogApi(string pKey, string ApiData, string note, int noteColor, int backColor) { string ret = string.Empty; int Log = int.Parse(JObject.Parse(ApiData).SelectToken("输出日志").ToString()); IntPtr intPtr = new IntPtr(Log); OutLog outLog = (OutLog)Marshal.GetDelegateForFunctionPointer(intPtr, typeof(OutLog)); outLog.Invoke(pKey, Marshal.StringToCoTaskMemAnsi(note), noteColor, backColor); return(ret); }
/// <summary> /// 输出日志 /// </summary> /// <param name="msg"></param> void outLog(string msg) { OutLog?.Invoke((lg.uin > 0 ? lg.uin.Value : lg.logon_id) + "->" + msg); Debug.WriteLine((lg.uin > 0 ? lg.uin.Value : lg.logon_id) + "->" + msg); }
private void Javbus_OutLog(string log) { OutLog?.Invoke(log); }