bool RunDownload(string url) { try { News newsFrom = null; News newsNative = null; EuronewsProviderLoad newsProvider = new EuronewsProviderLoad(); try { progressDownloadForm = new f.TED.FormDowloadedInfo(); progressDownloadForm.Show(); progressDownloadForm.EnSubtProgress = 10; newsFrom = newsProvider.GetContent(url); progressDownloadForm.EnSubtProgress = 60; progressDownloadForm.NativeSubtProgress = 10; string nativeSuffix = CurrentLangInfo.CurrentLangPair.To + "."; string nativeUrl = url.Replace("www.euronews.com", nativeSuffix + "euronews.com"); newsNative = newsProvider.GetContent(nativeUrl); if (newsFrom == null) { throw new ApplicationException("Was not found information fo detail data. Try another addres for getting data."); } progressDownloadForm.NativeSubtProgress = 60; string folder = GetFolder(newsFrom.Title, rootFolderName); DoDownloadFile(newsFrom.ImgSrc, folder); if (newsFrom != null) { DownloadNews(newsFrom, folder); } //if (this.newsNative != null && this.newsFrom != null) if (newsNative != null) { newsNative.VideoSrc = null; // skip native video DownloadNews(newsNative, folder, nativeSuffix, newsFrom == null ? newsNative : newsFrom); } return(true); } finally { progressDownloadForm.Close(); } } catch (TimeoutException) { MessageBox.Show("TimeoutException, please try again later"); return(false); } }
public void RunDownload(string url) { // url = @"http://www.ted.com/talks/drew_curtis_how_i_beat_a_patent_troll.html"; tedProgressForm = new f.TED.FormDowloadedInfo(); tedProgressForm.Show(); try { m_TEDProvider = new TEDProvider(); m_TEDProvider.GetContent(url, "", ""); // get info if (string.IsNullOrEmpty(m_TEDProvider.SubtitleId)) { } else { tedProgressForm.EnSubtProgress = 50; } string folder = GetFolder(m_TEDProvider.VideoTitle, rootFolderName); DoDownloadFile(m_TEDProvider.ImgSrc, folder); m_FileSubtEn = m_TEDProvider.GetSubtitles("en", folder); if (!string.IsNullOrEmpty(m_FileSubtEn)) { tedProgressForm.EnSubtProgress = 100; } else { tedProgressForm.IsEnSubtWorng = true; } // native if (rbTranslation.Checked && cmbNativeLanguage.SelectedItem is LangName) { string nativeCode = ((LangName)cmbNativeLanguage.SelectedItem).Code; if (!nativeCode.Equals("en")) { m_fileSubtNative = m_TEDProvider.GetSubtitles(nativeCode, folder); if (!string.IsNullOrEmpty(m_fileSubtNative)) { tedProgressForm.NativeSubtProgress = 100; } else { tedProgressForm.IsNativeSubtWorng = true; } } } if (!string.IsNullOrEmpty(m_TEDProvider.VideoURL)) { WebDownloader.DownloadProgressDelegate dowloadProgress = new WebDownloader.DownloadProgressDelegate(ShowProgress); m_fileVideo = WebDownloader.Download(m_TEDProvider.VideoURLFull, folder + "\\", dowloadProgress, "en.mp4"); CallCompleteEvent(); } else { // перейти на страницу чтобы самостоятельно скачать видео MessageBox.Show(this, "Video not found. Try download it self.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); Runner.OpenURL(url); } } catch { MessageBox.Show(this, "Please, try to select another episode.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); tedProgressForm.IsVideoWorng = true; } tedProgressForm.Close(); }