/// <summary>
        /// Scrapes the desktop site for web info. Currently only supports the lewd URL
        /// </summary>
        /// <param name="animeurlname"></param>
        /// <param name="name"></param>
        /// <param name="attributeName"></param>
        /// <returns></returns>
        public static string RunViaDesktop(string animeUrl, string animeurlname, string name, string attributeName)
        {
            var endpoint = $"http://{VariablesClass.MasterURL}{(VariablesClass.MasterURL == VariablesClass.KissLewdURL ? "/Hentai/" : "/Anime/")}{animeurlname}/{name.Replace(" ", "-")}?id={attributeName}&s=beta";
            var value    = "";

            PhantomJSInstance.Navigate().GoToUrl(endpoint);
            if (PhantomJSInstance.Title == "Are You Human") // Robot can't do this, YET! :P
            {
                AreYouHumanHelpFrm HelpFrm = new AreYouHumanHelpFrm(PhantomJSInstance);
                HelpFrm.ShowDialog();
            }
            if (VariablesClass.MasterURL == VariablesClass.KissLewdURL)
            {
                PhantomJSInstance.ExecuteScript("$('#selectServer').val('openload').change();");
                //PhantomJSInstance.ExecuteScript("$(\"#selectServer\").find(\"option[text=\"Beta Server\"]\").attr(\"selected\", true);");
                Thread.Sleep(1000);
            }
            var xo = PhantomJSInstance.FindElementsByTagName("a").FirstOrDefault(x => x.Text.Contains("CLICK HERE"));

            if (xo != null)
            {
                if (VariablesClass.MasterURL == VariablesClass.KissLewdURL)
                {
                    value = StaticsClass.GetOpenloadLink(xo.GetAttribute("href"));
                }
                else
                {
                    value = xo.GetAttribute("href");
                }
            }
            PhantomJSInstance.Navigate().GoToUrl(animeUrl);
            return(value);
        }
Example #2
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);
        }
Example #3
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);
            }
        }
Example #4
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();
            }
        }
Example #5
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);
        }
        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);
        }
Example #8
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;
        }
Example #10
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();
        }