Esempio n. 1
0
        //Má na starosti extrakci přímých odkazů z podporovaných stránek
        private void ResolveLink()
        {
            string href = "";

            if (Provider == Providers.Zippyshare)
            {
                System.Windows.Forms.HtmlElement element = webBrowser.Document.GetElementById("dlbutton");
                if (element != null)
                {
                    href = element.GetAttribute("href");
                }
                else
                {
                    OnExtractionError?.Invoke(Lang.Translate("lang_unable_to_extract"));
                    return;
                }
            }
            else if (Provider == Providers.Openload)
            {
                System.Windows.Forms.HtmlElement element = webBrowser.Document.GetElementById("streamurj");
                if (element != null)
                {
                    href = "/stream/" + element.InnerText;
                }
                else
                {
                    OnExtractionError?.Invoke(Lang.Translate("lang_unable_to_extract"));
                    return;
                }
            }
            Uri uri = new Uri(new Uri(webBrowser.Url.AbsoluteUri), href);

            OnExtractionCompleted?.Invoke(WebUtility.UrlDecode(uri.AbsoluteUri));
        }
Esempio n. 2
0
        public void Extract()
        {
            if (Provider != Providers.DirectLink) //jinak vytvoří nový objekt WebBrowser, který načte stránkou se současnou Url adresou
            {
                webBrowser = new System.Windows.Forms.WebBrowser();
                webBrowser.ScriptErrorsSuppressed = true; //potlačí vyskakovací okna
                webBrowser.Navigate(Url);
                webBrowser.DocumentCompleted += WebBrowser_DocumentCompleted;

                //spustí časovač, udává časový limit pro načtení stránky
                wbTimer.Interval = new TimeSpan(0, 0, 0, 0, browserTimeout);
                wbTimer.Tick    += WbTimer_Tick;
                wbTimer.Start();
            }
            else
            {
                OnExtractionCompleted?.Invoke(Url);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Extracts file from archive to some file in user file system, asking him where to save file using SaveFileDialog.
        /// </summary>
        /// <param name="fileName">File name in archive.</param>
        /// <returns>Task.</returns>
        public async Task ExtractFileWithDialog(int fileIndex)
        {
            string fileName = ArchiveInfo.Archive.FileList[fileIndex];

            if (fileName == null)
            {
                throw new Exception($"no file with index {fileIndex} exists.");
            }

            SaveFileDialog dialog = new SaveFileDialog();

            dialog.CheckPathExists = true;
            dialog.OverwritePrompt = true;
            dialog.ValidateNames   = true;
            dialog.Title           = "Extract file as...";
            dialog.FileName        = LowerFileNameExtension(Path.GetFileName(fileName));

            if (!String.IsNullOrWhiteSpace(AppSettings.Instance.Global.ExtractionLatestFolder))
            {
                dialog.InitialDirectory = AppSettings.Instance.Global.ExtractionLatestFolder;
            }

            string ext = Path.GetExtension(dialog.SafeFileName).ToLower();

            dialog.Filter = "Specified file|*" + ext + "|All files|*.*";

            var result = dialog.ShowDialog();

            if (result.HasValue && result.Value == true)
            {
                await ArchiveInfo.ExtractFileAsync(fileIndex, dialog.FileName);

                string destFolder = Path.GetDirectoryName(dialog.FileName);
                AppSettings.Instance.Global.ExtractionLatestFolder = destFolder;

                OnExtractionCompleted?.Invoke(this, new ExtractionEventArgs(dialog.FileName, 1, destFolder,
                                                                            ExtractionFinishedState.Succeed));
            }
        }