Ejemplo n.º 1
0
 public PixivBookmark(ResourceLoader loader, Pixiv pixiv)
 {
     illustQueue = new ConcurrentQueue <ImageInfo>();
     this.pixiv  = pixiv;
     this.loader = loader;
     nextUrl     = "begin";
 }
Ejemplo n.º 2
0
 public PixivFollowingIllust(ResourceLoader loader, Pixiv pixiv)
 {
     illustQueue = new ConcurrentQueue <ImageInfo>();
     this.loader = loader;
     this.pixiv  = pixiv;
     nextUrl     = "begin";
 }
 public PixivRecommendation(ResourceLoader loader, Pixiv pixiv)
 {
     this.loader = loader;
     this.pixiv  = pixiv;
     Recomm      = new ConcurrentQueue <ImageInfo>();
     nextUrl     = "begin";
 }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            banButton("1");
            String username = userBox.Text;
            String password = pwdBox.Text;
            String id       = idBox.Text;

            //MessageBox.Show(username + " " + password + " " + id);

            Pixiv pixiv = new Pixiv(HttpUtility.UrlEncode(username), password);//需要转换@为%40

            if (pixiv.login() == false)
            {
                MessageBox.Show("登录失败");
                return;
            }
            else
            {
                FileStream   fs = new FileStream("./user.txt", FileMode.Create);
                StreamWriter sr = new StreamWriter(fs, Encoding.UTF8);
                sr.Write(userBox.Text + "\n" + pwdBox.Text);
                sr.Close();
                fs.Close();
            }
            downloadProcess = pixiv.downloadImages(id, sameDirCheckBox.Checked);
            if (downloadProcess == null)
            {
                MessageBox.Show("下载失败");
            }

            downloadProcess.start();
            Thread thread = new Thread(this.run);

            thread.Start();
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter is ValueTuple <Pixiv, Conf> param)
            {
                pixiv          = param.Item1;
                c              = param.Item2;
                backgroundMode = c.backgroundMode;
                viewModel      = new ImageShowViewModel(pixiv);
                //后台模式选择
                if (backgroundMode.Equals("BackgroundTask"))
                {
                    RegistTask(); //注册后台任务以及时间触发器
                }
                else
                {
                    timer          = new DispatcherTimer();
                    timer.Interval = TimeSpan.FromMinutes(c.time);
                    timer.Tick    += Timer_Tick;
                    timer.Start();
                    BeginExtendedExecution(); //申请延迟挂起

                    foreach (var i in BackgroundTaskRegistration.AllTasks.Values)
                    {
                        if (i.Name.Equals("TimeBackgroundTrigger"))
                        {
                            i.Unregister(true);//将之前的时间触发器任务注销
                        }
                    }
                }
                ShowPageInitialize();
            }
        }
Ejemplo n.º 6
0
        public static async Task LoginMethod()
        {
            PixivCS.Objects.AuthResult res = null;
            string refreshToken            = conf.RefreshToken;

            try
            {
                if (refreshToken != null && !refreshToken.Equals("Invalidation"))
                {
                    res = await baseAPI.AuthAsync(refreshToken);

                    conf.RefreshToken = res.Response.RefreshToken;
                    var currentUser = res.Response.User;
                    pixiv = new Pixiv(baseAPI, currentUser);
                    frame.Navigate(typeof(MainPage), new ValueTuple <Pixiv, Conf>(pixiv, conf));
                    lp.webView.Visibility = Visibility.Collapsed;
                }
                else
                {
                    lp.webView.Navigate(baseAPI.GenerateWebViewUri());
                    lp.webView.Visibility = Visibility.Visible;
                }
            }
            catch (Exception)
            {
                conf.RefreshToken = "Invalidation";
                lp.webView.Navigate(baseAPI.GenerateWebViewUri());
                lp.webView.Visibility = Visibility.Visible;
            }
        }
 public PixivRanking(ResourceLoader loader, Pixiv pixiv)
 {
     this.pixiv  = pixiv;
     this.loader = loader;
     illustQueue = new ConcurrentQueue <ImageInfo>();
     rankingMode = "";
     date        = DateTime.UtcNow.Date.AddDays(-1);
     nextUrl     = "begin";
 }
        public static async Task LoginMethod()
        {
            PixivCS.Objects.AuthResult res = null;
            string refreshToken            = conf.RefreshToken;

            try
            {
                if (refreshToken != null && !refreshToken.Equals("Invalidation"))
                {
                    res = await baseAPI.AuthAsync(refreshToken);

                    conf.RefreshToken = res.Response.RefreshToken;
                    var currentUser = res.Response.User;
                    pixiv = new Pixiv(baseAPI, currentUser);
                    frame.Navigate(typeof(MainPage), new ValueTuple <Pixiv, Conf>(pixiv, conf));
                }
                else
                {
                    lp.webView.Source     = baseAPI.GenerateWebViewUri();
                    lp.webView.Visibility = Visibility.Visible;
                }
            }
            catch (Exception)
            {
                //refreshToken失效或是代理+去除SNI导致的认证失败
                try
                {
                    baseAPI.ExperimentalConnection = false;
                    res = await baseAPI.AuthAsync(refreshToken);

                    conf.RefreshToken = res.Response.RefreshToken;
                    var currentUser = res.Response.User;
                    pixiv = new Pixiv(baseAPI, currentUser);
                    frame.Navigate(typeof(MainPage), new ValueTuple <Pixiv, Conf>(pixiv, conf));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    conf.RefreshToken     = "Invalidation";
                    lp.webView.Source     = baseAPI.GenerateWebViewUri();
                    lp.webView.Visibility = Visibility.Visible;
                }
            }
        }
        public static async Task GetToken(string uri)
        {
            Console.WriteLine(uri);
            try
            {
                string[] uriSplit = uri.Split('=', '&');
                string   monitor  = uriSplit[1];
                var      res      = await baseAPI.Code2Token(uriSplit[1]);

                var currentUser = res.Response.User;
                pixiv             = new Pixiv(baseAPI, currentUser);
                conf.RefreshToken = res.Response.RefreshToken;
                frame.Navigate(typeof(MainPage), new ValueTuple <Pixiv, Conf>(pixiv, conf));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                string       title   = lp.loader.GetString("FailToLogin");
                ToastMessage message = new ToastMessage(title, "", ToastMessage.ToastMode.OtherMessage);
                message.ToastPush(30);
            }
        }
Ejemplo n.º 10
0
        public static void Load()
        {
            if (Global.Password == null)
            {
                return;
            }
            if (!File.Exists("Account.lock"))
            {
                return;
            }
            byte[] data = File.ReadAllBytes("Account.lock");
            data = FileDecrypt.Default(data);
            string  sdata = Encoding.UTF8.GetString(data);
            JObject obj   = JObject.Parse(sdata);

            if (obj["pixiv"] != null && obj["pixiv"]["username"] != null && obj["pixiv"]["password"] != null)
            {
                JToken pixv  = obj["pixiv"];
                Pixiv  pixiv = Global.Account.Pixiv ?? new Pixiv();
                _ = pixiv.Auth(pixv.StringValue("username"), pixv.StringValue("password"), true);
                Global.Account.Pixiv = pixiv;
            }
        }
Ejemplo n.º 11
0
 public PixivController(IHttpClient client)
 {
     this.client = client;
     pixiv       = new Pixiv(client);
 }