private List <DrakenVideo> GetVideos(DrakenCategorySelector selector = DrakenCategorySelector.none, string categoryNameSelector = null, uint size = 1024, string query = "", bool cache = true) { string url = string.Format(drakenVideosUrl, query, size); JObject data = ExtendedWebCache.Instance.GetWebData <JObject>(url, cache: cache); List <DrakenVideo> videos = new List <DrakenVideo>(); foreach (JToken vt in data["hits"].Value <JArray>()) { DrakenVideo video = new DrakenVideo(); video.Airdate = vt["year_of_release"].Value <string>(); video.Countries = vt["countries_of_origin_list"].Value <string>().Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => s.Trim()).ToList(); video.Directors = vt["director_list"].Value <string>().Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => s.Trim()).ToList(); video.Genres = vt["genre_list"].Value <string>().Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => s.Trim()).ToList(); video.Keywords = vt["keyword_list"].Value <string>().Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => s.Trim()).ToList(); video.Languages = vt["spoken_language_list"].Value <string>().Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => s.Trim()).ToList(); video.Description = string.Format("{0} | {1} | {2}\n{3}", string.Join(", ", video.Genres), string.Join(", ", video.Directors), string.Join(", ", video.Countries), vt["summary"].Value <string>()); video.Recommended = vt["recommended"] != null && vt["recommended"].Type == JTokenType.Boolean && vt["recommended"].Value <bool>(); video.Thumb = vt["image_background"].Value <string>(); if (video.Thumb.StartsWith("//")) { video.Thumb = "http:" + video.Thumb; } video.Title = vt["title"].Value <string>(); string trailerPovider = (vt["trailer_provider"] == null || vt["trailer_provider"].Type != JTokenType.String) ? string.Empty : vt["trailer_provider"].Value <string>(); if (trailerPovider == "vimeo") { video.TrailerUrl = string.Format(vimeoVideoUrl, vt["trailer_id"].Value <string>()); } else if (trailerPovider == "youtube") { video.TrailerUrl = string.Format(youtubeVideoUrl, vt["trailer_id"].Value <string>()); } else { video.HasDetails = false; } video.VideoUrl = string.Format(drakenVideoUrl, vt["search_title"].Value <string>()); videos.Add(video); } if (selector == DrakenCategorySelector.recommended) { videos = videos.Where(v => v.Recommended).ToList(); } else if (selector != DrakenCategorySelector.none && !string.IsNullOrWhiteSpace(categoryNameSelector)) { videos = videos.Where(v => v.getListFromSelector(selector).Any(t => t == categoryNameSelector)).ToList(); } return(videos); }
List <DetailVideoInfo> IChoice.GetVideoChoices(VideoInfo video) { DrakenVideo dv = video as DrakenVideo; DetailVideoInfo movie = new DetailVideoInfo(video); movie.Title2 = dv.Title + (HaveCredentials ? string.Empty : " [Inloggning krävs]"); DetailVideoInfo trailer = new DetailVideoInfo(video); trailer.Title2 = "Trailer"; trailer.VideoUrl = dv.TrailerUrl; List <DetailVideoInfo> videos = new List <DetailVideoInfo>() { movie, trailer }; return(videos); }
private List<DrakenVideo> GetVideos(string url) { string data = ExtendedWebCache.Instance.GetWebData(url); List<DrakenVideo> videos = new List<DrakenVideo>(); Regex rgx = new Regex(@"<img\s*src=""(?<ImageUrl>[^""]*)(?:(?!<a\s*class=""title""\s*).)*<a\s*class=""title""\s*href=""(?<VideoUrl>/film/[^""]*)[^>]*>(?<Title>[^<]*)(?:(?!role=""button""><span>).)*role=""button""><span>(?<Director>.*?),\s(?<Airdate>\d\d\d\d)(?:(?!<span\sclass=""summary"">).)*<span\sclass=""summary"">(?<Description>[^<]*)", RegexOptions.Singleline); foreach (Match m in rgx.Matches(data)) { string description = HttpUtility.HtmlDecode(m.Groups["Director"].Value) + ", " + m.Groups["Airdate"].Value + "\r\n" + HttpUtility.HtmlDecode(m.Groups["Description"].Value); DrakenVideo video = new DrakenVideo() { Title = HttpUtility.HtmlDecode(m.Groups["Title"].Value), Description = description, Thumb = m.Groups["ImageUrl"].Value, VideoUrl = "https://www.drakenfilm.se" + m.Groups["VideoUrl"].Value, Airdate = m.Groups["Airdate"].Value, Director = HttpUtility.HtmlDecode(m.Groups["Director"].Value) }; videos.Add(video); } return videos; }