Пример #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();
            }
        }
Пример #2
0
        private async Task <string> GetGoogleLink(string attributeNumber)
        {
            _tryCount++;
            if (_clicked == false)
            {
                _phantomObject.Navigate().Refresh();
                var runTheScript = _phantomObject.FindElementsByClassName("episode").First(x => x.GetAttribute("data-value") == attributeNumber);
                runTheScript.Click();
                _clicked = true;
            }
            var firstpreval          = _phantomObject.FindElementsByTagName("a");
            var secondspreval        = firstpreval.Where(x => x.Text != "").Select(x => x).ToList();
            var val                  = secondspreval.FirstOrDefault(x => x.Text.Contains("mp4"));
            var alternativeSourceUrl = "";

            try
            {
                alternativeSourceUrl = _phantomObject.FindElementById("mVideo").GetAttribute("src");
            }
            catch (Exception) { }
            if (!string.IsNullOrWhiteSpace(alternativeSourceUrl))
            {
                string value;
                if (alternativeSourceUrl.Contains("openload"))
                {
                    value = StaticsClass.GetOpenloadLink(alternativeSourceUrl);
                }
                else if (alternativeSourceUrl.Contains("rapidvideo"))
                {
                    value = await WebDriverClass.GetRapidVideoLink(alternativeSourceUrl);
                }
                else
                {
                    value = alternativeSourceUrl; // its the google link. weird.
                }
                _phantomObject.Navigate().GoToUrl(AnimeUrl);
                _clicked = false;
                return(value);
            }
            if (val == null)
            {
                if (_tryCount <= 5)
                {
                    await Task.Delay(300);

                    return((await GetGoogleLink(attributeNumber)).Replace("&amp;", "&"));;
                }
                MessageBox.Show("Video is unavailable, please try again later.", "Otaku Time", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                _tryCount = 0;
                return("no");
            }
            _tryCount = 0;
            var retval = val.GetAttribute("href");

            _clicked = false;
            return(retval);
        }
        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);
        }
Пример #4
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);
                }
            }
        }
Пример #5
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();
        }
Пример #6
0
 private static Image GetImage(string imageLocation)
 {
     return(new Bitmap(new MemoryStream(WebDriverClass.GetImageBytes(imageLocation))));
 }
Пример #7
0
 public void LoadMainScreen()
 {
     BuildLayout(WebDriverClass.MainMobileUpdates());
 }