Exemple #1
0
 private void LoadSetting()
 {
     try
     {
         GlobalData.VM_MA.Site = SiteType.Patreon;
         var ais = GlobalMethord.ReadArtists("Settings\\Artists_Patreon.json");
         foreach (var ai in ais)
         {
             GlobalData.VM_MA.ArtistList.Add(ai);
         }
         if (File.Exists("Settings\\Setting_Patreon.ini"))
         {
             var ms = File.ReadAllLines("Settings\\Setting_Patreon.ini");
             GlobalData.VM_MA.Cookies  = ms[0];
             GlobalData.VM_MA.SavePath = ms[1];
             GlobalData.VM_MA.Proxy    = ms[2];
             GlobalData.VM_MA.UseProxy = bool.Parse(ms[3]);
         }
         GlobalData.VM_MA.Site = SiteType.Fantia;
         ais = GlobalMethord.ReadArtists("Settings\\Artists_Fantia.json");
         foreach (var ai in ais)
         {
             GlobalData.VM_MA.ArtistList.Add(ai);
         }
         if (File.Exists("Settings\\Setting_Fantia.ini"))
         {
             var ms = File.ReadAllLines("Settings\\Setting_Fantia.ini");
             GlobalData.VM_MA.Cookies  = ms[0];
             GlobalData.VM_MA.SavePath = ms[1];
             GlobalData.VM_MA.Proxy    = ms[2];
             GlobalData.VM_MA.UseProxy = bool.Parse(ms[3]);
         }
         GlobalData.VM_MA.Site = SiteType.Fanbox;
         ais = GlobalMethord.ReadArtists("Settings\\Artists_Fanbox.json");
         foreach (var ai in ais)
         {
             GlobalData.VM_MA.ArtistList.Add(ai);
         }
         if (File.Exists("Settings\\Setting_Fanbox.ini"))
         {
             var ms = File.ReadAllLines("Settings\\Setting_Fanbox.ini");
             GlobalData.VM_MA.Cookies  = ms[0];
             GlobalData.VM_MA.SavePath = ms[1];
             GlobalData.VM_MA.Proxy    = ms[2];
             GlobalData.VM_MA.UseProxy = bool.Parse(ms[3]);
         }
     }
     catch { }
 }
Exemple #2
0
 private void SaveSetting()
 {
     try
     {
         string fn = $"Settings\\Artists_{GlobalData.VM_MA.Site.ToString()}.json";
         File.WriteAllText(fn, GlobalMethord.ConverToJson(GlobalData.VM_MA.ArtistList));
         fn = $"Settings\\Setting_{GlobalData.VM_MA.Site.ToString()}.ini";
         File.WriteAllLines(fn, new string[] { GlobalData.VM_MA.Cookies, GlobalData.VM_MA.SavePath, GlobalData.VM_MA.Proxy, GlobalData.VM_MA.UseProxy.ToString() });
         if (!string.IsNullOrEmpty(GlobalData.VM_MA.ArtistList.Last().Id))
         {
             Dispatcher.Invoke(() => GlobalData.VM_MA.ArtistList.Add(new ArtistInfo()));
         }
     }
     catch { }
 }
Exemple #3
0
        private async void Btn_Star_Click(object sender, RoutedEventArgs e)
        {
            if (_second)
            {
                return;
            }
            _second = true;

            if (await GetCheck(GlobalData.VM_MA.IsStarted ? GlobalLanguage.Msg_SecondConf : GlobalLanguage.Msg_StartConf))
            {
                if (GlobalData.CheckResult == false)
                {
                    _second = false;
                    return;
                }
            }
            if (!GlobalData.VM_MA.IsStarted)
            {
                ShowLoading(true);
                if (await Begin())
                {
                    _tempArt = new ArtistInfo()
                    {
                        Id      = GlobalData.VM_MA.Artist.Id,
                        AName   = GlobalData.VM_MA.Artist.AName,
                        PayLow  = GlobalData.VM_MA.Artist.PayLow,
                        PayHigh = GlobalData.VM_MA.Artist.PayHigh,
                        PostUrl = GlobalData.VM_MA.Artist.PostUrl,
                    };
                    _tempSite    = GlobalData.VM_MA.Site;
                    _tempCookies = GlobalData.VM_MA.Cookies;
                    _tempProxy   = GlobalData.VM_MA.Proxy;
                    _tempDate    = GlobalData.VM_MA.Date;
                    _tempSP      = GlobalData.VM_MA.SavePath;
                    _tempUP      = GlobalData.VM_MA.UseProxy;
                    _tempUD      = GlobalData.VM_MA.UseDate;

                    ShowLoading(false);
                    GlobalData.VM_MA.IsStarted = true;
                }
            }
            else
            {
                ShowLoading(true);
                if (_tempSite != GlobalData.VM_MA.Site || _tempArt.PostUrl != GlobalData.VM_MA.Artist.PostUrl)
                {
                    if (GlobalData.VM_DL.IsDownloading)
                    {
                        await GetCheck(GlobalLanguage.Msg_IsDownload);

                        ShowLoading(false);
                        _second = false;
                        return;
                    }

                    if (await Begin())
                    {
                        _tempArt = new ArtistInfo()
                        {
                            Id      = GlobalData.VM_MA.Artist.Id,
                            AName   = GlobalData.VM_MA.Artist.AName,
                            PayLow  = GlobalData.VM_MA.Artist.PayLow,
                            PayHigh = GlobalData.VM_MA.Artist.PayHigh,
                            PostUrl = GlobalData.VM_MA.Artist.PostUrl,
                        };
                        _tempSite    = GlobalData.VM_MA.Site;
                        _tempCookies = GlobalData.VM_MA.Cookies;
                        _tempProxy   = GlobalData.VM_MA.Proxy;
                        _tempDate    = GlobalData.VM_MA.Date;
                        _tempSP      = GlobalData.VM_MA.SavePath;
                    }
                    ShowLoading(false);
                    _second = false;
                    return;
                }

                if (_tempArt.PayLow != GlobalData.VM_MA.Artist.PayLow || _tempArt.PayHigh != GlobalData.VM_MA.Artist.PayHigh)
                {
                    if (GlobalData.VM_MA.Site == SiteType.Fanbox)
                    {
                        await Task.Run(() =>
                        {
                            foreach (var bi in _tempBis)
                            {
                                bi.Skip = GlobalMethord.OverPayment(int.Parse(bi.Fee));
                            }
                        });

                        GlobalData.VM_MA.ItemList = _tempBis.Where(x => !x.Skip).ToList();
                        _tempArt.PayLow           = GlobalData.VM_MA.Artist.PayLow;
                        _tempArt.PayHigh          = GlobalData.VM_MA.Artist.PayHigh;
                    }
                }

                if (_tempSP != GlobalData.VM_MA.SavePath)
                {
                    await GetCheck(GlobalLanguage.Msg_ChangeSP);

                    _tempSP = GlobalData.VM_MA.SavePath;
                }

                if (_tempProxy != GlobalData.VM_MA.Proxy)
                {
                    GlobalData.VM_DL.DLClients.ForEach(x =>
                    {
                        GlobalData.VM_DL.ReStartCommand.Execute(x);
                    });
                    if (null != GlobalData.VM_MA.PatreonCefBrowser)
                    {
                        await CefHelper.SetProxy((CefSharp.Wpf.ChromiumWebBrowser) GlobalData.VM_MA.PatreonCefBrowser, GlobalData.VM_MA.Proxy);
                    }
                    _tempProxy = GlobalData.VM_MA.Proxy;
                }

                if (_tempUP != GlobalData.VM_MA.UseProxy)
                {
                    GlobalData.VM_DL.DLClients.ForEach(x =>
                    {
                        GlobalData.VM_DL.ReStartCommand.Execute(x);
                    });
                    if (GlobalData.VM_MA.UseProxy && null != GlobalData.VM_MA.PatreonCefBrowser)
                    {
                        await CefHelper.SetProxy((CefSharp.Wpf.ChromiumWebBrowser) GlobalData.VM_MA.PatreonCefBrowser, GlobalData.VM_MA.Proxy);
                    }
                    _tempUP = GlobalData.VM_MA.UseProxy;
                }

                if (_tempCookies != GlobalData.VM_MA.Cookies)
                {
                    GlobalData.VM_DL.DLClients.ForEach(x =>
                    {
                        GlobalData.VM_DL.ReStartCommand.Execute(x);
                    });
                    _tempCookies = GlobalData.VM_MA.Cookies;
                }

                if (_tempDate != GlobalData.VM_MA.Date || _tempUD != GlobalData.VM_MA.UseDate)
                {
                    if (GlobalData.VM_MA.Site == SiteType.Fanbox || CompareDate(GlobalData.VM_MA.Date, _tempDate))
                    {
                        await Task.Run(() =>
                        {
                            foreach (var bi in _tempBis)
                            {
                                bi.Skip = GlobalMethord.OverTime(bi.UpdateDate);
                            }
                        });

                        GlobalData.VM_MA.ItemList = _tempBis.Where(x => !x.Skip).ToList();
                        _tempDate = GlobalData.VM_MA.Date;
                        _tempUD   = GlobalData.VM_MA.UseDate;
                    }
                    else
                    {
                        if (GlobalData.VM_DL.IsDownloading)
                        {
                            await GetCheck(GlobalLanguage.Msg_IsDownload);

                            ShowLoading(false);
                            _second = false;
                            return;
                        }

                        if (await Begin())
                        {
                            _tempArt = new ArtistInfo()
                            {
                                Id      = GlobalData.VM_MA.Artist.Id,
                                AName   = GlobalData.VM_MA.Artist.AName,
                                PayLow  = GlobalData.VM_MA.Artist.PayLow,
                                PayHigh = GlobalData.VM_MA.Artist.PayHigh,
                                PostUrl = GlobalData.VM_MA.Artist.PostUrl,
                            };
                            _tempSite    = GlobalData.VM_MA.Site;
                            _tempCookies = GlobalData.VM_MA.Cookies;
                            _tempProxy   = GlobalData.VM_MA.Proxy;
                            _tempDate    = GlobalData.VM_MA.Date;
                            _tempSP      = GlobalData.VM_MA.SavePath;
                        }
                        ShowLoading(false);
                        _second = false;
                        return;
                    }
                }

                ShowLoading(false);
                GlobalCommand.BackCommand.Execute(BackType.Pop);
            }
            _second = false;
        }
        public async void LoadData()
        {
            VM_DD.CompletedList = new ObservableCollection <DownloadItem>();
            var _downLoadItemList = new ObservableCollection <DownloadItem>();
            await Task.Run(() =>
            {
                DownloadItem di = null;
                switch (GlobalData.VM_MA.Site)
                {
                case SiteType.Fanbox:
                    {
                        foreach (var bi in _baseItems)
                        {
                            if (bi.Skip)
                            {
                                continue;
                            }
                            string sp = $"{VM_DD.SavePath}\\{GlobalData.VM_MA.Artist.AName}\\{bi.CreateDate.ToString("yyyyMM\\\\dd_HHmm")}_${bi.Fee}_{bi.Title}";
                            Directory.CreateDirectory(sp);
                            if (!Directory.Exists(sp))
                            {
                                sp = GlobalMethord.ReplacePath(sp);
                                Directory.CreateDirectory(sp);
                            }
                            GlobalData.DLLogs.SetPId(bi.ID);
                            if (!string.IsNullOrEmpty(bi.CoverPic))
                            {
                                if (!GlobalData.DLLogs.HasLog(bi.CoverPic))
                                {
                                    di = new DownloadItem
                                    {
                                        FileName   = $"Cover.{bi.CoverPic.Split('.').Last()}",
                                        Link       = bi.CoverPic,
                                        SavePath   = sp,
                                        CTime      = bi.CreateDate,
                                        SourceDocu = bi,
                                        AId        = VM_DD.TempAI
                                    };
                                    di.CheckTempFile();
                                    _downLoadItemList.Add(di);
                                }
                            }
                            for (int i = 0; i < bi.ContentUrls.Count; i++)
                            {
                                if (!GlobalData.DLLogs.HasLog(bi.ContentUrls[i]))
                                {
                                    di = new DownloadItem
                                    {
                                        FileName   = bi.FileNames[i],
                                        Link       = bi.ContentUrls[i],
                                        SavePath   = sp,
                                        CTime      = bi.CreateDate,
                                        SourceDocu = bi,
                                        AId        = VM_DD.TempAI
                                    };
                                    di.CheckTempFile();
                                    _downLoadItemList.Add(di);
                                }
                            }
                            for (int i = 0; i < bi.MediaUrls.Count; i++)
                            {
                                if (!GlobalData.DLLogs.HasLog(bi.MediaUrls[i]))
                                {
                                    di = new DownloadItem
                                    {
                                        FileName   = bi.MediaNames[i],
                                        Link       = bi.MediaUrls[i],
                                        SavePath   = sp,
                                        CTime      = bi.CreateDate,
                                        SourceDocu = bi,
                                        AId        = VM_DD.TempAI
                                    };
                                    di.CheckTempFile();
                                    _downLoadItemList.Add(di);
                                }
                            }
                            if (bi.Comments.Count > 0)
                            {
                                var fp = Path.Combine(sp, "Comment.txt");
                                if (File.Exists(fp))
                                {
                                    var cms = File.ReadAllLines(fp);
                                    if (cms.Except(bi.Comments).Count() == 0)
                                    {
                                        continue;
                                    }
                                }
                                File.WriteAllLines(Path.Combine(sp, "Comment.txt"), bi.Comments);
                            }
                        }
                    }
                    break;

                case SiteType.Fantia:
                    {
                        foreach (FantiaItem fi in _baseItems)
                        {
                            string sp = $"{VM_DD.SavePath}\\{GlobalData.VM_MA.Artist.AName}\\{fi.CreateDate.ToString("yyyyMM\\\\dd_HHmm")}_{fi.Title}";
                            Directory.CreateDirectory(sp);
                            if (!Directory.Exists(sp))
                            {
                                sp = GlobalMethord.ReplacePath(sp);
                                Directory.CreateDirectory(sp);
                            }
                            GlobalData.DLLogs.SetPId(fi.ID);
                            if (!string.IsNullOrEmpty(fi.CoverPic))
                            {
                                if (!GlobalData.DLLogs.HasLog(fi.CoverPic))
                                {
                                    di = new DownloadItem
                                    {
                                        FileName   = $"Cover.{fi.CoverPic.Split('.').Last()}",
                                        Link       = fi.CoverPic,
                                        SavePath   = sp,
                                        SourceDocu = fi,
                                        AId        = VM_DD.TempAI
                                    };
                                    di.CheckTempFile();
                                    _downLoadItemList.Add(di);
                                }
                            }
                            for (int i = 0; i < fi.ContentUrls.Count; i++)
                            {
                                if (GlobalMethord.OverPayment(int.Parse(fi.Fees[i])))
                                {
                                    continue;
                                }
                                if (!GlobalData.DLLogs.HasLog(fi.ContentUrls[i]))
                                {
                                    var nsp = $"{sp}\\{fi.PTitles[i]}";
                                    if (!Directory.Exists(nsp))
                                    {
                                        Directory.CreateDirectory(nsp);
                                        if (!Directory.Exists(nsp))
                                        {
                                            sp = GlobalMethord.ReplacePath(nsp);
                                            Directory.CreateDirectory(nsp);
                                        }
                                    }
                                    di = new DownloadItem
                                    {
                                        FileName   = fi.FileNames[i],
                                        Link       = fi.ContentUrls[i],
                                        SavePath   = nsp,
                                        SourceDocu = fi,
                                        AId        = VM_DD.TempAI
                                    };
                                    di.CheckTempFile();
                                    _downLoadItemList.Add(di);
                                }
                            }
                            if (fi.Comments.Count > 0)
                            {
                                var fp = Path.Combine(sp, "Comment.txt");
                                if (File.Exists(fp))
                                {
                                    var cms = File.ReadAllLines(fp);
                                    if (cms.Except(fi.Comments).Count() == 0)
                                    {
                                        continue;
                                    }
                                }
                                File.WriteAllLines(Path.Combine(sp, "Comment.txt"), fi.Comments);
                            }
                        }
                    }
                    break;

                default:
                    {
                        foreach (var bi in _baseItems)
                        {
                            string sp = $"{VM_DD.SavePath}\\{GlobalData.VM_MA.Artist.AName}\\{bi.CreateDate.ToString("yyyyMM\\\\dd_HHmm")}_{bi.Title}";
                            Directory.CreateDirectory(sp);
                            if (!Directory.Exists(sp))
                            {
                                sp = GlobalMethord.ReplacePath(sp);
                                Directory.CreateDirectory(sp);
                            }
                            GlobalData.DLLogs.SetPId(bi.ID);
                            for (int i = 0; i < bi.ContentUrls.Count; i++)
                            {
                                if (!GlobalData.DLLogs.HasLog(bi.ContentUrls[i]))
                                {
                                    di = new DownloadItem
                                    {
                                        FileName   = bi.FileNames[i],
                                        Link       = bi.ContentUrls[i],
                                        SavePath   = sp,
                                        CTime      = bi.CreateDate,
                                        SourceDocu = bi,
                                        AId        = VM_DD.TempAI
                                    };
                                    di.CheckTempFile();
                                    _downLoadItemList.Add(di);
                                }
                            }
                            if (bi.Comments.Count > 0)
                            {
                                var fp = Path.Combine(sp, "Comment.txt");
                                if (File.Exists(fp))
                                {
                                    var cms = File.ReadAllLines(fp);
                                    if (cms.Except(bi.Comments).Count() == 0)
                                    {
                                        continue;
                                    }
                                }
                                File.WriteAllLines(Path.Combine(sp, "Comment.txt"), bi.Comments);
                            }
                        }
                    }
                    break;
                }
            });

            VM_DD.DownLoadItemList = _downLoadItemList;
        }