예제 #1
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);
        }
예제 #3
0
        private async void WatchNowBtn_Click(object sender, EventArgs e)
        {
            var SelectedControls = EpisodesFlowPanel.Controls.Cast <EpisodeControl>().Where(x => x.Checked).ToArray();

            if (SelectedControls.Count() == 0)
            {
                return;
            }
            var    name          = SelectedControls[0].Text;
            var    attributeName = SelectedControls[0].Tag.ToString();
            string redirectVideoUrl;

            if (VariablesClass.MasterURL == VariablesClass.KissLewdURL)
            {
                // the so called lewd url is dodgy, but the owner doesn't captcha, so scraping is a bit easier.
                var animeurlname = _phantomObject.Url.Substring(_phantomObject.Url.LastIndexOf("/", StringComparison.Ordinal) + 1);
                redirectVideoUrl = WebDriverClass.RunViaDesktop(AnimeUrl, animeurlname, name, attributeName);
            }
            else
            {
                redirectVideoUrl = (await GetGoogleLink(attributeName)).Replace("&amp;", "&");
            }
            if (redirectVideoUrl == "no")
            {
                MessageBox.Show("Error getting stream URL. Please Try Again.");
                return;
            }
            if (_pv == null || _pv.Player == null)
            {
                CreatePlayerInstance(name, redirectVideoUrl);
            }
            else
            {
                if (_pv.Player.isPlaying)
                {
                    var msb = new MyMessageBox("You're already playing an anime, would you like to queue or watch now?", "Otaku Time", "Queue", "Watch Now");
                    msb.Load();
                    var response = msb.Response;

                    if (response == "Queue")
                    {
                        _pv.addToQueue(name, redirectVideoUrl);
                    }
                    else if (response == "Watch Now")
                    {
                        CreatePlayerInstance(name, redirectVideoUrl);
                    }
                }
                else
                {
                    CreatePlayerInstance(name, redirectVideoUrl);
                }
            }
        }