public override async Task <HttpResult> Crawl() { //从网络获取 MovieCode = await GetMovieCode((error) => { httpResult = new HttpResult() { Error = error, Success = false }; }); if (MovieCode.Length > 1) { InitHeaders(); Url = JvedioServers.Jav321.Url + MovieCode.Substring(1); httpResult = await new MyNet().Http(Url, headers); if (httpResult != null && httpResult.StatusCode == HttpStatusCode.OK && httpResult.SourceCode != null) { FileProcess.SaveInfo(GetInfo(), ID); httpResult.Success = true; ParseCookies(httpResult.Headers.SetCookie); } } return(httpResult); }
public void AddPath(object sender, MouseButtonEventArgs e) { System.Windows.Forms.FolderBrowserDialog folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog(); folderBrowserDialog.Description = Jvedio.Language.Resources.ChooseDir; folderBrowserDialog.ShowNewFolderButton = true; if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK & !string.IsNullOrWhiteSpace(folderBrowserDialog.SelectedPath)) { if (vieModel_Settings.ScanPath == null) { vieModel_Settings.ScanPath = new ObservableCollection<string>(); } if (!vieModel_Settings.ScanPath.Contains(folderBrowserDialog.SelectedPath) && !vieModel_Settings.ScanPath.IsIntersectWith(folderBrowserDialog.SelectedPath)) { vieModel_Settings.ScanPath.Add(folderBrowserDialog.SelectedPath); //保存 FileProcess.SaveScanPathToConfig(vieModel_Settings.DataBase, vieModel_Settings.ScanPath?.ToList()); } else { HandyControl.Controls.Growl.Error(Jvedio.Language.Resources.FilePathIntersection, "SettingsGrowl"); } } }
public static void SaveImage(string ID, byte[] ImageByte, ImageType imageType, string Url) { string FilePath; string ImageDir; if (imageType == ImageType.BigImage) { ImageDir = BasePicPath + $"BigPic\\"; FilePath = ImageDir + $"{ID}.jpg"; } else if (imageType == ImageType.ExtraImage) { ImageDir = BasePicPath + $"ExtraPic\\{ID}\\"; FilePath = ImageDir + Path.GetFileName(new Uri(Url).LocalPath); } else if (imageType == ImageType.SmallImage) { ImageDir = BasePicPath + $"SmallPic\\"; FilePath = ImageDir + $"{ID}.jpg"; } else { ImageDir = BasePicPath + $"Actresses\\"; FilePath = ImageDir + $"{ID}.jpg"; } if (!Directory.Exists(ImageDir)) { Directory.CreateDirectory(ImageDir); } FileProcess.ByteArrayToFile(ImageByte, FilePath); }
public override async Task <HttpResult> Crawl() { if (Url.IsProperUrl()) { InitHeaders(); } httpResult = await new MyNet().Http(Url, headers); if (httpResult != null && httpResult.StatusCode == HttpStatusCode.OK && httpResult.SourceCode != null) { if (httpResult.SourceCode.IndexOf("非常抱歉,此商品未在您的居住国家公开") < 0 && httpResult.SourceCode.IndexOf("非常抱歉,找不到您要的商品") < 0) { FileProcess.SaveInfo(GetInfo(), ID); httpResult.Success = true; } else if (httpResult.SourceCode.IndexOf("非常抱歉,此商品未在您的居住国家公开") > 0) { httpResult.StatusCode = HttpStatusCode.Forbidden; httpResult.Success = false; } else if (httpResult.SourceCode.IndexOf("非常抱歉,找不到您要的商品") > 0) { httpResult.StatusCode = HttpStatusCode.NotFound; httpResult.Success = false; } ParseCookies(httpResult.Headers.SetCookie); } return(httpResult); }
public override async Task <HttpResult> Crawl() { MovieCode = await GetMovieCode(); if (MovieCode != "") { //解析 Url = MovieCode; httpResult = await Net.Http(Url, headers); if (httpResult != null && httpResult.StatusCode == HttpStatusCode.OK && httpResult.SourceCode != null) { if (!this.OnlyPlot) { FileProcess.SaveInfo(GetInfo(), ID); } else { FileProcess.SavePartialInfo(GetInfo(), "plot", ID); } httpResult.Success = true; } } return(httpResult); }
public static string GenerateSign(string query, string appid, string pwd, string salt) { //http://api.fanyi.baidu.com/doc/21 //appid+q+salt+密钥 string r = appid + query + salt + pwd; return(FileProcess.CalculateMD5Hash(r)); }
private async void OpenUpdate(object sender, RoutedEventArgs e) { if (new Msgbox(this, Jvedio.Language.Resources.IsToUpdate).ShowDialog() == true) { try { //检查升级程序是否是最新的 bool IsToDownLoadUpdate = false; HttpResult httpResult = await Net.Http(Net.UpdateExeVersionUrl); if (httpResult != null && httpResult.SourceCode != "") { //跟本地的 md5 对比 if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "JvedioUpdate.exe")) { IsToDownLoadUpdate = true; } else { string md5 = FileProcess.GetFileMD5(AppDomain.CurrentDomain.BaseDirectory + "JvedioUpdate.exe"); if (md5 != httpResult.SourceCode) { IsToDownLoadUpdate = true; } } } if (IsToDownLoadUpdate) { HttpResult streamResult = await Net.DownLoadFile(Net.UpdateExeUrl); try { using (var fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "JvedioUpdate.exe", FileMode.Create, FileAccess.Write)) { fs.Write(streamResult.FileByte, 0, streamResult.FileByte.Length); } } catch { } } try { Process.Start(AppDomain.CurrentDomain.BaseDirectory + "JvedioUpdate.exe"); } catch (Exception ex) { HandyControl.Controls.Growl.Error(ex.Message, "Main"); } //IsToUpdate = true; Application.Current.Shutdown();//直接关闭 } catch { MessageBox.Show($"{Jvedio.Language.Resources.CannotOpen} JvedioUpdate.exe"); } } }
public static double InsertWithNfo(List <string> filepaths, CancellationToken ct, Action <string> messageCallBack = null, bool IsEurope = false) { List <string> nfopaths = new List <string>(); List <string> vediopaths = new List <string>(); foreach (var item in filepaths) { if (item.ToLower().EndsWith(".nfo")) { nfopaths.Add(item); } else { vediopaths.Add(item); } } //先导入 nfo 再导入视频,避免路径覆盖 if (nfopaths.Count > 0 && Properties.Settings.Default.ScanNfo) { Logger.LogScanInfo(Environment.NewLine + "-----【" + DateTime.Now.ToString() + "】-----"); Logger.LogScanInfo(Environment.NewLine + $"{Jvedio.Language.Resources.ScanNFO} => {nfopaths.Count} " + Environment.NewLine); double total = 0; //导入 nfo 文件 nfopaths.ForEach(item => { if (File.Exists(item)) { Movie movie = FileProcess.GetInfoFromNfo(item); if (movie != null && !string.IsNullOrEmpty(movie.id)) { DataBase.InsertFullMovie(movie); total += 1; Logger.LogScanInfo(Environment.NewLine + $"{Jvedio.Language.Resources.SuccessImportToDataBase} => {item} "); } } }); Logger.LogScanInfo(Environment.NewLine + $"{Jvedio.Language.Resources.ImportNFONumber}: {total}" + Environment.NewLine); messageCallBack?.Invoke($"{Jvedio.Language.Resources.ImportNFONumber}: {total}"); } //导入视频 if (vediopaths.Count > 0) { double _num = Scan.DistinctMovieAndInsert(vediopaths, ct, IsEurope); messageCallBack?.Invoke($"{Jvedio.Language.Resources.ImportVideioNumber}:{_num},详情请看日志"); return(_num); } return(0); }
public static void SaveInfo(Dictionary <string, string> Info, string id) { //保存信息 if (!Info.ContainsKey("id")) { Info.Add("id", id); } DataBase.UpdateInfoFromNet(Info); DetailMovie detailMovie = DataBase.SelectDetailMovieById(id); FileProcess.SaveNfo(detailMovie); }
public override async Task <HttpResult> Crawl() { httpResult = await Net.Http(Url, headers); if (httpResult != null && httpResult.StatusCode == HttpStatusCode.OK && httpResult.SourceCode != null) { FileProcess.SaveInfo(GetInfo(), ID); httpResult.Success = true; ParseCookies(httpResult.Headers.SetCookie); } return(httpResult); }
private async void OpenUpdate(object sender, RoutedEventArgs e) { if (new Msgbox(this, Jvedio.Language.Resources.IsToUpdate).ShowDialog() == true) { try { //检查升级程序是否是最新的 string content = ""; int statusCode; bool IsToDownLoadUpdate = false; try { (content, statusCode) = await Net.Http(Net.UpdateExeVersionUrl, Proxy : null); } catch (TimeoutException ex) { Logger.LogN($"URL={Net.UpdateUrl},Message-{ex.Message}"); } if (content != "") { //跟本地的 md5 对比 if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "JvedioUpdate.exe")) { IsToDownLoadUpdate = true; } else { string md5 = FileProcess.GetFileMD5(AppDomain.CurrentDomain.BaseDirectory + "JvedioUpdate.exe"); if (md5 != content) { IsToDownLoadUpdate = true; } } } if (IsToDownLoadUpdate) { (byte[] filebyte, string cookie, int statuscode) = Net.DownLoadFile(Net.UpdateExeUrl); try { using (var fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "JvedioUpdate.exe", FileMode.Create, FileAccess.Write)) { fs.Write(filebyte, 0, filebyte.Length); } } catch { } } try { Process.Start(AppDomain.CurrentDomain.BaseDirectory + "JvedioUpdate.exe"); } catch (Exception ex) { HandyControl.Controls.Growl.Error(ex.Message, "Main"); } //IsToUpdate = true; Application.Current.Shutdown();//直接关闭 } catch { MessageBox.Show($"{Jvedio.Language.Resources.CannotOpen} JvedioUpdate.exe"); } } }
public static bool IsEnglishExistBefore(string str1, string str2) { int index = str1.ToUpper().IndexOf(str2.ToUpper()); if (index <= 0) { return(false); } else { return(FileProcess.IsLetter(str1[index - 1])); } }
private void Button_Click(object sender, RoutedEventArgs e) { WindowTools windowTools = (WindowTools)FileProcess.GetWindowByName("WindowTools"); if (windowTools == null) { windowTools = new WindowTools(); } windowTools.Show(); windowTools.Activate(); windowTools.TabControl.SelectedIndex = 0; this.Close(); }
public override async Task <HttpResult> Crawl() { MovieCode = await GetMovieCode(); if (MovieCode != "") { //解析 Url = JvedioServers.Library.Url + $"?v={MovieCode}"; httpResult = await new MyNet().Http(Url, headers); if (httpResult != null && httpResult.StatusCode == HttpStatusCode.OK && httpResult.SourceCode != null) { FileProcess.SaveInfo(GetInfo(), ID); httpResult.Success = true; ParseCookies(httpResult.Headers.SetCookie); } } return(httpResult); }
public override async Task <HttpResult> Crawl() { MovieCode = await GetMovieCode((error) => { httpResult = new HttpResult() { Error = error, Success = false }; }); if (MovieCode != "") { Url = JvedioServers.MOO.Url + $"movie/{MovieCode}"; httpResult = await new MyNet().Http(Url, headers); if (httpResult != null && httpResult.StatusCode == HttpStatusCode.OK && httpResult.SourceCode != null) { FileProcess.SaveInfo(GetInfo(), ID); httpResult.Success = true; } } return(httpResult); }
public override async Task <HttpResult> Crawl() { Movie movie = DataBase.SelectMovieByID(ID); if (!string.IsNullOrEmpty(movie.sourceurl) && movie.sourceurl.IsProperUrl()) { //如果有原网址,则不用搜索了 MovieCode = movie.sourceurl.Split('/').Last(); } else { MovieCode = await GetMovieCode((error) => { httpResult = new HttpResult() { Error = error, Success = false }; }); } if (MovieCode != "") { Url = JvedioServers.DB.Url + $"v/{MovieCode}"; httpResult = await Net.Http(Url, headers); if (httpResult != null && httpResult.StatusCode == HttpStatusCode.OK && httpResult.SourceCode != null) { FileProcess.SaveInfo(GetInfo(), ID); httpResult.Success = true; //保存磁力 List <Magnet> magnets = new JavDBParse(ID, httpResult.SourceCode, MovieCode).ParseMagnet(); if (magnets.Count > 0) { DataBase.SaveMagnets(magnets); } } } return(httpResult); }
public override async Task <HttpResult> Crawl() { if (Url.IsProperUrl()) { InitHeaders(); } httpResult = await new MyNet().Http(Url, headers); if (httpResult != null && httpResult.StatusCode == HttpStatusCode.OK && httpResult.SourceCode != null) { FileProcess.SaveInfo(GetInfo(), ID, (int)VedioType); httpResult.Success = true; ParseCookies(httpResult.Headers.SetCookie); Movie movie = DataBase.SelectMovieByID(ID); //保存磁力 List <Magnet> magnets = await new BusParse(ID, httpResult.SourceCode, VedioType).ParseMagnet(movie.bigimageurl); if (magnets.Count > 0) { DataBase.SaveMagnets(magnets); } } return(httpResult); }
public void AddPath(object sender, RoutedEventArgs e) { var path = FileHelper.SelectPath(this); if (Directory.Exists(path)) { if (vieModel_Settings.ScanPath == null) { vieModel_Settings.ScanPath = new ObservableCollection <string>(); } if (!vieModel_Settings.ScanPath.Contains(path) && !vieModel_Settings.ScanPath.IsIntersectWith(path)) { vieModel_Settings.ScanPath.Add(path); //保存 FileProcess.SaveScanPathToConfig(vieModel_Settings.DataBase, vieModel_Settings.ScanPath?.ToList()); } else { HandyControl.Controls.Growl.Error(Jvedio.Language.Resources.FilePathIntersection, GrowlToken); } } }
private void PathListBox_Drop(object sender, DragEventArgs e) { if (vieModel_Settings.ScanPath == null) { vieModel_Settings.ScanPath = new ObservableCollection<string>(); } string[] dragdropFiles = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (var item in dragdropFiles) { if (!IsFile(item)) { if (!vieModel_Settings.ScanPath.Contains(item) && !vieModel_Settings.ScanPath.IsIntersectWith(item)) { vieModel_Settings.ScanPath.Add(item); } else { HandyControl.Controls.Growl.Error(Jvedio.Language.Resources.FilePathIntersection, "SettingsGrowl"); } } } //保存 FileProcess.SaveScanPathToConfig(vieModel_Settings.DataBase, vieModel_Settings.ScanPath.ToList()); }
public static bool IsCHS(string filepath) { if (string.IsNullOrEmpty(filepath)) { return(false); } string name = Path.GetFileNameWithoutExtension(filepath).ToLower(); //-c后面没有英文 if (name.IndexOf("-c") > 0 || name.IndexOf("_c") > 0) { int idx = name.LastIndexOf("-c"); if (idx > 0 && idx == name.Length - 2) { return(true); } else if (idx > 0 && idx < name.Length - 2 && !FileProcess.IsLetter(name[idx + 2])) { return(true); } idx = name.LastIndexOf("_c"); if (idx > 0 && idx == name.Length - 2) { return(true); } else if (idx > 0 && idx < name.Length - 2 && !FileProcess.IsLetter(name[idx + 2])) { return(true); } return(CHS.Any(arg => name.IndexOf(arg) >= 0)); } else { return(CHS.Any(arg => name.IndexOf(arg) >= 0)); } }
public override async Task <HttpResult> Crawl() { httpResult = await Net.Http(Url, headers); if (httpResult != null && httpResult.StatusCode == HttpStatusCode.OK && httpResult.SourceCode != null) { if (httpResult.SourceCode.IndexOf("非常抱歉,此商品未在您的居住国家公开") < 0 && httpResult.SourceCode.IndexOf("非常抱歉,找不到您要的商品") < 0) { FileProcess.SaveInfo(GetInfo(), ID); httpResult.Success = true; } else if (httpResult.SourceCode.IndexOf("非常抱歉,此商品未在您的居住国家公开") > 0) { httpResult.StatusCode = HttpStatusCode.Forbidden; httpResult.Success = false; } else if (httpResult.SourceCode.IndexOf("非常抱歉,找不到您要的商品") > 0) { httpResult.StatusCode = HttpStatusCode.NotFound; httpResult.Success = false; } } return(httpResult); }
private async void Button_Click_2(object sender, RoutedEventArgs e) { Button button = (Button)sender; button.IsEnabled = false; cts = new CancellationTokenSource(); cts.Token.Register(() => { HandyControl.Controls.Growl.Info(Jvedio.Language.Resources.Cancel, GrowlToken); }); ct = cts.Token; //数据库管理 var cb = CheckBoxWrapPanel.Children.OfType <CheckBox>().ToList(); string path = $"DataBase\\{vieModel_DBManagement.CurrentDataBase}"; MySqlite db = new MySqlite(path); if ((bool)cb[0].IsChecked) { //重置信息 db.DeleteTable("movie"); db.CreateTable(DataBase.SQLITETABLE_MOVIE); //清空最近播放和最近创建 ClearDateBefore(DateTime.Now); db.Vacuum(); HandyControl.Controls.Growl.Success(Jvedio.Language.Resources.Message_Success, GrowlToken); } if ((bool)cb[1].IsChecked) { //删除不存在影片 long num = 0; await Task.Run(() => { var movies = db.SelectMoviesBySql("select * from movie"); try { vieModel_DBManagement.ProgressBarValue = 0; for (int i = 0; i < movies.Count; i++) { ct.ThrowIfCancellationRequested(); if (!File.Exists(movies[i].filepath)) { db.DeleteByField("movie", "id", movies[i].id); num++; } if (movies.Count > 0) { vieModel_DBManagement.ProgressBarValue = (int)((double)(i + 1) / (double)movies.Count * 100); } } db.Vacuum(); } catch (OperationCanceledException ex) { Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {ex.Message}"); } }, ct); HandyControl.Controls.Growl.Success($"{ Jvedio.Language.Resources.SuccessDelete} {num}", GrowlToken); } if ((bool)cb[2].IsChecked) { var movies = db.SelectMoviesBySql("select * from movie"); StringCollection ScanPath = ReadScanPathFromConfig(vieModel_DBManagement.CurrentDataBase); long num = 0; await Task.Run(() => { try { vieModel_DBManagement.ProgressBarValue = 0; for (int i = 0; i < movies.Count; i++) { ct.ThrowIfCancellationRequested(); if (!IsPathIn(movies[i].filepath, ScanPath)) { db.DeleteByField("movie", "id", movies[i].id); num++; } if (movies.Count > 0) { vieModel_DBManagement.ProgressBarValue = (int)((double)(i + 1) / (double)movies.Count * 100); } } db.Vacuum(); } catch (OperationCanceledException ex) { Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {ex.Message}"); } }, ct); HandyControl.Controls.Growl.Success($"{Jvedio.Language.Resources.SuccessDelete} {num}", GrowlToken); } if ((bool)cb[3].IsChecked) { if (Properties.Settings.Default.SaveInfoToNFO) { var detailMovies = db.SelectDetailMoviesBySql("select * from movie"); await Task.Run(() => { try { vieModel_DBManagement.ProgressBarValue = 0; for (int i = 0; i < detailMovies.Count; i++) { ct.ThrowIfCancellationRequested(); FileProcess.SaveNfo(detailMovies[i]); if (detailMovies.Count > 0) { vieModel_DBManagement.ProgressBarValue = (int)((double)(i + 1) / (double)detailMovies.Count * 100); } } } catch (OperationCanceledException ex) { Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {ex.Message}"); } }, ct); HandyControl.Controls.Growl.Success($"{Jvedio.Language.Resources.Message_Success}", GrowlToken); } else { HandyControl.Controls.Growl.Success($"{Jvedio.Language.Resources.setnfo}", GrowlToken); } } db.CloseDB(); cts.Dispose(); await Task.Run(() => { Task.Delay(500).Wait(); }); Main main = (Main)GetWindowByName("Main"); main?.vieModel.Reset(); button.IsEnabled = true; }
public static async Task <bool> ParseSpecifiedInfo(WebSite webSite, string id, string url) { HttpResult httpResult = null; if (webSite == WebSite.Bus) { httpResult = await Net.Http(url, new CrawlerHeader() { Cookies = JvedioServers.Bus.Cookie }); } else if (webSite == WebSite.BusEu) { httpResult = await Net.Http(url, new CrawlerHeader() { Cookies = JvedioServers.BusEurope.Cookie }); } else if (webSite == WebSite.Library) { httpResult = await Net.Http(url, new CrawlerHeader() { Cookies = JvedioServers.Library.Cookie }); } else if (webSite == WebSite.Jav321) { httpResult = await Net.Http(url, new CrawlerHeader() { Cookies = JvedioServers.Jav321.Cookie }); } else if (webSite == WebSite.FC2) { httpResult = await Net.Http(url, new CrawlerHeader() { Cookies = JvedioServers.FC2.Cookie }); } else if (webSite == WebSite.DB) { httpResult = await Net.Http(url, new CrawlerHeader() { Cookies = JvedioServers.DB.Cookie }); } else if (webSite == WebSite.DMM) { httpResult = await Net.Http(url, new CrawlerHeader() { Cookies = JvedioServers.DMM.Cookie }); } else if (webSite == WebSite.MOO) { httpResult = await Net.Http(url, new CrawlerHeader() { Cookies = JvedioServers.MOO.Cookie }); } else { httpResult = await Net.Http(url); } if (httpResult != null && httpResult.StatusCode == HttpStatusCode.OK && httpResult.SourceCode != "") { string content = httpResult.SourceCode; Dictionary <string, string> Info = new Dictionary <string, string>(); if (webSite == WebSite.Bus) { Info = new BusParse(id, content, Identify.GetVideoType(id)).Parse(); Info.Add("source", "javbus"); } else if (webSite == WebSite.BusEu) { Info = new BusParse(id, content, VedioType.欧美).Parse(); Info.Add("source", "javbus"); } else if (webSite == WebSite.DB) { Info = new JavDBParse(id, content, url.Split('/').Last()).Parse(); Info.Add("source", "javdb"); } else if (webSite == WebSite.Library) { Info = new LibraryParse(id, content).Parse(); Info.Add("source", "javlibrary"); } else if (webSite == WebSite.Jav321) { Info = new LibraryParse(id, content).Parse(); Info.Add("source", "Jav321"); } else if (webSite == WebSite.DMM) { Info = new LibraryParse(id, content).Parse(); Info.Add("source", "DMM"); } else if (webSite == WebSite.MOO) { Info = new LibraryParse(id, content).Parse(); Info.Add("source", "MOO"); } else if (webSite == WebSite.FC2) { Info = new LibraryParse(id, content).Parse(); Info.Add("source", "FC2"); } Info.Add("sourceurl", url); if (Info.Count > 2) { FileProcess.SaveInfo(Info, id); return(true); } } return(false); }