Exemple #1
0
        private async Task <bool> Begin()
        {
            if (string.IsNullOrEmpty(GlobalData.VM_MA.Cookies))
            {
                await GetCheck(GlobalLanguage.Msg_CheckCk);

                ShowLoading(false);
                return(false);
            }

            if (string.IsNullOrEmpty(GlobalData.VM_MA.SavePath))
            {
                await GetCheck(GlobalLanguage.Msg_CheckSP);

                ShowLoading(false);
                return(false);
            }
            Directory.CreateDirectory(GlobalData.VM_MA.SavePath);
            if (!Directory.Exists(GlobalData.VM_MA.SavePath))
            {
                await GetCheck(GlobalLanguage.Msg_CreateSP);

                ShowLoading(false);
                return(false);
            }

            if (null != GlobalData.DownLP)
            {
                GlobalData.VM_DL.DownLoadItemList.Clear();
                GlobalData.DownLP.Close();
            }
            GlobalData.VM_MA.PostCount = 0;
            GlobalData.VM_MA.PostTitle = string.Empty;
            ResultMessage _ret = null;

            _utils = GlobalData.CaptureUtil;
            if (_utils is PatreonUtils)
            {
                _ret = await(_utils as PatreonUtils).InitBrowser();
                if (_ret.Error != ErrorType.NoError)
                {
                    await GetCheck(_ret.Msgs);

                    ShowLoading(false);
                    return(false);
                }
                else if ((bool)_ret.Result)
                {
                    while (GlobalData.VM_MA.ShowLogin)
                    {
                        await Task.Delay(1000);
                    }
                    if (!GlobalData.VM_MA.IsInitialized)
                    {
                        ShowLoading(false);
                        return(false);
                    }
                }
            }
            _selectF = GlobalData.VM_MA.HasSelected;
            if (!_selectF)
            {
                ArtistInfo ai = null;
                _ret = await _utils.GetArtistInfo(GlobalData.VM_MA.Artist.PostUrl);

                if (_ret.Error != ErrorType.NoError)
                {
                    await GetCheck(_ret.Msgs);

                    ShowLoading(false);
                    return(false);
                }
                ai = (ArtistInfo)_ret.Result;
                GlobalData.VM_MA.Artist = ai;
                if (!GlobalData.VM_MA.ArtistList.Contains(GlobalData.VM_MA.Artist))
                {
                    if (GlobalData.VM_MA.ArtistList.Count > 0)
                    {
                        GlobalData.VM_MA.ArtistList[GlobalData.VM_MA.ArtistList.Count - 1] = GlobalData.VM_MA.Artist;
                    }
                    else
                    {
                        GlobalData.VM_MA.ArtistList.Add(GlobalData.VM_MA.Artist);
                    }
                }
            }
            Task.Run(() => SaveSetting());
            await Task.Run(() => GlobalData.DLLogs.LoadData(GlobalData.VM_MA.Artist.Id, GlobalData.VM_MA.Site));

            _ret = await _utils.GetPostIDs(GlobalData.VM_MA.Artist.Cid);

            if (_ret.Error != ErrorType.NoError)
            {
                await GetCheck(_ret.Msgs);

                ShowLoading(false);
                return(false);
            }
            _tempBis = (List <BaseItem>)_ret.Result;
            if (_tempBis.Count == 0)
            {
                await GetCheck(GlobalLanguage.Msg_NoPosts);

                ShowLoading(false);
                return(false);
            }
            GlobalData.VM_MA.ItemList = _tempBis.Where(x => !x.Skip).ToList();
            GlobalData.DownLP         = new Downloader(_tempBis);
            GlobalData.DownLP.Show();
            GlobalData.DownLP.LoadData();
            GlobalCommand.BackCommand.Execute(BackType.Pop);
            return(true);
        }