Exemplo n.º 1
0
        private void BuildLayout(IEnumerable <AnimeInfoClass> animeList)
        {
            StaticsClass.InvokeIfRequired(MainFrmPanel, MainFrmPanel.SuspendLayout);
            StaticsClass.InvokeIfRequired(MainFrmPanel, () =>
            {
                while (MainFrmPanel.Controls.Count > 0)
                {
                    MainFrmPanel.Controls[0].Dispose();
                }
            });
            GC.Collect(); //clear old bitmap cache, if needed.
            StaticsClass.InvokeIfRequired(MainFrmPanel, MainFrmPanel.Controls.Clear);
            var alIst = new List <Control> ();

            foreach (var animeInfo in animeList)
            {
                var animeControl = new AnimeControl(animeInfo);
                animeControl.LoadAnime += StartLoadingAnimeInformation;
                if (animeInfo.AnimeThumbnailURL.Contains(VariablesClass.MasterURL))
                {
                    animeControl.AnimeImage.Image = GetImage(animeInfo.AnimeThumbnailURL);
                }
                else
                {
                    animeControl.AnimeImage.ImageLocation = animeInfo.AnimeThumbnailURL;
                }
                alIst.Add(animeControl);
            }
            StaticsClass.InvokeIfRequired(MainFrmPanel, () => MainFrmPanel.Controls.AddRange(alIst.ToArray()));
            StaticsClass.InvokeIfRequired(MainFrmPanel, MainFrmPanel.ResumeLayout);
            StaticsClass.InvokeIfRequired(MainFrmPanel, SetFlowMargin);
        }
Exemplo n.º 2
0
        private void DoAuth()
        {
            var titleText = "";

            switch (VariablesClass.MasterURL)
            {
            case VariablesClass.KissAnimeURL:
                titleText = "Please wait 5 seconds";
                break;

            case VariablesClass.KissLewdURL:
                titleText = "Just a moment";
                break;

            case VariablesClass.KissCartoonURL:

                break;
            }
            while (_phantomObject.Title.Contains(titleText))
            {
                StaticsClass.InvokeIfRequired(WhatDoing, () => WhatDoing.Text = "Gaining authentication from server.");
                if (_counter != 4)
                {
                    StaticsClass.InvokeIfRequired(Progress, Progress.PerformStep);
                    _counter++;
                }
                Thread.Sleep(2000);
            }
        }
Exemplo n.º 3
0
        private async void DownloadAnime(CancellationToken Token)
        {
            var vals = new Dictionary <string, string>();

            StaticsClass.InvokeIfRequired(EpisodesFlowPanel, (() => { EpisodesFlowPanel.Controls.Cast <EpisodeControl>().ToList().Where(x => x.Checked).ToList().ForEach(x => vals.Add(x.Text, x.Tag.ToString())); CloseBox.Enabled = false; }));
            foreach (var keyValPair in vals)
            {
                var episodeName = GetSafeFilename(keyValPair.Key);
                try
                {
                    _infoFrm.Invoke((MethodInvoker)(() =>
                    {
                        _infoFrm.textBox1.Text = "Downloading: " + episodeName;
                        _infoFrm.textBox1.Refresh();
                    }));
                }
                catch (ObjectDisposedException)
                {
                    Token.ThrowIfCancellationRequested();
                }
                var episodeUrl    = keyValPair.Value;
                var directoryPath = _path + @"\" + GetSafeFilename(AnimeName.Text);
                Directory.CreateDirectory(directoryPath);
                string redirectorLink;
                if (VariablesClass.MasterURL == VariablesClass.KissLewdURL)
                {
                    var animeurlname = _phantomObject.Url.Substring(_phantomObject.Url.LastIndexOf("/", StringComparison.Ordinal) + 1);
                    redirectorLink = WebDriverClass.RunViaDesktop(AnimeUrl, animeurlname, episodeName, episodeUrl);
                }
                else
                {
                    redirectorLink = (await GetGoogleLink(episodeUrl)).Replace("&amp;", "&");
                }

                if (redirectorLink != "no")
                {
                    if (WebDriverClass.FileDoesNotExist(redirectorLink))
                    {
                        var animeurlname = _phantomObject.Url.Substring(_phantomObject.Url.LastIndexOf("/", StringComparison.Ordinal) + 1);
                        redirectorLink = WebDriverClass.RunViaDesktop(AnimeUrl, animeurlname, episodeName, episodeUrl);
                    }
                    Invoke((MethodInvoker)(() => _de.addDownload(redirectorLink, episodeName, directoryPath)));
                }
            }
            if (InvokeRequired)
            {
                Invoke((MethodInvoker)(() =>
                {
                    CloseBox.Enabled = true;
                    _infoFrm.Close();
                }));
            }
            else
            {
                CloseBox.Enabled = true;
                _infoFrm.Close();
            }
        }
        private async Task <Dictionary <string, string> > GetDownloadUrls(Dictionary <string, string> Values, string FetchMode = "")
        {
            if (_InfoFrm == null || _InfoFrm.IsDisposed)
            {
                this.Invoke((MethodInvoker)(() => _InfoFrm = new InfoFrm()));                                          //generate on main UI thread
            }
            var Dictionary = new Dictionary <string, string>();

            StaticsClass.InvokeIfRequired(this, () =>
            {
                _InfoFrm.Show();
                _InfoFrm.BringToFront();
            });
            foreach (var keyValPair in Values)
            {
                var episodeName = GetSafeFilename(keyValPair.Key);
                try
                {
                    StaticsClass.InvokeIfRequired(this, () =>
                    {
                        _InfoFrm.textBox1.Text = $"{FetchMode}: " + episodeName;
                        _InfoFrm.textBox1.Refresh();
                    });
                }
                catch (ObjectDisposedException)
                {
                    StaticsClass.InvokeIfRequired(this, () => { _InfoFrm.Dispose(); _InfoFrm = null; });
                    return(Dictionary);
                }
                var episodeUrl    = keyValPair.Value;
                var directoryPath = _path + @"\" + GetSafeFilename(AnimeName.Text);
                Directory.CreateDirectory(directoryPath);

                string redirectorLink;
                if (VariablesClass.MasterURL == VariablesClass.KissLewdURL)
                {
                    var animeurlname = _phantomObject.Url.Substring(_phantomObject.Url.LastIndexOf("/", StringComparison.Ordinal) + 1);
                    redirectorLink = WebDriverClass.RunViaDesktop(AnimeUrl, animeurlname, episodeName, episodeUrl);
                }
                else
                {
                    redirectorLink = (await GetGoogleLink(episodeUrl)).Replace("&amp;", "&");
                }
                if (redirectorLink != "no")
                {
                    if (WebDriverClass.FileDoesNotExist(redirectorLink))
                    {
                        var animeurlname = _phantomObject.Url.Substring(_phantomObject.Url.LastIndexOf("/", StringComparison.Ordinal) + 1);
                        redirectorLink = WebDriverClass.RunViaDesktop(AnimeUrl, animeurlname, episodeName, episodeUrl);
                    }
                    Dictionary.Add(AnimeName.Text + " - " + episodeName, redirectorLink);
                }
            }
            StaticsClass.InvokeIfRequired(this, () => { _InfoFrm.Dispose(); _InfoFrm = null; });
            return(Dictionary);
        }
        private async void GetDownloadUrlsClick(object sender, EventArgs e)
        {
            var vals = new Dictionary <string, string>();

            StaticsClass.InvokeIfRequired(EpisodesFlowPanel, (() => { EpisodesFlowPanel.Controls.Cast <EpisodeControl>().ToList().Where(x => x.Checked).ToList().ForEach(x => vals.Add(x.Text, x.Tag.ToString())); CloseBox.Enabled = false; }));
            var urls = await Task.Run(() => GetDownloadUrls(vals, "Getting URL For"));

            string CopyData = "";

            foreach (KeyValuePair <string, string> keypairvalues in urls)
            {
                CopyData += keypairvalues.Value + " - " + keypairvalues.Key + Environment.NewLine;
            }
            Clipboard.SetText(CopyData);
            MessageBox.Show("The following has been copied to your clipboard: " + Environment.NewLine + CopyData, "Otaku Time", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 6
0
        private async Task AnimeSearcher()
        {
            await Task.Run(() =>
            {
                BuildLayout(WebDriverClass.GetAnimeViaMobile(AnimeSearchQuery.Text));
                StaticsClass.InvokeIfRequired(this, () =>
                {
                    UseWaitCursor             = false;
                    AnimeSearchQuery.ReadOnly = false;
                    AnimeSearchQuery.Clear();
                    AnimeSearchQuery.Visible = false;
                });
            });

            MainFrmPanel.Refresh();
            MainFrmPanel.BringToFront();
        }
        private async void DownloadNow(object sender, EventArgs e)
        {
            var fbd    = new FolderBrowserDialog();
            var result = fbd.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }
            _path               = fbd.SelectedPath;
            UseWaitCursor       = true;
            DownloadBtn.Enabled = false;
            WatchNowBtn.Enabled = false;
            GetUrlsBtn.Enabled  = false;
            var token = new CancellationToken();

            try
            {
                await Task.Run(async() =>
                {
                    var vals = new Dictionary <string, string>();
                    StaticsClass.InvokeIfRequired(EpisodesFlowPanel, (() => { EpisodesFlowPanel.Controls.Cast <EpisodeControl>().ToList().Where(x => x.Checked).ToList().ForEach(x => vals.Add(x.Text, x.Tag.ToString())); CloseBox.Enabled = false; }));
                    var directoryPath = _path + @"\" + GetSafeFilename(AnimeName.Text);
                    Directory.CreateDirectory(directoryPath);
                    var Urls = await GetDownloadUrls(vals, "Downloading");
                    foreach (var keyValPair in Urls)
                    {
                        var ActualUrl  = keyValPair.Value;
                        var EpisodeNum = keyValPair.Key;
                        Invoke((MethodInvoker)(() => _de.addDownload(ActualUrl, EpisodeNum, directoryPath)));
                    }
                    StaticsClass.InvokeIfRequired(this, () => CloseBox.Enabled = true);
                }, token);
            }
            catch (OperationCanceledException)
            {
                //Messagebox disposed, stop doing this.
            }
            DownloadBtn.Enabled = true;
            WatchNowBtn.Enabled = true;
            GetUrlsBtn.Enabled  = true;
            UseWaitCursor       = false;
        }
Exemplo n.º 8
0
        private async void SplashFrm_Load(object sender, EventArgs e)
        {
            await Task.Run(() =>
            {
                _phantomObject.Navigate().GoToUrl($"http://{VariablesClass.MasterURL}/M");
                DoAuth();
            });

            await Task.Run(() =>
            {
                StaticsClass.InvokeIfRequired(WhatDoing, () => WhatDoing.Text = "Loading new titles!");
                StaticsClass.InvokeIfRequired(Progress, Progress.PerformStep);
                _mainFrm.LoadMainScreen();
            });

            StaticsClass.InvokeIfRequired(Progress, Progress.PerformStep);
            _mainFrm.Show();
            Hide();
        }