public override DownloadInfo GetVideoInfo(bool saveDialog, String savePath) { DownloadInfo info = null; long videoFileSize = 0; String titreVideo = null; try { if (urlPageVideo != null) { videoFileSize = getVideoFileSizeAndType(urlPageVideo); if (videoFileSize > 0) { titreVideo = extractTitleFromUrl(urlPageVideo); if (titreVideo != null) { info = new DownloadInfo(urlPageVideo, titreVideo, videoFileSize, savePath, this.fileType, manager.managerMV, manager, this); if (saveDialog) { info = LaunchSaveDlg(info); } } } } return info; } catch (Exception ex) { AddErrorMsg(String.Format(Properties.Resources.downloadError, urlPageVideo), ex); return null; } }
public Download(string urlPageVideo, DownloadManagerM manager) { if(urlPageVideo != null) if (!urlPageVideo.StartsWith("http://")) { if (!urlPageVideo.StartsWith("https://")) urlPageVideo = "http://" + urlPageVideo; else { //Remove the s from https urlPageVideo.Remove(4, 1); } } this.urlPageVideo = urlPageVideo; this.manager = manager; fileType = ""; segments = null; p_videoInfo = null; fichierLocal = null; p_isPaused = false; isCanceled = false; downloadStarted = false; //downloadStartTime = DateTime.Now; nombreSegmentsActifs = 0; speedTimer = new Stopwatch(); totalDownloadTime = new Stopwatch(); }
public override DownloadInfo GetVideoInfo(bool saveDialog, String savePath) { HttpWebResponse myReponse = null; StreamReader streamReader = null; try { DownloadInfo info = null; int indexSeparateurCode = urlPageVideo.IndexOf('?'); String xmlUrl = urlPageVideo.Substring(0, indexSeparateurCode); String videoCode = urlPageVideo.Substring(indexSeparateurCode + 1); XmlDocument videosListe = new XmlDocument(); String ligne = null; StringBuilder xmlBuilder = new StringBuilder(); String title = null; String broadcastId = null; int limite = 9999; int offset = 0; xmlUrl = xmlUrl + "?limit=" + limite + "&offset=" + offset; HttpWebRequest myReq = manager.getHttpWebRequest(xmlUrl); myReq.Timeout = Settings.Default.getInfoTimeout; myReponse = (HttpWebResponse)myReq.GetResponse(); streamReader = new StreamReader(myReponse.GetResponseStream()); while ((ligne = streamReader.ReadLine()) != null) { xmlBuilder.AppendLine(ligne); } streamReader.Close(); myReponse.Close(); videosListe.LoadXml(xmlBuilder.ToString()); String XPathSearchId = "//objects/object/id[. ='" + videoCode + "']"; XmlNode node = videosListe.SelectSingleNode(XPathSearchId); if (node != null) { XmlNode objectNode = node.ParentNode; title = objectNode.SelectSingleNode("title").InnerText; broadcastId = objectNode.SelectSingleNode("broadcast_id").InnerText; } if (title != null) { String XPathSearchTitle = "//objects/object/title[. ='" + title + "']"; XmlNodeList nodes = videosListe.SelectNodes(XPathSearchTitle); foreach (XmlNode titleNode in nodes) { XmlNode objectNode = titleNode.ParentNode; if (objectNode.HasChildNodes) { XmlNode videoUrlNode = objectNode.SelectSingleNode("video_file_url"); XmlNode titreNode = objectNode.SelectSingleNode("title"); XmlNode fileSizeNode = objectNode.SelectSingleNode("file_size"); if ((videoUrlNode != null) && (titreNode != null) && (fileSizeNode != null)) { String urlVideoFile = videoUrlNode.InnerText; long videoFileSize = getVideoFileSizeAndType(urlVideoFile);//Int64.Parse(fileSizeNode.InnerText); String titreVideo = CleanTitre(titreNode.InnerText); int indexExtension = urlVideoFile.LastIndexOf("."); String type = urlVideoFile.Substring(indexExtension + 1); info = new DownloadInfo(urlVideoFile, titreVideo, videoFileSize, savePath, type, manager.managerMV, manager, this); if (saveDialog) { info = LaunchSaveDlg(info); } } } } } /* XmlElement root = videosListe.DocumentElement; XmlNodeList nodes = root.SelectNodes("record"); foreach (XmlNode objectNode in nodes) { if (objectNode.HasChildNodes) { XmlNode idNode = objectNode.SelectSingleNode("id"); if (videoCode.Equals(idNode.InnerText)) { XmlNode videoUrlNode = objectNode.SelectSingleNode("video_file_url"); XmlNode titreNode = objectNode.SelectSingleNode("title"); XmlNode fileSizeNode = objectNode.SelectSingleNode("file_size"); if ((videoUrlNode != null) && (titreNode != null) && (fileSizeNode != null)) { String urlVideoFile = videoUrlNode.InnerText; long videoFileSize = Int64.Parse(fileSizeNode.InnerText); String titreVideo = CleanTitre(titreNode.InnerText); int indexExtension = urlVideoFile.LastIndexOf("."); String type = urlVideoFile.Substring(indexExtension + 1); info = new DownloadInfo(urlVideoFile, titreVideo, videoFileSize, savePath, type, manager.managerMV, manager, this); if (saveDialog) { info = LaunchSaveDlg(info); } } } } }*/ return info; } catch (WebException wex) { if (myReponse != null) { myReponse.Close(); myReponse = null; streamReader = null; } if (wex.Status == WebExceptionStatus.Timeout) { nombreTimeout++; if (nombreTimeout < Settings.Default.timeoutMax) { return this.GetVideoInfo(saveDialog, savePath); } else { AddErrorMsg(String.Format(Properties.Resources.timeoutError, urlPageVideo, Settings.Default.timeoutMax), wex); return null; } } else { AddErrorMsg(String.Format(Properties.Resources.downloadError, urlPageVideo), wex); return null; } } catch (Exception ex) { if (myReponse != null) { myReponse.Close(); myReponse = null; streamReader = null; } AddErrorMsg(String.Format(Properties.Resources.downloadError, urlPageVideo), ex); return null; } }
internal void DownloadFini(DownloadInfo downloadInfo) { try { listeDownloadInfos.Remove(downloadInfo); updateTotalDownloadSpeed(); } catch (Exception ex) { AddErrorMsg("DownloadManagerMV.DownloadFini() ", ex); } }
internal void AddNewDownload(DownloadInfo downloadInfo) { try { listeDownloadInfos.Add(downloadInfo); updateTotalDownloadSpeed(); AddInfoMsg(String.Format(Properties.Resources.msgNewDownload, downloadInfo.titre)); } catch (Exception ex) { AddErrorMsg("DownloadManagerMV.AddNewDownload() ", ex); } }
public override DownloadInfo GetVideoInfo(bool saveDialog, String savePath) { HttpWebResponse myReponse = null; StreamReader streamReader = null; try { DownloadInfo info = null; String ligne; String swfHtml = "Raté"; String titre = "Raté"; bool swfhtmlTrouve = false; bool titreTrouve = false; int videoIndex = -1; if (urlPageVideo != null) { String urlPageVideoHtml = urlPageVideo; int posIndex = urlPageVideo.IndexOf(Settings.Default.indexParam); if (posIndex != -1) { try { videoIndex = Int32.Parse(urlPageVideo.Substring(posIndex + Settings.Default.indexParam.Length)); } catch (Exception) { videoIndex = -1; } urlPageVideoHtml = urlPageVideo.Substring(0, posIndex); } HttpWebRequest myReq = manager.getHttpWebRequest(urlPageVideoHtml); myReq.Timeout = Settings.Default.getInfoTimeout; myReponse = (HttpWebResponse)myReq.GetResponse(); if (myReq.CookieContainer != null) myReponse.Cookies = myReq.CookieContainer.GetCookies(myReq.RequestUri); streamReader = new StreamReader(myReponse.GetResponseStream()); } else { byte[] byteArray = Encoding.ASCII.GetBytes(this.clipboardContent); MemoryStream stream = new MemoryStream(byteArray); streamReader = new StreamReader(stream); } #if DEBUG StringBuilder page = new StringBuilder(); #endif while (((ligne = streamReader.ReadLine()) != null) && (!(swfhtmlTrouve && titreTrouve))) { #if DEBUG page.AppendLine(ligne); #endif if (ligne.Contains(Settings.Default.debutLigneUrlYoutube)) { swfHtml = ligne; swfhtmlTrouve = true; } if (ligne.Contains(Settings.Default.debutLigneTitreYoutube)) { titre = ligne; while (!titre.Contains(Settings.Default.finLigneTitreYoutube)) titre = String.Concat(titre.Trim(), streamReader.ReadLine()); titreTrouve = true; } } streamReader.Close(); #if DEBUG String pageHtml = CleanASCIICodingOnce(page.ToString()); #endif if (swfhtmlTrouve && titreTrouve) { //swfHtml = CleanASCIICodingOnce(swfHtml).Trim(); titre = CleanASCIICoding(titre).Trim(); if ((titre != null) && (swfHtml != null)) { String urlVideoFileClear = extractUrlFromBrutSwfHtml(swfHtml); long videoFileSize = 0; String titreVideo = null; if (urlVideoFileClear != null) { String urlVideoFile = urlVideoFileClear;// urlVideoFileClear.Replace(",", "%2C"); ; videoFileSize = getVideoFileSizeAndType(urlVideoFile); if (videoFileSize > 0) { titreVideo = extractTitleFromDocumentTitle(titre, Settings.Default.debutTitreYoutube, Settings.Default.finTitreYoutube); if (titreVideo != null) { info = new DownloadInfo(urlVideoFile, titreVideo, videoFileSize, savePath, this.fileType, manager.managerMV, manager, this, videoIndex); if (saveDialog) { info = LaunchSaveDlg(info); } } } } } } else { if (!swfhtmlTrouve) { AddInfoMsg(String.Format("Impossible de trouver la ligne commençant par {0} qui contient les url des different format pour cette video dans {1}", Settings.Default.debutLigneUrlYoutube, urlPageVideo)); //DownloadThroughKeepvid(urlPageVideo, savePath, saveDialog); } if (!titreTrouve) { AddInfoMsg(String.Format("Impossible de trouver la ligne commençant par {0} qui contient le titre de la video dans {1}", Settings.Default.debutLigneTitreYoutube, urlPageVideo)); } } return info; } catch (WebException wex) { if (myReponse != null) { myReponse.Close(); myReponse = null; streamReader = null; } if (wex.Status == WebExceptionStatus.Timeout) { nombreTimeout++; #if DEBUG nombreTimeout += 999; #endif if (nombreTimeout < Settings.Default.timeoutMax) { return this.GetVideoInfo(saveDialog, savePath); } else { AddErrorMsg(String.Format(Properties.Resources.timeoutError, urlPageVideo, Settings.Default.timeoutMax), wex); return null; } } else { AddErrorMsg(String.Format(Properties.Resources.downloadError, urlPageVideo), wex); return null; } } catch (Exception ex) { if (myReponse != null) { myReponse.Close(); myReponse = null; streamReader = null; } else if (streamReader != null) streamReader.Close(); AddErrorMsg(String.Format(Properties.Resources.downloadError, urlPageVideo), ex); return null; } }
private void DownloadThroughKeepvid(string urlPageVideo, String savePath, bool saveDialog) { HttpWebResponse myReponse = null; StreamReader streamReader = null; try { String keepVidUrl = "http://keepvid.com/?url=" + HttpUtility.UrlEncode(urlPageVideo); HttpWebRequest myReq = manager.getHttpWebRequest(keepVidUrl); myReq.Timeout = Settings.Default.getInfoTimeout; myReponse = (HttpWebResponse)myReq.GetResponse(); streamReader = new StreamReader(myReponse.GetResponseStream()); StringBuilder pageHtmlBuilder = new StringBuilder(); String ligne; String urlFinale = null; String titre = null; while ((ligne = streamReader.ReadLine()) != null) { pageHtmlBuilder.AppendLine(ligne); } streamReader.Close(); myReponse.Close(); String pageHtml = CleanASCIICoding(pageHtmlBuilder.ToString()); List<String> listeUrl = new List<String>(); MatchCollection MatchList; Regex regex = new Regex("(?<videoUrl>http://[^\"<> ]*\\.youtube\\.com/videoplayback[^\"<> ]*)", RegexOptions.Compiled | RegexOptions.IgnoreCase); StringReader reader = new StringReader(pageHtml); int compteur = 0; while ((ligne = reader.ReadLine()) != null) { ligne = ligne.Trim(); MatchList = regex.Matches(ligne); foreach (Match match in MatchList) { Group videoUrlGroup; videoUrlGroup = match.Groups["videoUrl"]; if (videoUrlGroup.Success) { listeUrl.Add(videoUrlGroup.Value); } } if(ligne.Contains(urlPageVideo)) { int index = ligne.IndexOf(urlPageVideo); while (index != -1) { compteur++; if (compteur == 4) { int indexDebutTitre = ligne.IndexOf(">", index) + 1; int indexFinTitre = ligne.IndexOf("<", indexDebutTitre); if ((indexDebutTitre > -1) && (indexFinTitre > indexDebutTitre)) titre = ligne.Substring(indexDebutTitre, indexFinTitre - indexDebutTitre); break; } index = ligne.IndexOf(urlPageVideo, index + urlPageVideo.Length); } } } reader.Close(); int currentTagPriorite = 999; foreach (String url in listeUrl) { int itagIndex = url.IndexOf(Settings.Default.itagParam); if (itagIndex != -1) { itagIndex += Settings.Default.itagParam.Length; int indexSeparator = url.IndexOf(Settings.Default.paramSeparator, itagIndex); String itagString = url.Substring(itagIndex, indexSeparator - itagIndex); int itag = Convert.ToInt32(itagString); int priorite = manager.getPrioriteFromFormatTag(itag); if (priorite < currentTagPriorite) { currentTagPriorite = priorite; urlFinale = url; } } } if (urlFinale != null) { if (titre == null) titre = "keepVidYoutube"; long videoFileSize = getVideoFileSizeAndType(urlFinale); if (videoFileSize > 0) { DownloadInfo info = new DownloadInfo(urlFinale, titre, videoFileSize, savePath, this.fileType, manager.managerMV, manager, this); if (saveDialog) { info = LaunchSaveDlg(info); } } } else { } } catch (Exception ex) { if (myReponse != null) { myReponse.Close(); myReponse = null; streamReader = null; } AddErrorMsg("Erreur dans DownloadThroughKeepvid pour: " + urlPageVideo, ex); } }
public override DownloadInfo GetVideoInfo(bool saveDialog, String savePath) { HttpWebResponse myReponse = null; StreamReader streamReader = null; try { DownloadInfo info = null; XmlDocument videoInfoXml = new XmlDocument(); String ligne = null; StringBuilder xmlBuilder = new StringBuilder(); String titreVideo = null; String urlVideoFile = null; long videoFileSize = 0; HttpWebRequest myReq = manager.getHttpWebRequest(urlPageVideo); myReq.Timeout = Settings.Default.getInfoTimeout; myReponse = (HttpWebResponse)myReq.GetResponse(); streamReader = new StreamReader(myReponse.GetResponseStream()); while ((ligne = streamReader.ReadLine()) != null) { xmlBuilder.AppendLine(ligne); } streamReader.Close(); myReponse.Close(); videoInfoXml.LoadXml(xmlBuilder.ToString()); XmlNode titleNode = videoInfoXml.SelectSingleNode(Settings.Default.blipTvTitleXPath); if (titleNode != null) { titreVideo = titleNode.InnerText; XmlNodeList mediaList = videoInfoXml.SelectNodes(Settings.Default.blipTvMediaXPath); foreach (XmlNode mediaNode in mediaList) { XmlNode filePathNode = mediaNode.SelectSingleNode(Settings.Default.blipTvVideoUrlXPath); XmlNode sizeNode = mediaNode.SelectSingleNode(Settings.Default.blipTvVideoFileSizeXPath); XmlNode contentTypeNode = mediaNode.SelectSingleNode(Settings.Default.blipTvVideoTypeXPath); if ((filePathNode != null) && (sizeNode != null) && (contentTypeNode != null)) { long currentSize = Int64.Parse(sizeNode.InnerText); if (currentSize > videoFileSize) { urlVideoFile = filePathNode.InnerText; videoFileSize = currentSize; this.fileType = GetTypeFromContentType(contentTypeNode.InnerText); } } } if (urlVideoFile != null) { info = new DownloadInfo(urlVideoFile, titreVideo, videoFileSize, savePath, this.fileType, manager.managerMV, manager, this); if (saveDialog) { info = LaunchSaveDlg(info); } } } return info; } catch (WebException wex) { if (myReponse != null) { myReponse.Close(); myReponse = null; streamReader = null; } if (wex.Status == WebExceptionStatus.Timeout) { nombreTimeout++; if (nombreTimeout < Settings.Default.timeoutMax) { return this.GetVideoInfo(saveDialog, savePath); } else { AddErrorMsg(String.Format(Properties.Resources.timeoutError, urlPageVideo, Settings.Default.timeoutMax), wex); return null; } } else { AddErrorMsg(String.Format(Properties.Resources.downloadError, urlPageVideo), wex); return null; } } catch (Exception ex) { if (myReponse != null) { myReponse.Close(); myReponse = null; streamReader = null; } AddErrorMsg(String.Format(Properties.Resources.downloadError, urlPageVideo), ex); return null; } }
public override DownloadInfo GetVideoInfo(bool saveDialog, String savePath) { HttpWebResponse myReponse = null; StreamReader streamReader = null; try { DownloadInfo info = null; String ligne; String swfHtml = "Raté"; String titre = "Raté"; bool swfhtmlTrouve = false; bool titreTrouve = false; HttpWebRequest myReq = manager.getHttpWebRequest(urlPageVideo); myReq.Timeout = Settings.Default.getInfoTimeout; myReponse = (HttpWebResponse)myReq.GetResponse(); streamReader = new StreamReader(myReponse.GetResponseStream()); #if DEBUG StringBuilder page = new StringBuilder(); #endif while (((ligne = streamReader.ReadLine()) != null) && (!(swfhtmlTrouve && titreTrouve))) { #if DEBUG page.AppendLine(ligne); #endif if (ligne.Contains(Settings.Default.ligneFinderUrlGiantBomb)) { swfHtml = ligne; swfhtmlTrouve = true; } if (ligne.Contains(Settings.Default.debutLigneTitreYoutube)) { titre = ligne; while (!titre.Contains(Settings.Default.finLigneTitreYoutube)) titre = String.Concat(titre.Trim(), streamReader.ReadLine()); titreTrouve = true; } } streamReader.Close(); myReponse.Close(); #if DEBUG String pageHtml = CleanASCIICoding(page.ToString()); #endif if (swfhtmlTrouve && titreTrouve) { swfHtml = CleanASCIICoding(swfHtml); titre = CleanASCIICoding(titre).Trim(); if ((titre != null) && (swfHtml != null)) { String urlVideoFile = extractUrlFromSwfHtml(swfHtml); long videoFileSize = 0; String titreVideo = null; if (urlVideoFile != null) { videoFileSize = getVideoFileSizeAndType(urlVideoFile); if (videoFileSize > 0) { titreVideo = extractTitleFromDocumentTitle(titre, Settings.Default.debutTitreGiantBomb, Settings.Default.finTitreGiantBomb); if (titreVideo != null) { info = new DownloadInfo(urlVideoFile, titreVideo, videoFileSize, savePath, this.fileType, manager.managerMV, manager, this); if (saveDialog) { info = LaunchSaveDlg(info); } } } } } } else { if (!swfhtmlTrouve) { AddInfoMsg(String.Format("Impossible de trouver la ligne commençant par {0} qui contient les url des different format pour cette video dans {1}", Settings.Default.debutLigneUrlYoutube, urlPageVideo)); } if (!titreTrouve) { AddInfoMsg(String.Format("Impossible de trouver la ligne commençant par {0} qui contient le titre de la video dans {1}", Settings.Default.debutLigneTitreYoutube, urlPageVideo)); } } return info; } catch (WebException wex) { if (myReponse != null) { myReponse.Close(); myReponse = null; streamReader = null; } if (wex.Status == WebExceptionStatus.Timeout) { nombreTimeout++; if (nombreTimeout < Settings.Default.timeoutMax) { return this.GetVideoInfo(saveDialog, savePath); } else { AddErrorMsg(String.Format(Properties.Resources.timeoutError, urlPageVideo, Settings.Default.timeoutMax), wex); return null; } } else { AddErrorMsg(String.Format(Properties.Resources.downloadError, urlPageVideo), wex); return null; } } catch (Exception ex) { if (myReponse != null) { myReponse.Close(); myReponse = null; streamReader = null; } AddErrorMsg(String.Format(Properties.Resources.downloadError, urlPageVideo), ex); return null; } }
protected DownloadInfo LaunchSaveDlg(DownloadInfo info) { try { lock (manager.mainWindowPtr) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "All files (*.*)|*.*"; saveFileDialog1.FilterIndex = 1; saveFileDialog1.RestoreDirectory = true; saveFileDialog1.InitialDirectory = info.saveFilePath; saveFileDialog1.FileName = info.fileName; saveFileDialog1.DefaultExt = info.fileExtension; saveFileDialog1.CheckFileExists = false; saveFileDialog1.AddExtension = true; saveFileDialog1.AutoUpgradeEnabled = true; saveFileDialog1.ShowHelp = false; saveFileDialog1.OverwritePrompt = true; DialogResult resultat = DialogResult.Abort; resultat = saveFileDialog1.ShowDialog(manager.mainWindowPtr); if (resultat == DialogResult.OK) { if (!saveFileDialog1.FileName.Equals("")) { int index = saveFileDialog1.FileName.LastIndexOf(Path.DirectorySeparatorChar); info.saveFilePath = saveFileDialog1.FileName.Substring(0, index + 1); info.fileName = saveFileDialog1.FileName.Substring(index + 1); } } else info = null; return info; } } catch (Exception ex) { AddErrorMsg("Download.LaunchSaveDlg ", ex); return null; } }
protected void DownloadFini() { try { fichierLocal.Close(); //TimeSpan downloadTime = DateTime.Now - downloadStartTime; totalDownloadTime.Stop(); long averageDownloadSpeed = 0; if (totalDownloadTime.Elapsed.TotalSeconds != 0) averageDownloadSpeed = (long)(videoInfo.taille / totalDownloadTime.Elapsed.TotalSeconds); if (videoInfo.downloaded == videoInfo.taille) AddInfoMsg(TypeMsg.Validation, String.Format(Properties.Resources.msgDownloadDone, videoInfo.titre, Helper.ByteSpeedToString(averageDownloadSpeed))); else AddInfoMsg(String.Format(Properties.Resources.msgDownloadDoneIncomplete, videoInfo.titre, videoInfo.downloaded, videoInfo.taille, videoInfo.taille - videoInfo.downloaded)); manager.DownloadFini(this); speedTimer.Stop(); segments = null; videoInfo = null; } catch (Exception ex) { AddErrorMsg("Download.DownloadFini() ", ex); } }
public virtual void LaunchDownload(bool saveDialog, String savePath) { int retries = 0; #if DEBUG retries = maxRetries - 1; #endif while (((videoInfo = GetVideoInfo(saveDialog, savePath)) == null) && (retries < maxRetries)) retries++; if (videoInfo != null && !videoInfo.fileExistsAlready) StartDownload(); }
public override DownloadInfo GetVideoInfo(bool saveDialog, String savePath) { HttpWebResponse myReponse = null; StreamReader streamReader = null; try { DownloadInfo info = null; String ligne; //XmlDocument videoInfoXml = new XmlDocument(); String videoId = urlPageVideo.Substring(urlPageVideo.LastIndexOf("/") + 1); String vimeoXmlUrl = String.Format(Settings.Default.vimeoXmlUrl, videoId); String keepVidUrl = Settings.Default.keepVidUrl + urlPageVideo; HttpWebRequest myReq = manager.getHttpWebRequest(keepVidUrl); myReq.Timeout = Settings.Default.getInfoTimeout; myReponse = (HttpWebResponse)myReq.GetResponse(); streamReader = new StreamReader(myReponse.GetResponseStream()); StringBuilder page = new StringBuilder(); String titre = null; String downloadInfoLigne = null; while ((ligne = streamReader.ReadLine()) != null) { page.AppendLine(ligne); if(ligne.Contains("<div class=\"j\" id=\"info\">")) downloadInfoLigne = ligne; } streamReader.Close(); myReponse.Close(); String pageHtml = page.ToString(); Regex vimeoRegex = new Regex(Settings.Default.keepVidVimeoUrlRegex, RegexOptions.Compiled | RegexOptions.IgnoreCase); String finDivTag = "</div>"; MatchCollection MatchList = vimeoRegex.Matches(downloadInfoLigne.Substring(downloadInfoLigne.IndexOf(finDivTag) + finDivTag.Length)); StringCollection vimeoVideoUrls = new StringCollection(); foreach (Match match in MatchList) { Group urlGroup = match.Groups["url"]; if (urlGroup.Success) { String urlPotentielle = urlGroup.Value; //if(urlPotentielle.Contains(".mp4")) vimeoVideoUrls.Add(urlPotentielle); } } if (vimeoVideoUrls.Count > 0) { Regex vimeoTitreRegex = new Regex(Settings.Default.keepVidVimeoTitleRegex, RegexOptions.Compiled | RegexOptions.IgnoreCase); Match matchTitre = vimeoTitreRegex.Match(downloadInfoLigne); Group titreGroup; titreGroup = matchTitre.Groups["title"]; if (titreGroup.Success) titre = titreGroup.Value; else titre = "Defaut"; long videoFileSize = 0; long bestSize = -1; String bestType = null; String urlVideoFile = null; /*foreach (String videoUrl in vimeoVideoUrls) { videoFileSize = getVideoFileSizeAndType(videoUrl); if (videoFileSize > bestSize) { bestSize = videoFileSize; bestType = this.fileType; urlVideoFile = videoUrl; } } this.fileType = bestType; videoFileSize = bestSize;*/ urlVideoFile = vimeoVideoUrls[vimeoVideoUrls.Count - 1]; videoFileSize = getVideoFileSizeAndType(urlVideoFile); if (videoFileSize > 0) { //titreVideo = extractTitleFromDocumentTitle(titre, Settings.Default.debutTitreDailyMotion, Settings.Default.finTitreDailyMotion); titre = CleanTitre(titre); if (titre == null) titre = "Defaut"; else { info = new DownloadInfo(urlVideoFile, titre, videoFileSize, savePath, this.fileType, manager.managerMV, manager, this); if (saveDialog) { info = LaunchSaveDlg(info); } } } } else { AddInfoMsg(String.Format("Impossible de trouver lesurls des videos Vimeo dans la page {0}", keepVidUrl)); } return info; } catch (WebException wex) { if (myReponse != null) { myReponse.Close(); myReponse = null; streamReader = null; } if (wex.Status == WebExceptionStatus.Timeout) { nombreTimeout++; if (nombreTimeout < Settings.Default.timeoutMax) { return this.GetVideoInfo(saveDialog, savePath); } else { AddErrorMsg(String.Format(Properties.Resources.timeoutError, urlPageVideo, Settings.Default.timeoutMax), wex); return null; } } else { AddErrorMsg(String.Format(Properties.Resources.downloadError, urlPageVideo), wex); return null; } } catch (Exception ex) { if (myReponse != null) { myReponse.Close(); myReponse = null; streamReader = null; } AddErrorMsg(String.Format(Properties.Resources.downloadError, urlPageVideo), ex); return null; } }