public void Update(ListViewItem item, clsFile PlayFile) { if (!_bIsUrlExists) { lvDetails.Items.Add(item); lvDetails.TopItem = item; FileList.Add(PlayFile); } }
public static clsFile GetUrlById(string url) { clsFile file = new clsFile(); MatchCollection matches = null; file.StrRefererUrl = url; Match matchDomain = Regex.Match(url, @"(?<Protocol>\w+):\/\/(?<Domain>[\w.]+\/?)\S*"); string Id = url.Substring(url.LastIndexOf("=") + 1); string RegexPatternBaiHat = @"<a href=[""']\/nghe\?M=" + Id + @"[""'].*?title=[""'](?<GroupTitle>.*?)[""'].*?>.*?(?<GroupName>.*?)</a>"; string data = clsHTML.GetHTML(url); matches = Regex.Matches(data, RegexPatternBaiHat, RegexOptions.IgnoreCase); foreach (Match match in matches) { file.StrTitle = match.Groups["GroupTitle"].Value; file.StrName = match.Groups["GroupName"].Value; file.StrUrl = URL(url)[1]; } return(file); }
public static clsFile GetInfoURL(string urlNeedProcess) { clsFile file = new clsFile(); Match matchDomain = Regex.Match(urlNeedProcess, @"(?<Protocol>\w+):\/\/(?<Domain>[\w.]+\/?)\S*"); if (IsURL(urlNeedProcess)) { matchDomain = Regex.Match(urlNeedProcess, @"(?<Protocol>\w+):\/\/(?<Domain>[\w.]+\/?)\S*"); } try { String Url = urlNeedProcess; string data = string.Empty; string RegexPattern = @"<embed.*?src=[""'].*?.swf?.*?=(?<url>.*?)[""']"; string[] UrlList = null; bool FlagComplete = false; MatchCollection matches = null; Working: int c = 0; data = clsHTML.GetHTML(Url); matches = Regex.Matches(data, RegexPattern, RegexOptions.IgnoreCase); UrlList = new string[matches.Count]; foreach (Match match in matches) { UrlList[c] = match.Groups["url"].Value; c++; } if (FlagComplete == false && UrlList.Length > 0) { //UrlList[0] co dang: http://v6.nhaccuatui.com/GetMusic.aspx?key2=007600040060007600150018002300320060000c if (!UrlList[0].Contains(matchDomain.Groups["Protocol"].Value)) { Url = matchDomain.Groups["Protocol"].Value + "://" + matchDomain.Groups["Domain"].Value.Remove(matchDomain.Groups["Domain"].Value.IndexOf('/')) + UrlList[0]; } else { Url = UrlList[0]; } FlagComplete = true; // chay lan nua la se lay duoc link goc goto Working; //xu li tiep link cap 2 de lay link goc } // FlagComplete = true; se lay duoc link goc else { string RegexPatternTrinhBay = string.Empty; string RegexPatternBaiHat = string.Empty; if (matchDomain.Groups["Domain"].Value.Contains("nhaccuatui.com")) //nhaccuatui.com { RegexPattern = @"<location>(?<url>.*?)</location>"; RegexPatternBaiHat = @"<creator>(?<baihat>.*?)</creator>"; RegexPatternTrinhBay = @"<title>(?<trinhbay>.*?)</title>"; } else { RegexPattern = @"<source>(?<url>.*?)</source>"; //mp3.zing.vn RegexPatternBaiHat = @"<title>(?<baihat>.*?)((]]>)|)</title>"; RegexPatternTrinhBay = @"<singer>(?<trinhbay>.*?)</singer>"; } data = clsHTML.GetHTML(Url); matches = Regex.Matches(data, RegexPattern, RegexOptions.IgnoreCase); file.StrUrl = matches[0].Groups["url"].Value; if (file.StrUrl.Contains(".mp4")) { file.StrUrl += "?q=57dd52d4365be86ebd4803521862f5ee&t=603031854"; } else if (file.StrUrl.Contains(".mp3")) { file.StrUrl += "?q=e43176f8150d7e30a6bd59bbe46b766b&t=60303108"; } else if (file.StrUrl.Contains(".flv")) { file.StrUrl += "?q=93f74da9793c0ffe9fc1d4c71fae5ebf&t=603031854"; } file.StrUrl = file.StrUrl.Replace(" ", "%20"); matches = Regex.Matches(data, RegexPatternBaiHat, RegexOptions.IgnoreCase); file.StrName = matches[0].Groups["baihat"].Value; file.StrName = file.StrName.Substring(file.StrName.LastIndexOf("[") + 1); file.StrName = file.StrName.Replace("]", ""); file.StrName = file.StrName.Replace(">", "").Trim(); matches = Regex.Matches(data, RegexPatternTrinhBay, RegexOptions.IgnoreCase); file.StrArtist = matches[0].Groups["trinhbay"].Value; file.StrArtist = file.StrArtist.Substring(file.StrArtist.LastIndexOf("[") + 1); file.StrArtist = file.StrArtist.Replace("]", ""); file.StrArtist = file.StrArtist.Replace(">", "").Trim(); } } catch { } return(file); }
public void NhacCuaTui(object linkBegin) { string link = (string)linkBegin; Match matchDomain = Regex.Match(link, @"(?<Protocol>\w+):\/\/(?<Domain>[\w.]+\/?)\S*"); string data = string.Empty; List <MatchCollection> matchs = new List <MatchCollection>(); string RegexPatternBaiHat = string.Empty; string RegexPatternTrinhBay = @"<a href=[""].*?/tim[-|_|+]kiem\?by=casi&key=(?<GroupId>.*?)[""].*?((title=[""](?<GroupTitle>.*?)[""])|)>.*?(?<GroupName>.*?)</a>"; string RegexPatternTheLoai = @"<a href=[""].*?/tim[-|_|+]kiem\?type=(?<GroupId>.*?)[""].*?((title=[""](?<GroupTitle>.*?)[""])|)>.*?(?<GroupName>.*?)</a>"; string RegexPatternIcon = @"<img src=[""]http://static2.nhaccuatui.com/Icon/?(?<icon>.*?)?.(gif|jpg)[""]"; string KeyBaiHat = "nghe?M="; string KeyTrinhBay = "tim_kiem?by=casi&key="; string KeyTheLoai = "tim_kiem?type="; List <string> arrRow = new List <string>(); data = clsHTML.GetHTML(link); try { if (_SearchOne_Or_SearchAll) { if (matchDomain.Groups["Domain"].Value.Contains("nhaccuatui.com")) { RegexPatternBaiHat = @"<a.*?href=[""]\/nghe\?M=" + _Id + @"[""].*?(title=[""](?<GroupTitle>.*?)[""]).*?>.*?(?<GroupName>.*?)</a>"; } else if (matchDomain.Groups["Domain"].Value.Contains("mp3.zing.vn")) { RegexPatternBaiHat = @"<a.*?href=[""]\/mp3\/nghe-bai-hat\/" + _Id + @"[""].*?((title=[""](?<GroupTitle>.*?)[""])|).*?>.*?(?<GroupName>.*?)</a>"; } } else { _MainForm.Invoke(new MusicOnline.MainForm.delegateUpdateClear(_MainForm.UpdateClear), new object[] { }); _MainForm.Invoke(new MusicOnline.MainForm.delegateUpdateCreatePlaylist(_MainForm.UpdateCreatePlaylist), new object[] { null, false }); if (matchDomain.Groups["Domain"].Value.Contains("nhaccuatui.com")) { RegexPatternBaiHat = @"<a.*?href=[""]\/nghe\?M=(?<GroupId>.*?)[""].*?(title=[""](?<GroupTitle>.*?)[""]).*?>.*?(?<GroupName>.*?)</a>"; } else if (matchDomain.Groups["Domain"].Value.Contains("mp3.zing.vn")) { RegexPatternBaiHat = @"<a.*?href=[""]\/mp3\/nghe-bai-hat\/(?<GroupId>.*?)[""].*?((title=[""](?<GroupTitle>.*?)[""])|).*?>.*?(?<GroupName>.*?)</a>"; } } if (matchDomain.Groups["Domain"].Value.Contains("nhaccuatui.com")) { KeyBaiHat = "nghe?M="; KeyTrinhBay = "tim_kiem?by=casi&key="; KeyTheLoai = "tim_kiem?type="; RegexPatternTrinhBay = @"<a.*?href=[""].*?/tim[-|_|+]kiem\?by=casi&key=(?<GroupId>.*?)[""].*?((title=[""](?<GroupTitle>.*?)[""])|)>.*?(?<GroupName>.*?)</a>"; RegexPatternTheLoai = @"<a.*?href=[""].*?/tim[-|_|+]kiem\?type=(?<GroupId>.*?)[""].*?((title=[""](?<GroupTitle>.*?)[""])|)>.*?(?<GroupName>.*?)</a>"; SearchPage(data, "Trang:", "chủ đề", "http://v6.nhaccuatui.com"); } else if (matchDomain.Groups["Domain"].Value.Contains("mp3.zing.vn")) { KeyBaiHat = "mp3/nghe-bai-hat/"; KeyTrinhBay = "mp3/search/do.html?"; KeyTheLoai = "mp3/search/do.html?g="; RegexPatternTrinhBay = @"Trình bày:.*?<a href=[""]\/mp3\/search\/do.html\?(?<GroupId>.*?)[""].*?((title=[""](?<GroupTitle>.*?)[""])|).*?>.*?(?<GroupName>.*?)</a>"; RegexPatternTheLoai = @"<a.*?href=[""]\/mp3\/search\/do.html\?g=(?<GroupId>.*?)[""].*?((title=[""](?<GroupTitle>.*?)[""])|)>.*?(?<GroupName>.*?)</a>"; SearchPage(data, "Trang trước", "Trang sau", ""); } string strsplit = string.Empty; if (matchDomain.Groups["Domain"].Value.Contains("nhaccuatui.com")) { strsplit = "<div class=\"row\">"; } else { strsplit = "<h1>"; } arrRow.AddRange(data.Split(new string[] { strsplit, "" }, StringSplitOptions.RemoveEmptyEntries)); if (matchDomain.Groups["Domain"].Value.Contains("mp3.zing") && arrRow.Count <= 6 && !_SearchOne_Or_SearchAll) { strsplit = "RwCakhuc"; arrRow.Clear(); arrRow.AddRange(data.Split(new string[] { strsplit, "" }, StringSplitOptions.RemoveEmptyEntries)); } else if (matchDomain.Groups["Domain"].Value.Contains("nhaccuatui") && arrRow.Count <= 6 && _SearchOne_Or_SearchAll) { strsplit = "<div class=\"item\">"; arrRow.Clear(); arrRow.AddRange(data.Split(new string[] { strsplit, "" }, StringSplitOptions.RemoveEmptyEntries)); } if (arrRow.Count <= 1) { return; } if (matchDomain.Groups["Domain"].Value.Contains("mp3.zing")) { if (!_SearchOne_Or_SearchAll) { arrRow.RemoveAt(1); } else { arrRow.RemoveAt(0); } for (int i = 0; i < arrRow.Count; i++) { if (arrRow[i].Contains("Gợi ý") || arrRow[i].Contains("Bình luận")) { arrRow.RemoveRange(i, arrRow.Count - i); break; } } } if (!_SearchOne_Or_SearchAll) { arrRow.RemoveAt(0); } MatchCollection match; ListViewItem item; foreach (string row in arrRow) { if (row.Contains("<!DOCTYPE")) { continue; } clsFile PlayerFile = new clsFile(); PlayerFile.IIndex = _MainForm._IndexRow; item = new ListViewItem(); //Bai hat va link match = Regex.Matches(row, RegexPatternBaiHat, RegexOptions.IgnoreCase); if (matchDomain.Groups["Domain"].Value.Contains("mp3.zing") && match.Count <= 0) { //tim video if (!_SearchOne_Or_SearchAll) { RegexPatternBaiHat = @"<a href=[""]\/mp3\/video-clip\/xem-video/(?<GroupId>.*?)[""].*?((title=[""](?<GroupTitle>.*?)[""])|).*?>.*?(?<GroupName>.*?)</a>"; match = Regex.Matches(row, RegexPatternBaiHat, RegexOptions.IgnoreCase); if (match.Count <= 0)//tim album { RegexPatternBaiHat = @"<a href=[""]\/mp3\/nghe-album/(?<GroupId>.*?)[""].*?((title=[""](?<GroupTitle>.*?)[""])|).*?>.*?(?<GroupName>.*?)</a>"; } match = Regex.Matches(row, RegexPatternBaiHat, RegexOptions.IgnoreCase); } else { RegexPatternBaiHat = @"<a.*?href=[""]\/mp3\/search\/do.html\?t=1(?<GroupId>.*?)[""].*?((title=[""](?<GroupTitle>.*?)[""])|)>.*?(?<GroupName>.*?)</a>"; RegexPatternTrinhBay = @"Trình bày:.*?<a.*?href=[""]\/mp3\/search\/do.html\?t=2(?<GroupId>.*?)[""].*?((title=[""](?<GroupTitle>.*?)[""])|).*?>.*?(?<GroupName>.*?)</a>"; match = Regex.Matches(row, RegexPatternBaiHat, RegexOptions.IgnoreCase); KeyTrinhBay += "t=2"; } } if (match.Count > 0 && match[0] != null && match[0].Success) { if (match[0].Groups["GroupName"].Value.Contains("img")) { continue; } PlayerFile.StrName = string.Format("{0:000}", _MainForm._IndexRow) + ". " + match[0].Groups["GroupName"].Value; item.ToolTipText = match[0].Groups["GroupTitle"].Value; if (_SearchOne_Or_SearchAll)//search one { PlayerFile.StrRefererUrl = string.Format("{0}://{1}{2}{3}", matchDomain.Groups["Protocol"].Value, matchDomain.Groups["Domain"].Value, KeyBaiHat, _Id); } else { PlayerFile.StrRefererUrl = string.Format("{0}://{1}{2}{3}", matchDomain.Groups["Protocol"].Value, matchDomain.Groups["Domain"].Value, KeyBaiHat, match[0].Groups["GroupId"].Value); } string[] url = { "", "" }; url = clsProcessUrl.URL(PlayerFile.StrRefererUrl); if (url != null && url[1] != null) { PlayerFile.StrUrl = url[1]; _MainForm.Invoke(new MusicOnline.MainForm.delegateUpdateCreatePlaylist(_MainForm.UpdateCreatePlaylist), new object[] { url[1], true }); } else { url = new string[] { "", "" } }; //url xml PlayerFile.StrRefererUrl = url[0]; //link download PlayerFile.StrUrl = url[1]; } else { continue; } match = Regex.Matches(row, RegexPatternTrinhBay, RegexOptions.IgnoreCase); //Trinh bay va link if (match.Count > 0 && match[0] != null && match[0].Success) { PlayerFile.StrArtist = match[0].Groups["GroupName"].Value; PlayerFile.StrArtistUrl = string.Format("{0}://{1}{2}{3}", matchDomain.Groups["Protocol"].Value, matchDomain.Groups["Domain"].Value, KeyTrinhBay, match[0].Groups["GroupId"].Value); } else { PlayerFile.StrArtist = ""; PlayerFile.StrArtistUrl = ""; } match = Regex.Matches(row, RegexPatternTheLoai, RegexOptions.IgnoreCase); //The loai va link if (match.Count > 0 && match[0] != null && match[0].Success) { string theloaiTemp = match[0].Groups["GroupName"].Value; theloaiTemp = theloaiTemp.Replace("<strong>", ""); theloaiTemp = theloaiTemp.Replace("</strong>", ""); PlayerFile.StrCategory = theloaiTemp; PlayerFile.StrCategoryUrl = string.Format("{0}://{1}{2}{3}", matchDomain.Groups["Protocol"].Value, matchDomain.Groups["Domain"].Value, KeyTheLoai, match[0].Groups["GroupId"].Value); } else { PlayerFile.StrCategory = ""; PlayerFile.StrCategoryUrl = ""; } //ten - casi - the loai //Icon match = Regex.Matches(row, RegexPatternIcon, RegexOptions.IgnoreCase); if (match.Count > 0 && match[0] != null && match[0].Success) { if (match[0].Groups["icon"].Value == "MP3") { item.ImageIndex = 0; } else { item.ImageIndex = 1; } } else { item.ImageIndex = 1; } item.Text = string.Format("{0} - {1} - {2}", PlayerFile.StrName, PlayerFile.StrArtist, PlayerFile.StrCategory); item.Checked = true; item.SubItems.Add(""); _MainForm.Invoke(new MusicOnline.MainForm.delegateUpdate(_MainForm.Update), new object[] { item, PlayerFile }); if (_SearchOne_Or_SearchAll)//search one { break; } } } catch { } _MainForm.Invoke(new MusicOnline.MainForm.delegatePlayFile(_MainForm.AutoPlayFile), new object[] { }); }