public List <Song> SearchVideos(string key, short pageNumber) { List <Song> listVideos = new List <Song>(); string sourcePage = null; string[] info = key.Split(new char[] { '-' }, 2); string videoTitle; try { videoTitle = info[0]; } catch { videoTitle = ""; } string singerName; try { singerName = info[1]; } catch { singerName = ""; } sourcePage = SourceWeb.GetWebSource(URLSearch[0] + videoTitle + URLSearch[1] + singerName + URLSearch[2] + "3" + URLSearch[3] + pageNumber.ToString()); if (sourcePage == null) { return(null); } listVideos = GetListVideo(sourcePage); return(listVideos); }
public List <Playlist> LoadTop20Albums(short Genre /*1 : V-Pop 2: US-UK, 3: K-Pop */) { List <Playlist> listALbums = new List <Playlist>(); HtmlDocument doc = new HtmlDocument(); string contains = SourceWeb.GetWebSource(URLAlbumPage + GenreArray[Genre]); string s = URLAlbumPage + GenreArray[Genre]; if (contains == null) { return(null); } doc.LoadHtml(contains); HtmlNodeCollection playlists = doc.DocumentNode.SelectSingleNode("//div[@class='fram_select']").SelectNodes(".//li"); foreach (HtmlNode playlist in playlists) { try { Playlist album = new Playlist(); album.URL = playlist.SelectSingleNode(".//div").SelectSingleNode(".//a").GetAttributeValue("href", string.Empty); album.Name_Playlist = playlist.ChildNodes[3].ChildNodes[1].ChildNodes[0].InnerText; album.Image_Playlist = playlist.ChildNodes[1].ChildNodes[1].ChildNodes[3].ChildNodes[0].GetAttributeValue("src", ""); for (int i = 0; i < playlist.ChildNodes[3].ChildNodes[3].ChildNodes.Count; i++) { album.Name_Artist += playlist.ChildNodes[3].ChildNodes[3].ChildNodes[i].InnerText + " "; } listALbums.Add(album); } catch { } } return(listALbums); }
public List <Playlist> LoadNewAlbums(short pagenum) { List <Playlist> listALbums = new List <Playlist>(); HtmlDocument doc = new HtmlDocument(); string contains = SourceWeb.GetWebSource(URLNewALbums + pagenum.ToString()); if (contains == null) { return(null); } doc.LoadHtml(contains); HtmlNode new_playlists = doc.DocumentNode.SelectSingleNode("//div[@class='fram_select']").ChildNodes[4]; if (doc == null) { return(null); } HtmlNodeCollection playlists = new_playlists.SelectNodes(".//li"); foreach (HtmlNode playlist in playlists) { Playlist album = new Playlist(); album.URL = playlist.SelectSingleNode(".//div").SelectSingleNode(".//a").GetAttributeValue("href", string.Empty); album.Top = 0; album.Image_Playlist = playlist.ChildNodes[1].ChildNodes[1].ChildNodes[3].ChildNodes[0].GetAttributeValue("src", ""); album.Name_Playlist = playlist.ChildNodes[3].ChildNodes[1].ChildNodes[0].InnerText; for (int i = 0; i < playlist.ChildNodes[3].ChildNodes[3].ChildNodes.Count; i++) { album.Name_Artist += playlist.ChildNodes[3].ChildNodes[3].ChildNodes[i].InnerText + " "; } listALbums.Add(album); } return(listALbums); }
/// <summary> /// Load các bài hát trong một thể loại /// </summary> /// <param name="key"> Thể loại muốn load</param> /// <param name="pageNumber"> Trang kết quả muốn lấy (bắt đầu từ 0)</param> /// <returns> Trả về danh sách bài hát trong thể loại</returns> public List <Song> LoadSongInGenre(eGenre key, short pageNumber) { List <Song> listSongs = new List <Song>(); string sourcePage = SourceWeb.GetWebSource(URLSongPage + GenreArray[(int)key] + pageNumber.ToString()); if (sourcePage == null) { return(null); } listSongs = GetListSong(sourcePage); return(listSongs); }
/// <summary> /// Load các bài hát mới từ trang nhạc của tui /// </summary> /// <param name="pageNumber"> Số thứ tự của trang muốn load(bắt đàu từ 0) </param> /// <returns> Trả về danh sách các bái hát mới</returns> public List <Song> LoadNewSongs(short pageNumber) { List <Song> listSongs = new List <Song>(); string s = URLNewSongs + pageNumber.ToString() + ".html"; string sourcePage = SourceWeb.GetWebSource(URLNewSongs + pageNumber.ToString() + ".html"); if (sourcePage != null) { listSongs = GetListSong(sourcePage); } return(listSongs); }
public List <Song> LoadNewVideos(short pageNumber) { List <Song> listVideos = new List <Song>(); string sourcePage = null; sourcePage = SourceWeb.GetWebSource("http://www.nhaccuatui.com/mv/video-moi.html?page=" + pageNumber.ToString()); if (sourcePage == null) { return(null); } listVideos = GetListVideo(sourcePage); return(listVideos); }
/// <summary> /// Load các bài hát trong top 20 /// </summary> /// <param name="Genre"> 0 : V-Pop 1: US-UK, 2: K-Pop </param> /// <returns> Trả về danh sách các bài hát trong Top 20</returns> public List <Song> LoadTop20Songs(short genre /*0 : V-Pop 1: US-UK, 2: K-Pop */) { List <Song> listSongs = null; string s = URLSongPage + KeyTop20[genre]; string sourcePage = SourceWeb.GetWebSource(URLSongPage + KeyTop20[genre]); if (sourcePage == null) { return(null); } listSongs = GetTop20Song(sourcePage, genre); return(listSongs); }
/// <summary> /// Tìm các bài hát trên trang Nhạc Của Tui /// </summary> /// <param name="key"> Tên bài hát </param> /// <param name="by"> by = 1 Tìm theo tên bài hát /// by = 2 Tìm theo tên ca sĩ trình bày</param> /// <param name="pageNumber"> Số thứ tự của trang muốn lấy(bắt đàu từ 0) </param> /// <returns> Trả về danh sách các bài hát tìm thấy</returns> public List <Song> Search_Songs(string key, short pageNumber) { List <Song> listSongs = new List <Song>(); string sourcePage = null; sourcePage = SourceWeb.GetWebSource(URLSearch + key + "&page=" + pageNumber.ToString()); if (sourcePage == null) { return(null); } listSongs = GetListSearchSong(sourcePage); return(listSongs); }
public static List <Song> LoadSongFromPlaylistSelected(Playlist Plist) { List <Song> lSong = new List <Song>(); HtmlDocument doc = new HtmlDocument(); string source = SourceWeb.GetWebSource(Plist.URL.Replace("http://www", "http://m")); if (source == null) { return(null); } doc.LoadHtml(source); HtmlNode playlist = doc.DocumentNode.SelectSingleNode("//div[@id='songList']"); HtmlNode songnode = playlist.SelectSingleNode("div[@class='pd-playlist']").SelectSingleNode("div[@class='row active']"); Song playing_song = new Song(); playing_song.Name_Album = Plist.Name_Playlist; playing_song.Name_Artist = Plist.Name_Artist; playing_song.Name_Artist = songnode.SelectSingleNode("p").InnerText; playing_song.URL = songnode.SelectSingleNode("h3").SelectSingleNode("a").GetAttributeValue("href", ""); //playing_song.LinkStream = ""; playing_song.Name_Song = songnode.SelectSingleNode("h3").SelectSingleNode("a").InnerText; playing_song.Image_Song = Plist.Image_Playlist; lSong.Add(playing_song); HtmlNodeCollection songsnode = playlist.SelectSingleNode("div[@class='pd-playlist']").SelectNodes("div[@class='row ']"); foreach (HtmlNode song in songsnode) { Song next_song = new Song(); next_song.Online = true; next_song.Name_Album = Plist.Name_Playlist; next_song.Name_Artist = Plist.Name_Artist; next_song.Name_Artist = song.SelectSingleNode("p").InnerText; next_song.URL = song.SelectSingleNode("h3").SelectSingleNode("a").GetAttributeValue("href", ""); //HtmlDocument next_doc = new HtmlDocument(); //if (next_doc == null) return null; //next_doc.LoadHtml(SourceWeb.GetWebSource(next_song.URL)); //next_song.LinkStream = ""; next_song.Name_Song = song.SelectSingleNode("h3").SelectSingleNode("a").InnerText; next_song.Image_Song = Plist.Image_Playlist; lSong.Add(next_song); } return(lSong); }
public static void GetMoreVideoInfo(string linkPage, out string linkStream, out string size) { HtmlDocument wap = new HtmlDocument(); wap.LoadHtml(SourceWeb.GetWebSource(linkPage.Replace("http://www", "http://m"))); try { HtmlNode linkStreamNode = wap.DocumentNode.SelectSingleNode("//div[@class='player-video']/div/div/a"); linkStream = linkStreamNode.GetAttributeValue("href", null); WebRequest request; WebResponse reponse; request = WebRequest.Create(linkStream); request.Method = "HEAD"; reponse = request.GetResponse(); size = Math.Round(reponse.ContentLength * 1.0 / 1024 / 1024, 2).ToString() + "MB"; reponse.Close(); } catch { linkStream = null; size = null; } }
public List <Playlist> SearchPlaylists(string key) { List <Playlist> listPlaylist = new List <Playlist>(); string sourcePage = null; string[] info = key.Split('-'); string albumTitle; try { albumTitle = info[0]; } catch { albumTitle = ""; } string singerName; try { singerName = info[1]; } catch { singerName = ""; } sourcePage = SourceWeb.GetWebSource(URLSearch[0] + albumTitle + URLSearch[1] + singerName + URLSearch[2] + "2" + URLSearch[3] + "1"); if (sourcePage == null) { return(null); } listPlaylist = GetListPlaylist(sourcePage); return(listPlaylist); }
public static Song GetMoreSongInfo(Song Item, bool isGetSize = false) { string linkStream; // Lấy image HtmlDocument wap = new HtmlDocument(); wap.LoadHtml(SourceWeb.GetWebSource(Item.URL.Replace("http://www", "http://m"))); HtmlNode playerSong = wap.DocumentNode.SelectSingleNode("//div[@class='player-song']"); Item.Name_Song = playerSong.ChildNodes[1].InnerText.Trim(); Item.Name_Artist = playerSong.ChildNodes[3].ChildNodes[3].InnerText.Trim(); //Lấy Stream try { HtmlNode stream = wap.DocumentNode.SelectSingleNode("//div[@class='download']"); if (Item.Quality == null) { linkStream = stream.SelectSingleNode(".//a").GetAttributeValue("href", ""); if (isGetSize) { WebRequest request; WebResponse reponse; request = WebRequest.Create(linkStream); request.Method = "HEAD"; reponse = request.GetResponse(); reponse.Close(); } } else if (Item.Quality.Contains("128")) { linkStream = stream.SelectSingleNode(".//a").GetAttributeValue("href", ""); if (isGetSize) { WebRequest request; WebResponse reponse; request = WebRequest.Create(linkStream); request.Method = "HEAD"; reponse = request.GetResponse(); reponse.Close(); } } else { WebRequest request; WebResponse reponse; HtmlNode pdlikeNode = wap.DocumentNode.SelectSingleNode("//div[@class='pdlike']"); HtmlNode _blankNode = pdlikeNode.SelectSingleNode(".//a[@target='_blank']"); request = WebRequest.Create(_blankNode.GetAttributeValue("href", "")); reponse = request.GetResponse(); linkStream = reponse.ResponseUri.ToString(); if (linkStream.Contains("login")) { linkStream = stream.SelectSingleNode(".//a").GetAttributeValue("href", ""); } reponse.Close(); } } catch { linkStream = null; } Item.URL = linkStream; return(Item); }
/// <summary> /// Lấy thêm thông tin (Link Stream, Size, PictureCover)vào đối tượng song của lớp Media.NowPlayingSong /// </summary> /// <param name="song"> đối tượng được bổ sung thông tin</param> public static List <Song> GetMoreSongInfo(string linkPage, out string linkStream, out string lyric, out string linkPicture, out System.Windows.Media.Imaging.BitmapImage pictureCover, string quality, out string size, string albumCover, bool isGetSize = false) { lyric = ""; size = ""; linkPicture = ""; HtmlDocument wap = new HtmlDocument(); wap.LoadHtml(SourceWeb.GetWebSource(linkPage.Replace("http://www", "http://m"))); //Lấy lyrics try { HtmlNode lyricNode = wap.DocumentNode.SelectSingleNode("//div[@class='lyric']"); foreach (HtmlNode node in lyricNode.ChildNodes) { lyric += WebUtility.HtmlDecode(node.InnerText); } } catch { } //Lấy Stream try { HtmlNode stream = wap.DocumentNode.SelectSingleNode("//div[@class='download']"); if (quality == null) { linkStream = stream.SelectSingleNode(".//a").GetAttributeValue("href", ""); if (isGetSize) { WebRequest request; WebResponse reponse; request = WebRequest.Create(linkStream); request.Method = "HEAD"; reponse = request.GetResponse(); size = Math.Round(reponse.ContentLength * 1.0 / 1024 / 1024, 2).ToString() + "MB"; reponse.Close(); } } else if (quality.Contains("128")) { linkStream = stream.SelectSingleNode(".//a").GetAttributeValue("href", ""); if (isGetSize) { WebRequest request; WebResponse reponse; request = WebRequest.Create(linkStream); request.Method = "HEAD"; reponse = request.GetResponse(); size = Math.Round(reponse.ContentLength * 1.0 / 1024 / 1024, 2).ToString() + "MB"; reponse.Close(); } } else { WebRequest request; WebResponse reponse; HtmlNode pdlikeNode = wap.DocumentNode.SelectSingleNode("//div[@class='pdlike']"); HtmlNode _blankNode = pdlikeNode.SelectSingleNode(".//a[@target='_blank']"); request = WebRequest.Create(_blankNode.GetAttributeValue("href", "")); reponse = request.GetResponse(); linkStream = reponse.ResponseUri.ToString(); if (linkStream.Contains("login")) { linkStream = stream.SelectSingleNode(".//a").GetAttributeValue("href", ""); } //size if (isGetSize) { size = Math.Round(reponse.ContentLength * 1.0 / 1024 / 1024, 2).ToString() + "MB"; } reponse.Close(); } } catch { linkStream = null; } if (albumCover == null) { pictureCover = new System.Windows.Media.Imaging.BitmapImage(new Uri(/*MY_PACK_URIS.ALBUM_COVER_PICTURE.NHAC_CUA_TUI*/ null)); } else { pictureCover = new System.Windows.Media.Imaging.BitmapImage(new Uri(albumCover)); linkPicture = albumCover; } //Lấy các bài hát gợi ý HtmlNodeCollection nodeSuggestSongs = wap.DocumentNode.SelectNodes("//div[@id='relatedSong']/div[@class='row bgmusic ']"); if (nodeSuggestSongs == null) { return(null); } List <Song> listSuggestSong = new List <Song>(); foreach (HtmlNode nodeSong in nodeSuggestSongs) { Song tempSong = new Song(); HtmlNode nodeArtist = nodeSong.SelectSingleNode(".//p"); tempSong.Name_Artist = nodeArtist.ChildNodes[1].InnerText; HtmlNode nodeTitle = nodeSong.SelectSingleNode(".//h3/a"); tempSong.Name_Song = nodeTitle.InnerText; tempSong.URL = nodeTitle.GetAttributeValue("href", null).Replace("http://m", "http://www"); tempSong.Name_Album = "Nhac Cua Tui"; if (tempSong.URL != null) { listSuggestSong.Add(tempSong); } } return(listSuggestSong); }
public static Song GetMoreSongInfo(Song Item, bool isGetSize = false) { string lyric = ""; string linkStream; // Lấy image Item.Image_Song = ""; HtmlDocument wap = new HtmlDocument(); wap.LoadHtml(SourceWeb.GetWebSource(Item.URL)); HtmlNode ImageNode = wap.DocumentNode.SelectSingleNode("//div[@class='box_singer_pri']").ChildNodes[1].ChildNodes[0]; Item.Image_Song = ImageNode.GetAttributeValue("src", ""); if (Item.Image_Song == null) { Item.Image_Song = Picture.NHAC_CUA_TUI; } wap.LoadHtml(SourceWeb.GetWebSource(Item.URL.Replace("http://www", "http://m"))); //Lấy lyrics try { HtmlNode lyricNode = wap.DocumentNode.SelectSingleNode("//div[@class='lyric']"); foreach (HtmlNode node in lyricNode.ChildNodes) { lyric += WebUtility.HtmlDecode(node.InnerText); } } catch { } Item.Lyric_Song = lyric; //Lấy Stream try { HtmlNode stream = wap.DocumentNode.SelectSingleNode("//div[@class='download']"); if (Item.Quality == null) { linkStream = stream.SelectSingleNode(".//a").GetAttributeValue("href", ""); if (isGetSize) { WebRequest request; WebResponse reponse; request = WebRequest.Create(linkStream); request.Method = "HEAD"; reponse = request.GetResponse(); reponse.Close(); } } else if (Item.Quality.Contains("128")) { linkStream = stream.SelectSingleNode(".//a").GetAttributeValue("href", ""); if (isGetSize) { WebRequest request; WebResponse reponse; request = WebRequest.Create(linkStream); request.Method = "HEAD"; reponse = request.GetResponse(); reponse.Close(); } } else { WebRequest request; WebResponse reponse; HtmlNode pdlikeNode = wap.DocumentNode.SelectSingleNode("//div[@class='pdlike']"); HtmlNode _blankNode = pdlikeNode.SelectSingleNode(".//a[@target='_blank']"); request = WebRequest.Create(_blankNode.GetAttributeValue("href", "")); reponse = request.GetResponse(); linkStream = reponse.ResponseUri.ToString(); if (linkStream.Contains("login")) { linkStream = stream.SelectSingleNode(".//a").GetAttributeValue("href", ""); } reponse.Close(); } } catch { linkStream = null; } Item.URL = linkStream; return(Item); }