public static List<YoutubeObject> GetListYoutubeVD(string content) { List<YoutubeObject> youtube_videos = new List<YoutubeObject>(); string regexBlock = @"class=""yt-uix-tile yt-lockup-list yt-tile-default yt-grid-box "">.*?(?=\sviews</span>)"; List<string> result_blocks = Utility.SimpleRegex(regexBlock, content, 0); foreach (string block in result_blocks) { YoutubeObject yo = new YoutubeObject(); yo.image = Utility.SimpleRegexSingle(@"src=""([^""]*)""\s*alt=""Thumbnail""", block, 1); if (yo.image.StartsWith("//")) yo.image = "http:" + yo.image; yo.description = Utility.SimpleRegexSingle(@"-description"" dir=""ltr"">(.*?)(?=</p>)", block, 1); yo.youtube_url = Utility.SimpleRegexSingle(@"dir=""ltr""title=""([^""]*)""href=""([^""&]*)"">", block, 2); yo.title = Utility.SimpleRegexSingle(@"dir=""ltr""title=""([^""]*)""href=""([^""&]*)"">", block, 1); if (yo.youtube_url == "") continue; youtube_videos.Add(yo); } return youtube_videos; }
internal void AddFavoriteYoutube(YoutubeObject youtubeObject) { favYoutubeList.Add(youtubeObject); SaveYoutubeFav(); LoadFavoriteYoutube(); }
public void LoadFavoriteYoutube() { InitFav(); string res = Utility.ReadFile(favoriteYoutubeFile); List<string> youtube_url = Utility.ReadAttribueXpath(res, "/fs/f", "youtube_url"); List<string> image = Utility.ReadAttribueXpath(res, "/fs/f", "image"); List<string> author = Utility.ReadAttribueXpath(res, "/fs/f", "author"); List<string> author_url = Utility.ReadAttribueXpath(res, "/fs/f", "author_url"); List<string> view_count = Utility.ReadAttribueXpath(res, "/fs/f", "view_count"); List<string> has_uploaded_date = Utility.ReadAttribueXpath(res, "/fs/f", "has_uploaded_date"); List<string> description = Utility.ReadAttribueXpath(res, "/fs/f", "description"); List<string> title = Utility.ReadAttribueXpath(res, "/fs/f", "title"); List<string> time = Utility.ReadAttribueXpath(res, "/fs/f", "time"); favYoutubeList.Clear(); for (int i = 0; i < youtube_url.Count; i++) { YoutubeObject ch = new YoutubeObject(); ch.youtube_url = Utility.URLDecode(youtube_url[i]); ch.image = Utility.URLDecode(image[i]); ch.author = Utility.URLDecode(author[i]); ch.author_url = Utility.URLDecode(author_url[i]); ch.view_count = Utility.URLDecode(view_count[i]); ch.has_uploaded_date = Utility.URLDecode(has_uploaded_date[i]); ch.description = Utility.URLDecode(description[i]); ch.title = Utility.URLDecode(title[i]); ch.time = Utility.URLDecode(time[i]); favYoutubeList.Add(ch); } }